> Index of every page: https://docs.merchantservicedepot.com/llms.txt

# Create recurring invoice


`POST /v1/recurring_invoices`

`startDate` and `endDate` are calendar dates (`YYYY-MM-DD`), not timestamps, and they mean dates in YOUR timezone — set it in the portal under Settings → Invoicing, because "the 1st of the month" is a claim about your calendar and not about UTC.

A `dayOfMonth` of 29, 30 or 31 is honoured as asked: a schedule set to the 31st bills the 28th in February and returns to the 31st in March, rather than quietly becoming a 28th-of-the-month schedule. Use `lastDayOfMonth: true` when the last day is what you actually mean.

`mode` defaults to `auto_send` — each cycle issues the invoice. `draft_for_review` leaves a draft for you to edit and send instead, which is what you want when the amount needs a human look. Amounts are integers in the minor unit — 4999 is $49.99. A decimal is rejected rather than silently charged as a different figure.

Auth: a secret key with the `recurringInvoices.create` permission. Returns `201` with Recurring invoice.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `customerId` | body | string | Yes | The customer that owns or receives this resource. |
| `name` | body | string | Yes | A human-readable name. |
| `cadence` | body | string | Yes | The cadence value. |
| `startDate` | body | string | Yes | The start date value. |
| `template` | body | string | Yes | The template value. |

## Request

**curl**

```curl
curl -X POST "https://payments-api-sandbox.merchantservicedepot.com/v1/recurring_invoices" \
  -H "Authorization: Bearer $MYELA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "customerId": "{{CUSTOMER_ID}}",
  "name": "Monthly retainer",
  "cadence": {
    "unit": "monthly",
    "interval": 1,
    "dayOfMonth": 1
  },
  "startDate": "2026-09-01",
  "template": {
    "currency": "USD",
    "paymentTerms": "net_30",
    "items": [
      {
        "description": "Retainer",
        "quantity": 1,
        "unitAmount": 120000
      }
    ]
  }
}'
```

**Node**

```node
const res = await fetch("https://payments-api-sandbox.merchantservicedepot.com/v1/recurring_invoices", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MYELA_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "customerId": "{{CUSTOMER_ID}}",
    "name": "Monthly retainer",
    "cadence": {
      "unit": "monthly",
      "interval": 1,
      "dayOfMonth": 1
    },
    "startDate": "2026-09-01",
    "template": {
      "currency": "USD",
      "paymentTerms": "net_30",
      "items": [
        {
          "description": "Retainer",
          "quantity": 1,
          "unitAmount": 120000
        }
      ]
    }
  }),
});

if (!res.ok) {
  const { error } = await res.json();
  // Branch on error.code — never on error.message.
  throw new Error(error.code);
}
const data = await res.json();
```

**Python**

```python
import os
import requests

res = requests.post(
    "https://payments-api-sandbox.merchantservicedepot.com/v1/recurring_invoices",
    headers={
        "Authorization": f"Bearer {os.environ['MYELA_API_KEY']}",
    },
    json={
        "customerId": "{{CUSTOMER_ID}}",
        "name": "Monthly retainer",
        "cadence": {
            "unit": "monthly",
            "interval": 1,
            "dayOfMonth": 1
        },
        "startDate": "2026-09-01",
        "template": {
            "currency": "USD",
            "paymentTerms": "net_30",
            "items": [
                {
                    "description": "Retainer",
                    "quantity": 1,
                    "unitAmount": 120000
                }
            ]
        }
    },
)

if not res.ok:
    # Branch on error["code"] — never on error["message"].
    raise RuntimeError(res.json()["error"]["code"])
data = res.json()
```

## Response

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Unique recurring invoice identifier. |
| `object` | "recurring_invoice" | Stable resource discriminator. |
| `customerId` | string | The customer every generated invoice bills. |
| `name` | string | Your label for the schedule. Not shown to the customer. |
| `status` | string | One of active, paused, completed, cancelled or failed. You set paused and cancelled; completed and failed are set for you — completed when it runs out of occurrences or passes its end date, failed when it parks itself after repeated errors. |
| `mode` | string | auto_send issues each invoice as it is generated. draft_for_review leaves a draft for you to edit and send, which is what you want when the amount needs a human look before it goes out. |
| `cadence` | object | unit (weekly or monthly) and interval, plus weekday for weekly, or dayOfMonth or lastDayOfMonth for monthly. dayOfMonth is reported as you asked for it, never as clamped: a schedule set to the 31st reports 31 in every month, and bills the 28th in February. |
| `startDate` | string | First date the schedule may produce an invoice, as a calendar date (YYYY-MM-DD) in your timezone — not a timestamp. |
| `endDate` | string | Optional last date, inclusive. Absent means it runs until you stop it. |
| `nextInvoiceDate` | string | The next date this produces an invoice, in your timezone. Absent once the schedule is cancelled or has run its course. |
| `maxOccurrences` | integer | Optional cap on how many invoices this will ever produce. |
| `occurrenceCount` | integer | How many invoices it has produced so far. |
| `template` | object | What each generated invoice is built from: amount and currency, optional amountTax, amountDiscount, description, paymentTerms, items, plus autoCharge and paymentMethodId. Amounts are minor units. Editing it changes the next cycle only. |
| `lastFailureCode` | string | Why the last cycle produced nothing, as a code. Present only after a failure; cleared once a cycle succeeds. |
| `recurringInvoiceId` | string | The recurring invoice that produced this one. Absent on a one-off invoice. |
| `billingPeriod` | string | Which cycle this invoice satisfies, as the period's start date in your timezone. Two invoices in one month carry two different values, which is how you tell them apart. |
| `createdAt` | string | ISO 8601 creation timestamp. |

```json
{
  "id": "sch_01JEXAMPLE",
  "object": "recurring_invoice",
  "customerId": "cus_01JEXAMPLE",
  "name": "Monthly retainer",
  "status": "active",
  "mode": "auto_send",
  "cadence": {
    "unit": "monthly",
    "interval": 1,
    "dayOfMonth": 1
  },
  "startDate": "2026-09-01",
  "endDate": "2027-09-01",
  "nextInvoiceDate": "2026-10-01",
  "maxOccurrences": 12,
  "occurrenceCount": 3,
  "template": {
    "amount": 120000,
    "currency": "USD",
    "paymentTerms": "net_30",
    "autoCharge": false
  },
  "lastFailureCode": "RECURRING_INVOICE_CARD_NOT_FOR_CUSTOMER",
  "recurringInvoiceId": "sch_01JEXAMPLE",
  "billingPeriod": "2026-09-01",
  "createdAt": "2026-08-19T12:00:00.000Z"
}
```

Source: https://docs.merchantservicedepot.com/api-reference/create-recurring-invoice/
