# Billing | Signal House API Docs

> Read your Signal House wallet balance, transactions and payment methods through the API.

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

---

## Billing & Wallets

### GET /billing/fees/:groupId

Retrieve the fee schedule for a group. Returns fees from the active subscription if one exists (source: 'subscription'), otherwise falls back to the group's fee schedule (source: 'feeSchedule'). When source is 'subscription', a subscriptionType field ('template' or 'custom') is also present. When the active custom subscription has volume tiers, an additive volumePricing object is included (tiers, periodStart, periodEnd, periodOutboundSmsSegments, monthlyMinimumSmsSegments, periodMinimumSmsSegments, rampDays, rampEndsAt, inRamp, currentRate). The monthly minimum ramps up linearly over rampDays: periodMinimumSmsSegments is the minimum the current billing period owes (the share of monthlyMinimumSmsSegments matching how far through the ramp the period ends, rounded down). Volume plans bill by UTC calendar month, starting on the 1st; outside the ramp, a period that covers only part of its month, such as the first month of a plan that starts on the 15th, owes the matching share of the minimum, and its shortfall is measured against that share. inRamp is true while that is still less than the full minimum. smsOutbound remains the first-tier list rate and does not change as volume is consumed. periodStart, periodEnd, periodOutboundSmsSegments, currentRate, periodMinimumSmsSegments and inRamp all describe the calendar month the next send counts toward: once a period's end has passed they describe the following month, even before that period's renewal has run. All fee values are in microdollars (divide by 1,000,000 for USD). Messaging fees come in six parallel rails: unsuffixed fields bill 10DLC traffic, \*TollFree fields bill Toll-Free traffic, and \*ShortCode fields bill Short Code traffic (base sms/mms in/out plus per-carrier pass-through for Default, T-Mobile, AT&T, Verizon, US Cellular, ClearSky, and Interop; Puerto Rico and Guam carriers bill at platform regional rates). \*Canada and \*CanadaTollFree fields are the Canada rails, chosen by a Canadian recipient handset: a toll-free sender bills \*CanadaTollFree and every other sender bills \*Canada. Each rail is a stored base per segment (SMS) or per message (MMS) plus an outbound carrier fee per carrier (Bell, Rogers, Telus, Videotron, SaskTel, Eastlink, Fibernetics, and Default for every other carrier), passed through at cost and billed as its own line. An inbound message to a Canadian number bills its rail's inbound base (smsInbound\* / mmsInbound\*) as its own line; the Canada inbound carrier fields are 0. numberCanadaLocal and numberCanadaTollFree are charged at purchase (the first month) and their \*Renew siblings each month. \*Uk fields are the UK rail, chosen by a GB recipient handset whatever the sender. Its smsCarrierOutbound\* fields (EE, O2, Vodafone, Sky, Lycamobile, Standard, Three, Default) and its number fields (numberUkLocal, numberUkLocalVoice, numberUkAlphanumeric for a UK Alphanumeric Sender ID, and the \*Renew siblings) are a negotiated price or null: a number is charged as stored, and null means the price is derived from Signal House's rate card at the platform's margin or multiplier. The response's retail object gives, keyed by those field names, the price actually charged either way: the all-in price per segment for a carrier field (including the rail's smsOutboundUk surcharge), and the setup or monthly price for a number field. Read a UK price from retail. shortCodeActivation and shortCodeMmsEnablement are each charged once for every Short Code brought into service, whether Signal House leases it (RANDOM or VANITY, at fulfillment) or the customer leases it directly (EXTERNAL\_LEASE, at request). shortCodeLeaseMonthly (RANDOM) or shortCodeVanityLeaseMonthly (VANITY) is charged monthly on a Signal House-leased number until its lease end date; externally leased codes pay no monthly lease. brandVettingRcsAegis and the rcs\* fields are the RCS agent registration fees: the Aegis brand vet, the RCS vet the carrier partner runs (rcsVetting, renewed yearly at rcsVetRenewal), the logo and banner vets, the agent token, the Aegis campaign verification and the T-Mobile activation. rcsAgentMonthly is the monthly agent fee: a launched agent pays it every month, from a month after its first carrier launch until the agent is archived. simSwapCheck and numberVerifyCheck are the Verify fees: simSwapCheck once per SIM Swap check that answers, with or without the swap date, and numberVerifyCheck per Number Verify check that ends VERIFIED or NOT\_VERIFIED. The voice fees (voiceOutboundPerSecond, voiceInboundPerSecond, voiceConferencePerMinute, recordingPerMinute, transcriptionPerMinute, sentimentPerRequest, aiAgentPerMinute, voiceDIDMonthly, voiceTollFreeDIDMonthly, didSetup, trunkSetup, profileSetup) are priced in the unit their name gives and always come from the group's fee schedule, also when source is 'subscription'. aiAgentPerMinute is the rate for an AI voice agent's time on a call, prorated per second, on top of the call's own rate. A fee field introduced after an account's fee document was written is reported at the price the account is charged for it: a subscription that lacks the field reports the group's fee schedule price, and a field neither holds reports its default.

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

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | URL Param | Required | Group ID starting with 'G'. |

#### Example Response 200

Response

```json
{
  "source": "feeSchedule",
  "fees": {
    "smsInbound": 0,
    "smsOutbound": 20000,
    "smsCarrierInboundDefault": 4000,
    "smsCarrierOutboundDefault": 4000,
    "smsCarrierInboundTMobile": 2500,
    "smsCarrierOutboundTMobile": 4500,
    "smsCarrierInboundATT": 3500,
    "smsCarrierOutboundATT": 3500,
    "smsCarrierInboundVerizon": 0,
    "smsCarrierOutboundVerizon": 5000,
    "smsCarrierInboundUSCellular": 2500,
    "smsCarrierOutboundUSCellular": 4500,
    "smsCarrierInboundGoogleVoice": 3500,
    "smsCarrierOutboundGoogleVoice": 3500,
    "smsCarrierInboundClearSky": 5000,
    "smsCarrierOutboundClearSky": 5000,
    "smsCarrierInboundInterop": 4500,
    "smsCarrierOutboundInterop": 4500,
    "mmsInbound": 0,
    "mmsOutbound": 22000,
    "mmsCarrierInboundDefault": 10000,
    "mmsCarrierOutboundDefault": 10000,
    "mmsCarrierInboundTMobile": 2500,
    "mmsCarrierOutboundTMobile": 4500,
    "mmsCarrierInboundATT": 3500,
    "mmsCarrierOutboundATT": 3500,
    "mmsCarrierInboundVerizon": 0,
    "mmsCarrierOutboundVerizon": 7000,
    "mmsCarrierInboundUSCellular": 2500,
    "mmsCarrierOutboundUSCellular": 4500,
    "mmsCarrierInboundGoogleVoice": 3500,
    "mmsCarrierOutboundGoogleVoice": 3500,
    "mmsCarrierInboundClearSky": 4000,
    "mmsCarrierOutboundClearSky": 4000,
    "mmsCarrierInboundInterop": 3500,
    "mmsCarrierOutboundInterop": 3500,
    "smsOutboundTollFree": 8000,
    "smsInboundTollFree": 8000,
    "mmsOutboundTollFree": 20000,
    "mmsInboundTollFree": 20000,
    "smsCarrierInboundDefaultTollFree": 0,
    "smsCarrierOutboundDefaultTollFree": 4000,
    "smsCarrierInboundTMobileTollFree": 3000,
    "smsCarrierOutboundTMobileTollFree": 3000,
    "smsCarrierInboundATTTollFree": 3000,
    "smsCarrierOutboundATTTollFree": 3000,
    "smsCarrierInboundVerizonTollFree": 0,
    "smsCarrierOutboundVerizonTollFree": 5000,
    "smsCarrierInboundUSCellularTollFree": 3000,
    "smsCarrierOutboundUSCellularTollFree": 3000,
    "mmsCarrierInboundDefaultTollFree": 0,
    "mmsCarrierOutboundDefaultTollFree": 10000,
    "mmsCarrierInboundTMobileTollFree": 10000,
    "mmsCarrierOutboundTMobileTollFree": 10000,
    "mmsCarrierInboundATTTollFree": 7500,
    "mmsCarrierOutboundATTTollFree": 7500,
    "mmsCarrierInboundVerizonTollFree": 0,
    "mmsCarrierOutboundVerizonTollFree": 6500,
    "mmsCarrierInboundUSCellularTollFree": 10000,
    "mmsCarrierOutboundUSCellularTollFree": 10000,
    "smsOutboundShortCode": 6500,
    "smsInboundShortCode": 0,
    "mmsOutboundShortCode": 22000,
    "mmsInboundShortCode": 22000,
    "smsCarrierInboundDefaultShortCode": 0,
    "smsCarrierOutboundDefaultShortCode": 4500,
    "smsCarrierInboundTMobileShortCode": 2500,
    "smsCarrierOutboundTMobileShortCode": 4500,
    "smsCarrierInboundATTShortCode": 3500,
    "smsCarrierOutboundATTShortCode": 3500,
    "smsCarrierInboundVerizonShortCode": 0,
    "smsCarrierOutboundVerizonShortCode": 5000,
    "smsCarrierInboundUSCellularShortCode": 2500,
    "smsCarrierOutboundUSCellularShortCode": 4500,
    "smsCarrierInboundClearSkyShortCode": 5000,
    "smsCarrierOutboundClearSkyShortCode": 5000,
    "smsCarrierInboundInteropShortCode": 4500,
    "smsCarrierOutboundInteropShortCode": 4500,
    "mmsCarrierInboundDefaultShortCode": 0,
    "mmsCarrierOutboundDefaultShortCode": 10000,
    "mmsCarrierInboundTMobileShortCode": 10000,
    "mmsCarrierOutboundTMobileShortCode": 10000,
    "mmsCarrierInboundATTShortCode": 9000,
    "mmsCarrierOutboundATTShortCode": 9000,
    "mmsCarrierInboundVerizonShortCode": 0,
    "mmsCarrierOutboundVerizonShortCode": 7000,
    "mmsCarrierInboundUSCellularShortCode": 10000,
    "mmsCarrierOutboundUSCellularShortCode": 10000,
    "mmsCarrierInboundClearSkyShortCode": 10000,
    "mmsCarrierOutboundClearSkyShortCode": 10000,
    "mmsCarrierInboundInteropShortCode": 5000,
    "mmsCarrierOutboundInteropShortCode": 10000,
    "shortCodeActivation": 1000000000,
    "shortCodeMmsEnablement": 500000000,
    "shortCodeLeaseMonthly": 1000000000,
    "shortCodeVanityLeaseMonthly": 1500000000,
    "numberLocal": 1000000,
    "numberLocalRenew": 1000000,
    "smsInboundCanada": 6500,
    "smsOutboundCanada": 6500,
    "smsCarrierInboundDefaultCanada": 0,
    "smsCarrierOutboundDefaultCanada": 6400,
    "smsCarrierOutboundBellCanada": 8000,
    "smsCarrierOutboundRogersCanada": 9000,
    "smsCarrierOutboundTelusCanada": 7500,
    "smsCarrierOutboundVideotronCanada": 6500,
    "smsCarrierOutboundSaskTelCanada": 6000,
    "smsCarrierOutboundEastlinkCanada": 6000,
    "smsCarrierOutboundFiberneticsCanada": 3800,
    "mmsInboundCanada": 24500,
    "mmsOutboundCanada": 24500,
    "mmsCarrierOutboundBellCanada": 29000,
    "smsInboundCanadaTollFree": 7900,
    "smsOutboundCanadaTollFree": 7900,
    "smsCarrierInboundDefaultCanadaTollFree": 0,
    "smsCarrierOutboundDefaultCanadaTollFree": 6400,
    "smsCarrierOutboundBellCanadaTollFree": 8700,
    "mmsInboundCanadaTollFree": 27800,
    "mmsOutboundCanadaTollFree": 27800,
    "mmsCarrierOutboundBellCanadaTollFree": 32300,
    "numberCanadaLocal": 1100000,
    "numberCanadaLocalRenew": 1100000,
    "numberCanadaTollFree": 1250000,
    "numberCanadaTollFreeRenew": 1250000,
    "smsInboundUk": 0,
    "smsOutboundUk": 0,
    "smsCarrierInboundDefaultUk": 0,
    "smsCarrierOutboundEEUk": null,
    "smsCarrierOutboundDefaultUk": null,
    "numberUkLocal": null,
    "numberUkLocalRenew": null,
    "numberUkLocalVoice": null,
    "numberUkLocalVoiceRenew": null,
    "numberUkAlphanumeric": null,
    "numberUkAlphanumericRenew": null,
    "brandCreate": 4500000,
    "campaignCreate": 15000000,
    "brandVettingRcsAegis": 75000000,
    "rcsVetting": 100000000,
    "rcsVetRenewal": 50000000,
    "rcsAgentMonthly": 100000000,
    "rcsLogoVet": 20000000,
    "rcsBannerVet": 20000000,
    "rcsAgentToken": 10000000,
    "rcsCampaignVerify": 10000000,
    "rcsCarrierActivationTMobile": 500000000,
    "simSwapCheck": 10000,
    "numberVerifyCheck": 10000,
    "voiceOutboundPerSecond": 233,
    "voiceInboundPerSecond": 142,
    "voiceConferencePerMinute": 1800,
    "recordingPerMinute": 2500,
    "transcriptionPerMinute": 200000,
    "sentimentPerRequest": 10000,
    "aiAgentPerMinute": 220000,
    "voiceDIDMonthly": 5000000,
    "voiceTollFreeDIDMonthly": 7500000,
    "didSetup": 1000000,
    "trunkSetup": 5000000,
    "profileSetup": 1000000,
    "rcsRichOutbound": 6500,
    "rcsRichMediaOutbound": 16000,
    "rcsRichInbound": 5000,
    "rcsRichMediaInbound": 5000,
    "rcsActionClick": 1000,
    "rcsMediaSurchargeTMobile": 1000,
    "rcsCarrierOutboundATT": 4500,
    "rcsCarrierOutboundTMobile": 6200,
    "rcsCarrierOutboundVerizon": 5000,
    "rcsCarrierOutboundUSCellular": 6200,
    "rcsCarrierOutboundClearSky": 4000,
    "rcsCarrierOutboundInterop": 3000,
    "rcsCarrierOutboundSpectrum": 4000,
    "rcsCarrierOutboundXfinity": 4000,
    "rcsCarrierOutboundDefault": 6200,
    "rcsCarrierRichMediaOutboundATT": 10000,
    "rcsCarrierRichMediaOutboundTMobile": 12500,
    "rcsCarrierRichMediaOutboundVerizon": 7000,
    "rcsCarrierRichMediaOutboundUSCellular": 12500,
    "rcsCarrierRichMediaOutboundClearSky": 10000,
    "rcsCarrierRichMediaOutboundInterop": 5000,
    "rcsCarrierRichMediaOutboundSpectrum": 6000,
    "rcsCarrierRichMediaOutboundXfinity": 8000,
    "rcsCarrierRichMediaOutboundDefault": 12500,
    "rcsCarrierInboundATT": 4500,
    "rcsCarrierInboundTMobile": 2500,
    "rcsCarrierInboundVerizon": 0,
    "rcsCarrierInboundUSCellular": 2500,
    "rcsCarrierInboundClearSky": 4000,
    "rcsCarrierInboundInterop": 0,
    "rcsCarrierInboundSpectrum": 4000,
    "rcsCarrierInboundXfinity": 0,
    "rcsCarrierInboundDefault": 4500,
    "rcsCarrierRichMediaInboundATT": 10000,
    "rcsCarrierRichMediaInboundTMobile": 12500,
    "rcsCarrierRichMediaInboundVerizon": 0,
    "rcsCarrierRichMediaInboundUSCellular": 12500,
    "rcsCarrierRichMediaInboundClearSky": 10000,
    "rcsCarrierRichMediaInboundInterop": 0,
    "rcsCarrierRichMediaInboundSpectrum": 6000,
    "rcsCarrierRichMediaInboundXfinity": 0,
    "rcsCarrierRichMediaInboundDefault": 12500,
    "rcsSession": 55000,
    "rcsCarrierSessionA2PATT": 30000,
    "rcsCarrierSessionA2PTMobile": 60000,
    "rcsCarrierSessionA2PVerizon": 9000,
    "rcsCarrierSessionA2PSpectrum": 9000,
    "rcsCarrierSessionA2PDish": 9000,
    "rcsCarrierSessionA2PClearSky": 30000,
    "rcsCarrierSessionA2PXfinity": 10000,
    "rcsCarrierSessionA2PDefault": 60000,
    "rcsCarrierSessionP2AATT": 30000,
    "rcsCarrierSessionP2ATMobile": 60000,
    "rcsCarrierSessionP2AVerizon": 9000,
    "rcsCarrierSessionP2ASpectrum": 9000,
    "rcsCarrierSessionP2ADish": 9000,
    "rcsCarrierSessionP2AClearSky": 30000,
    "rcsCarrierSessionP2AXfinity": 0,
    "rcsCarrierSessionP2ADefault": 60000
  },
  "retail": {
    "smsCarrierOutboundEEUk": 159500,
    "smsCarrierOutboundDefaultUk": 230000,
    "numberUkLocal": 6000000,
    "numberUkLocalRenew": 6000000,
    "numberUkLocalVoice": 30000000,
    "numberUkLocalVoiceRenew": 30000000,
    "numberUkAlphanumeric": 6000000,
    "numberUkAlphanumericRenew": 6000000
  },
  "volumePricing": {
    "tiers": [
      {
        "upTo": 1000000,
        "rate": 5000
      },
      {
        "upTo": 5000000,
        "rate": 4500
      },
      {
        "upTo": null,
        "rate": 4000
      }
    ],
    "periodStart": "2026-10-15T00:00:00.000Z",
    "periodEnd": "2026-10-31T23:59:59.999Z",
    "periodOutboundSmsSegments": 600000,
    "monthlyMinimumSmsSegments": 2000000,
    "periodMinimumSmsSegments": 1096774,
    "rampDays": 0,
    "rampEndsAt": "2026-10-15T00:00:00.000Z",
    "inRamp": false,
    "currentRate": 5000
  }
}
```

### GET /billing/wallet/:groupId

Retrieve wallet balance and auto-recharge settings for a group.

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

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | URL Param | Required | Group ID starting with 'G'. |

#### Errors

| Status | Error | When |
| --- | --- | --- |
| 403 | `AuthorizationError` | The caller cannot access this group, including a group ID that does not exist. |
| 404 | `WalletNotFound` | The group has no wallet. |

#### Example Response 200

Response

```json
{
  "_id": "60f7b2a1c9e77c001a2b3c51",
  "groupId": "G1234567",
  "balance": 150000000,
  "reservedAmount": 5000000,
  "currency": "USD",
  "autoRechargeEnabled": true,
  "autoRechargeThreshold": 30000000,
  "autoRechargeToAmount": 100000000,
  "primaryPaymentMethodId": "pm_1234567890",
  "secondaryPaymentMethodId": null,
  "createdAt": "2024-01-15T12:00:00.000Z",
  "updatedAt": "2024-01-15T12:00:00.000Z"
}
```

### PUT /billing/wallet/:groupId

Update wallet auto-recharge settings. Auto recharge may not be available for all account types.

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

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | URL Param | Required | Group ID starting with 'G'. |
| `autoRechargeEnabled` | Boolean | Optional | Enable/Disable auto-recharge. |
| `autoRechargeThreshold` | Number | Optional | Threshold in microdollars (min 30000000 / $30). |
| `autoRechargeToAmount` | Number | Optional | Recharge to amount in microdollars (min 100000000 / $100). |
| `primaryPaymentMethodId` | String | Optional | Stripe/Tilled Payment Method ID. |
| `secondaryPaymentMethodId` | String | Optional | Backup Payment Method ID. |

#### Example Request

Request

```json
{
  "autoRechargeEnabled": true,
  "autoRechargeThreshold": 30000000,
  "autoRechargeToAmount": 100000000
}
```

#### Example Response 200

Response

```json
{
  "_id": "60f7b2a1c9e77c001a2b3c51",
  "groupId": "G1234567",
  "balance": 150000000,
  "reservedAmount": 5000000,
  "currency": "USD",
  "autoRechargeEnabled": true,
  "autoRechargeThreshold": 30000000,
  "autoRechargeToAmount": 100000000,
  "primaryPaymentMethodId": "pm_1234567890",
  "secondaryPaymentMethodId": null,
  "createdAt": "2024-01-15T12:00:00.000Z",
  "updatedAt": "2024-01-15T12:00:00.000Z"
}
```

### POST /billing/wallet/addfunds/:groupId

Manually add funds to a wallet.

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

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `amount` | Number | Required | Amount in microdollars (min $10 = 10000000). Note: the $10 minimum is enforced at the payment processor level; validation alone does not guarantee rejection of smaller amounts. |
| `paymentMethodId` | String | Optional | Optional specific payment method to charge. |

#### Example Request

Request

```json
{
  "amount": 50000000
}
```

#### Example Response 200

Response

```json
[
  {
    "_id": "60f7b2a1c9e77c001a2b3c51",
    "groupId": "G1234567",
    "transactionType": "Recharge Wallet",
    "entryType": "CREDIT",
    "amount": 50000000,
    "quantity": 1,
    "unitPrice": 50000000,
    "referenceId": "pi_3Ofh2kABC123",
    "description": "Added funds to wallet for group G1234567",
    "accountLast4": "4242",
    "status": "succeeded",
    "currency": "USD",
    "createdAt": "2024-01-15T12:00:00.000Z",
    "updatedAt": "2024-01-15T12:00:00.000Z"
  }
]
```

### GET /billing/wallet/transactionHistory

Retrieve detailed transaction history.

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

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | Query Param | Required | Group ID. |
| `subgroupId` | Query Param | Optional | Filter by Subgroup ID. |
| `brandId` | Query Param | Optional | Filter by Brand ID. |
| `campaignId` | Query Param | Optional | Filter by Campaign ID. |
| `entryType` | Query Param | Optional | DEBIT or CREDIT. |
| `transactionType` | Query Param | Optional | Filter by transaction type. Values are human-readable labels set at write time (e.g., 'SMS Outbound 1', 'SMS Outbound (Subscription)', 'MMS Outbound', 'Recharge Wallet', 'Number Purchase', 'Brand Creation'). |
| `category` | Query Param | Optional | Filter by RCS charge category: one value, a comma-separated list or a repeated param. RCS\_RICH\_OUTBOUND, RCS\_RICH\_MEDIA\_OUTBOUND, RCS\_INBOUND, RCS\_ACTION\_CLICK, RCS\_MEDIA\_SURCHARGE, RCS\_FEE\_ONBOARDING, RCS\_FEE\_RENEWAL, RCS\_SESSION\_ADJUSTMENT (the Signal House session fee part of the daily repricing of a conversational agent's interactive sessions), RCS\_SESSION\_CARRIER\_ADJUSTMENT (the carrier session rate part of that repricing, passed through at cost) or RCS\_CARRIER\_PASSTHROUGH, which reads RCS carrier charges alone. Any other value answers 400. The rows do not carry the category. |
| `startDate` | Query Param | Optional | ISO-8601 date or timestamp. Normalized to start-of-UTC-day — the full start day is included. |
| `endDate` | Query Param | Optional | ISO-8601 date or timestamp. Normalized to end-of-UTC-day — the full end day is included. Hourly resolution is not supported. |
| `page` | Query Param | Optional | Page number for pagination (default: 1). |
| `limit` | Query Param | Optional | Results per page, max 1000 (default: 100). |

#### Example Response 200

Response

```json
[
  {
    "_id": "60f7b2a1c9e77c001a2b3c52",
    "groupId": "G1234567",
    "subgroupId": "S1234567",
    "transactionType": "SMS Outbound 1",
    "entryType": "DEBIT",
    "amount": 24000,
    "quantity": 1,
    "unitPrice": 24000,
    "description": "Outbound SMS to 14175551234",
    "currency": "USD",
    "createdAt": "2024-01-15T14:30:00.000Z",
    "updatedAt": "2024-01-15T14:30:00.000Z"
  }
]
```

### GET /billing/wallet/paymentHistory

Retrieve payment history (wallet recharge transactions) with server-side pagination.

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

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | Query Param | Required | Group ID starting with 'G'. |
| `startDate` | Query Param | Required | Start date in YYYY-MM-DD format (inclusive). |
| `endDate` | Query Param | Required | End date in YYYY-MM-DD format (inclusive). |
| `page` | Query Param | Optional | Page number (positive integer, default: 1). |
| `limit` | Query Param | Optional | Results per page, max 10000 (default: 10). |
| `timezone` | Query Param | Optional | IANA timezone (default: "UTC"). |

#### Example Response 200

Response

```json
{
  "data": [
    {
      "_id": "60f7b2a1c9e77c001a2b3c52",
      "groupId": "G1234567",
      "transactionType": "Recharge Wallet",
      "entryType": "CREDIT",
      "amount": 20000000,
      "accountLast4": "4242",
      "status": "succeeded",
      "failureMessage": null,
      "referenceId": "pi_3abc123",
      "description": "Wallet recharge",
      "currency": "USD",
      "quantity": 1,
      "unitPrice": 20000000,
      "createdAt": "2024-01-15T14:30:00.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 10,
    "totalRecords": 25,
    "totalPages": 3,
    "totalAmount": 500000000
  }
}
```

### GET /billing/wallet/paymentMethods/:groupId

Retrieve saved payment methods for a group.

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

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | URL Param | Required | Group ID starting with 'G'. |

#### Example Response 200

Response

```json
{
  "has_more": false,
  "items": [
    {
      "id": "pm_8RtXKnvCelMBgqFDaz9p3",
      "type": "card",
      "chargeable": true,
      "customer_id": "cus_Wp4NrTQbYKHJ7mudhXkzv",
      "billing_details": {
        "name": "Alex Thompson",
        "address": {
          "zip": "90210",
          "city": "Beverly Hills",
          "state": "CA",
          "street": "456 Oak Avenue",
          "country": "US"
        }
      },
      "card": {
        "brand": "visa",
        "last4": "4242",
        "checks": {
          "cvc_check": "unchecked",
          "address_line1_check": "pass",
          "address_postal_code_check": "pass"
        },
        "funding": "credit",
        "exp_year": 2028,
        "exp_month": 7,
        "holder_name": "Alex Thompson",
        "surchargeable": false,
        "apple_pay": false
      },
      "created_at": "2024-03-10T09:15:30.000Z",
      "updated_at": "2024-03-10T09:15:30.000Z"
    }
  ],
  "offset": 0,
  "limit": 30,
  "total": 1
}
```

### POST /billing/wallet/paymentMethod/:groupId

Attach a new payment method to a group's wallet.

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

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | URL Param | Required | Group ID starting with 'G'. |
| `paymentMethodId` | String | Required | The payment method ID from your payment provider. |

#### Example Request

Request

```json
{
  "paymentMethodId": "pm_1234567890"
}
```

#### Example Response 200

Response

```json
{
  "Message": "Payment method pm_1234567890 successfully attached to customer for group G1234567"
}
```

### DELETE /billing/wallet/paymentMethod/:groupId/:paymentMethodId

Detach a payment method from a group's wallet.

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

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | URL Param | Required | Group ID starting with 'G'. |
| `paymentMethodId` | URL Param | Required | The payment method ID to detach. |

#### Example Response 200

Response

```json
{
  "Message": "Payment method pm_1234567890 successfully detached from customer for group G1234567"
}
```

### GET /billing/invoiceDetails

Retrieve invoice details for a group.

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

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | Query Param | Required | Group ID starting with 'G'. |
| `subgroupId` | Query Param | Optional | Filter by Subgroup ID. |
| `startDate` | Query Param | Optional | ISO-8601 date or timestamp. Normalized to start-of-UTC-day — the full start day is included. |
| `endDate` | Query Param | Optional | ISO-8601 date or timestamp. Normalized to end-of-UTC-day — the full end day is included. Hourly resolution is not supported. |

#### Example Response 200

Response

```json
[
  {
    "_id": "G12345678::S1234567::2026-03-10",
    "groupId": "G12345678",
    "subgroupId": "S1234567",
    "dataDate": "2026-03-10",
    "transactionSummary": {
      "SMS Outbound 1": {
        "quantity": 150,
        "amount": 3600000
      },
      "MMS Outbound": {
        "quantity": 25,
        "amount": 800000
      }
    }
  }
]
```

### GET /billing/invoiceDetails/ledger

Retrieve a summarized ledger of billing transactions for a group, grouped by subgroup, entry type, transaction type, and unit price. All monetary values are in microdollars.

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

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | Query Param | Required | Group ID starting with 'G'. |
| `startDate` | Query Param | Required | Start date in YYYY-MM-DD format (inclusive). |
| `endDate` | Query Param | Required | End date in YYYY-MM-DD format (inclusive). Must be >= startDate. |
| `subgroupId` | Query Param | Optional | Filter by Subgroup ID. |
| `timezone` | Query Param | Optional | IANA timezone for date boundaries (default: UTC). |

#### Example Response 200

Response

```json
[
  {
    "subgroupId": "S1234567",
    "entryType": "DEBIT",
    "transactionType": "SMS Outbound 1",
    "unitPrice": 24000,
    "quantity": 150,
    "amount": 3600000
  },
  {
    "subgroupId": null,
    "entryType": "CREDIT",
    "transactionType": "Recharge Wallet",
    "unitPrice": 50000000,
    "quantity": 1,
    "amount": 50000000
  }
]
```
