# Subscriptions | Signal House API Docs

> Manage Signal House plans and subscriptions through the API.

Source: https://docs.signalhouse.io/subscriptions

---

## Subscriptions

### GET /subscription/user

Retrieve subscription records for a group. Returns all records (including expired) by default; pass onlyActive=true to exclude expired subscriptions. Custom volume-tiered plans also return volumeTiers, monthlyMinimumSmsSegments, rampDays, rampEndsAt, volumeContractStartedAt, periodOutboundSmsSegments, volumePeriodClosedAt, nextPeriodOutboundSmsSegments, laterPeriodOutboundSmsSegments, volumeTrueUpLines, unpaidVolumeTrueUpLines, unpaidMonthlyFees, and nextRenewalAttemptAt. A volume plan's periods are UTC calendar months, and an expired period keeps its own periodEnd, so consecutive periods never overlap. laterPeriodOutboundSmsSegments is present only when the period's renewal is more than a month late: it holds the segments sent in each later calendar month, keyed YYYY-MM, so each month keeps its own count. nextRenewalAttemptAt is null unless a renewal charge failed, in which case it is when the renewal is next retried. volumePeriodClosedAt is null except while the period is being closed for billing; from then on periodOutboundSmsSegments is final and new sends are counted in nextPeriodOutboundSmsSegments, which becomes the next period's starting count. volumeTrueUpLines is absent until the period is closed, then lists the shortfall billed for it as \[{ quantity, unitPrice }\] in microdollars (empty when the minimum was met). unpaidVolumeTrueUpLines lists shortfall from earlier periods whose payment failed, as \[{ quantity, unitPrice, referenceId }\]; the plan still moves to its next period on schedule, and this debt is collected with that period's own shortfall at its close. It is empty when nothing is owed. unpaidMonthlyFees lists monthly fees from earlier periods whose payment failed, as \[{ amount, description, referenceId }\] in microdollars, collected at the same time; empty when nothing is owed. Every subscription also returns periodChargesFundedAmount: microdollars already charged to the card and credited to the wallet for charges not yet settled, so a retry charges the card only for the rest; 0 when nothing is pending. periodChargesFundedLines lists the charges that amount was collected for, as \[{ referenceId, amount }\], and periodChargesFundingPending is { amount, startedAt, attemptId } while a card charge for them is in progress or awaiting reconciliation, otherwise null.

**The following roles are required to use this endpoint:** `admin`, `developer`, `api`, `user`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | Query Param | Required | Group ID. |
| `onlyActive` | Query Param | Optional | Boolean. |

#### Example Response 200

Response

```json
[
  {
    "_id": "60f7b2a1c9e77c001a2b3c60",
    "groupId": "G1234567",
    "templateId": "60f7b2a1c9e77c001a2b3c5f",
    "name": "Pro Plan",
    "description": "Ideal for growing businesses with high messaging volume.",
    "monthlyFee": 99000000,
    "monthlyPlanSmsSegments": 10000,
    "accumulatedSmsSegments": 10000,
    "usedSmsSegments": 3500,
    "monthlyPlanMmsSegments": 2000,
    "accumulatedMmsSegments": 2000,
    "usedMmsSegments": 500,
    "status": "ACTIVE",
    "periodStart": "2024-01-15T00:00:00.000Z",
    "periodEnd": "2024-02-14T00:00:00.000Z",
    "createdAt": "2024-01-15T00:00:00.000Z",
    "updatedAt": "2024-01-15T00:00:00.000Z"
  }
]
```

### POST /subscription/user/subscribe/:groupId/:templateId

Subscribe a group to a paid template plan (Charges wallet immediately). Always returns HTTP 201, but the response body has three possible shapes: (a) New plan or upgrade — returns a new subscription object with status: 'ACTIVE' and a fresh \_id. (b) Downgrade — returns the existing subscription object updated to status: 'PENDING\_DOWNGRADE' with nextTemplateId set to the requested template; periodStart/periodEnd are unchanged. (c) Same plan — returns { Message: 'You are already on the same plan' } (capital-M key, not a subscription object). Returns 400 when the group is on a contracted volume-tiered plan: that plan cannot be switched to a template. Contact Signal House to change or end it.

**The following roles are required to use this endpoint:** `admin`, `developer`, `api`, `user`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | URL Param | Required | Group ID. |
| `templateId` | URL Param | Required | Subscription Template ObjectId. |

#### Example Response 201

Response

```json
{
  "_id": "60f7b2a1c9e77c001a2b3c60",
  "groupId": "G1234567",
  "templateId": "60f7b2a1c9e77c001a2b3c5f",
  "name": "Pro Plan",
  "monthlyFee": 99000000,
  "status": "ACTIVE",
  "periodStart": "2024-01-15T00:00:00.000Z",
  "periodEnd": "2024-02-14T00:00:00.000Z",
  "createdAt": "2024-01-15T00:00:00.000Z"
}
```

### POST /subscription/user/cancel/:groupId

Cancel a group's active subscription (downgrades at end of billing cycle). A contracted volume-tiered plan can only be cancelled by Signal House: for these roles the request returns 403 when the group is on one. Contact Signal House to change or end it.

**The following roles are required to use this endpoint:** `admin`, `developer`, `api`, `user`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | URL Param | Required | Group ID. |

#### Example Response 200

Response

```json
{
  "_id": "60f7b2a1c9e77c001a2b3c70",
  "groupId": "G1234567",
  "templateId": "60f7b2a1c9e77c001a2b3c71",
  "name": "Pro Plan",
  "monthlyFee": 99000000,
  "status": "PENDING_DOWNGRADE",
  "nextTemplateId": null,
  "periodStart": "2024-01-15T00:00:00.000Z",
  "periodEnd": "2024-02-14T00:00:00.000Z",
  "createdAt": "2024-01-15T00:00:00.000Z",
  "updatedAt": "2024-01-20T12:00:00.000Z"
}
```
