Skip to content
myela

Send a total, or the lines that make one. With items the invoice totals itself — quantity × unitAmount, plus amountTax, less amountDiscount — and amount becomes optional; send it anyway and it is checked against that sum rather than trusted. amountTax and amountDiscount adjust that line total, so they require items. Lines come back in the order you sent them. For the due date, send either dueAt or paymentTerms (due_on_receipt, net_7, net_15, net_30, net_60) — not both. Terms are a derivation: the due date is computed when the invoice is ISSUED, counting calendar days from that moment, so a draft written today and sent next week is due relative to next week. The example below sends dueAt because the two are alternatives and a request cannot demonstrate both. Set an Idempotency-Key header derived from the operation (not random per run) so a job that runs twice gets the original invoice back instead of a second one. Amounts are integers in the minor unit — 4999 is $49.99. A decimal is rejected rather than silently charged as a different figure.

Create invoice

POST/v1/invoicesLink

Send a total, or the lines that make one. With items the invoice totals itself — quantity × unitAmount, plus amountTax, less amountDiscount — and amount becomes optional; send it anyway and it is checked against that sum rather than trusted. amountTax and amountDiscount adjust that line total, so they require items. Lines come back in the order you sent them.

For the due date, send either dueAt or paymentTerms (due_on_receipt, net_7, net_15, net_30, net_60) — not both. Terms are a derivation: the due date is computed when the invoice is ISSUED, counting calendar days from that moment, so a draft written today and sent next week is due relative to next week. The example below sends dueAt because the two are alternatives and a request cannot demonstrate both.

Set an Idempotency-Key header derived from the operation (not random per run) so a job that runs twice gets the original invoice back instead of a second one. Amounts are integers in the minor unit — 4999 is $49.99. A decimal is rejected rather than silently charged as a different figure.

SandboxSecret keyinvoices.create

Request fields

Edit a field and the generated request updates immediately.

Request body
stringrequired

The customer that owns or receives this resource.

stringrequired

A three-letter ISO 4217 currency code.

ISO 4217

integerrequired

A non-negative integer in the currency’s minor unit. 4999 represents $49.99.

integer · minor units

Optional fields5
stringoptional

A merchant-visible description of the resource.

arrayoptional

The lines being billed. Each carries a description, a quantity, and a unitAmount in minor units; the invoice totals itself from them, so amount becomes optional.

integeroptional

Tax added to the line total. Adjusts the lines, so it requires items.

integer · minor units

integeroptional

Discount subtracted from the line total. Adjusts the lines, so it requires items, and may not exceed what is being discounted.

integer · minor units

stringoptional

An ISO 8601 timestamp for when the invoice is due.

ISO 8601 timestamp

Response contract

The successful wire shape and errors an integration should branch on.

201

Invoice

application/json
idstringrequired
Unique invoice identifier.
object"invoice"required
Stable resource discriminator.
statusstringrequired
Current invoice state.
invoiceNumberstringrequired
Your invoice's own number: a per-account sequence behind a prefix you choose. Unique within your account, and yours to quote to a customer — it is not the processor's reference, nor the number on the payment that settles it.
customerIdstring
Customer receiving the invoice.
amountintegerrequired
Invoice total in minor units. On an itemized invoice this is the computed sum — lines, plus tax, less discount — not a figure set independently of them.
amountPaidintegerrequired
Amount paid in minor units: `amount` once paid, 0 while open. On a partly paid invoice (`overdue`, or `void` after it), what the first partial payment still holds, net of refunds; check `/attempts` for any later one. Read paid from `status`, not this figure.
currencystringrequired
Three-letter currency code.
descriptionstring
Free-text memo, the same field the create call takes as description. Absent when the invoice carries none.
itemsarray
The billed lines, in the order they were sent, with amounts in minor units. Absent on an invoice created from a total alone — an amount-only invoice has no lines to report, and none are invented for it.
amountTaxinteger
Tax added to the line total, in minor units. Absent when the invoice carried none, which is not the same as zero.
amountDiscountinteger
Discount subtracted from the line total, in minor units. Absent when the invoice carried none.
billToobject
Who the invoice was addressed to, copied from the customer's default billing address when the invoice was issued. A snapshot, not a live link — a customer who moves house does not rewrite invoices already sent. Absent on a draft, which has not been issued.
paymentTermsstring
How dueAt was arrived at: due_on_receipt, net_7, net_15, net_30, net_60, or custom when the date was named directly. Absent on invoices issued before terms existed.
issuedAtstring
When the invoice was issued, which is not when it was created — a draft written on Monday and sent on Friday is issued Friday. Terms count from here. Absent while it is still a draft.
urlstring
Where the customer pays this invoice, on a Myela-hosted page. Present once the invoice has been sent from the portal or by an auto-send recurring invoice; one only created and scheduled through /v1 has none.
pdfUrlstringrequired
The invoice as a PDF, fronted by your business name. Fetch it with the same API key; it is not a public link.
dueAtstring
ISO 8601 due timestamp.
collectionobject
Scheduled collection details, when configured.
createdAtstringrequired
ISO 8601 creation timestamp.
pendingConfirmationobject
Present only while a charge on this invoice is unresolved. Automatic collection is suspended and the named payment must be reconciled before it resumes. Voiding is refused (409, `details.code` `PAYMENT_PENDING_CONFIRMATION`) until it clears, and still afterwards if the named payment resolved as authorized but never captured.
Example response
{
  "id": "inv_01JEXAMPLE",
  "object": "invoice",
  "status": "open",
  "invoiceNumber": "INV-000123",
  "customerId": "cus_01JEXAMPLE",
  "amount": 147375,
  "amountPaid": 0,
  "currency": "USD",
  "description": "Consulting, August",
  "items": [
    {
      "description": "Consulting, August",
      "quantity": 20,
      "unitAmount": 7500,
      "amount": 150000
    }
  ],
  "amountTax": 12375,
  "amountDiscount": 15000,
  "billTo": {
    "name": "Augusta King",
    "company": "Analytical Engines Ltd",
    "line1": "12 St James Square",
    "city": "London",
    "postalCode": "SW1Y 4LE",
    "country": "GB"
  },
  "paymentTerms": "net_30",
  "issuedAt": "2026-08-19T10:00:00.000Z",
  "url": "https://example.com/pay/8Kd2mQ",
  "pdfUrl": "https://payments-api-sandbox.merchantservicedepot.com/v1/invoices/inv_01JEXAMPLE/pdf",
  "dueAt": "2026-09-01T00:00:00.000Z",
  "collection": {
    "collectAt": "2026-09-01T09:00:00.000Z",
    "attemptCount": 0
  },
  "createdAt": "2026-08-10T20:49:51.653Z",
  "pendingConfirmation": {
    "paymentId": "pay_01JEXAMPLE",
    "since": "2026-09-14T18:04:11.000Z"
  }
}
Error responses
401authentication_failed

The key is missing, malformed, revoked, or invalid for this environment.

403permission_denied

The key does not have invoices.create.

422invalid_request

One or more request fields are invalid.