Billing Platform docs Admin →

Billing Platform API

Version 2026-01-01 · Base URL https://pay.marthaia.com/v1 · OpenAPI document

REST API of the billing platform. Authenticate with `Authorization: Bearer sk_test_…` (the key selects the environment). Amounts are integer minor units with an ISO 4217 currency. Send an `Idempotency-Key` on every POST.

New here? Start with the getting started tutorial. Every operation below lists the key scope it needs and shows a curl command and the matching JavaScript SDK call.

Customers

POST /customers scope customers:write · SDK billing.customers.create()

Create a customer

Body · CustomerInput

billing_addressAddress
countrystringISO alpha-2.
currencystringISO 4217.
emailstring
external_idstringYour user id.
localestring
metadatamapUp to 50 string key/value pairs for your own use.
namestring
phonestring

Returns

Customer

curl https://pay.marthaia.com/v1/customers \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
GET /customers scope customers:read · SDK billing.customers.list()

List customers

Parameters

external_idstring · queryFilter by your user id.
emailstring · queryFilter by email.
limitinteger · query1–100, default 20.
starting_afterstring · queryCursor: id of the last item of the previous page.
ending_beforestring · queryCursor: id of the first item of the next page.

Returns

A list of Customer objects (data, has_more).

curl https://pay.marthaia.com/v1/customers \
  -H "Authorization: Bearer $BILLING_KEY"
GET /customers/{id} scope customers:read · SDK billing.customers.retrieve()

Retrieve a customer

Parameters

id requiredstring · pathObject id.

Returns

Customer

curl https://pay.marthaia.com/v1/customers/cus_01a15d… \
  -H "Authorization: Bearer $BILLING_KEY"
PATCH /customers/{id} scope customers:write · SDK billing.customers.update()

Update a customer

Parameters

id requiredstring · pathObject id.

Body · CustomerInput

billing_addressAddress
countrystringISO alpha-2.
currencystringISO 4217.
emailstring
external_idstringYour user id.
localestring
metadatamapUp to 50 string key/value pairs for your own use.
namestring
phonestring

Returns

Customer

curl https://pay.marthaia.com/v1/customers/cus_01a15d… \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X PATCH \
  -H "Content-Type: application/json" \
  -d '{}'
DELETE /customers/{id} scope customers:write · SDK billing.customers.del()

Anonymise a customer

Erases personal data; invoices and payments are kept.

Parameters

id requiredstring · pathObject id.

Returns

Customer

curl https://pay.marthaia.com/v1/customers/cus_01a15d… \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X DELETE
GET /customers/{id}/entitlements scope customers:read · SDK billing.customers.entitlements()

List a customer’s entitlements

The single place access is decided, from subscription status and the grace policy.

Parameters

id requiredstring · pathObject id.

Returns

A list of Entitlement objects (data, has_more).

curl https://pay.marthaia.com/v1/customers/cus_01a15d…/entitlements \
  -H "Authorization: Bearer $BILLING_KEY"
GET /customers/{id}/payment_methods scope payment_methods:read · SDK billing.customers.paymentMethods()

List a customer’s saved payment methods

Parameters

id requiredstring · pathObject id.

Returns

A list of PaymentMethod objects (data, has_more).

curl https://pay.marthaia.com/v1/customers/cus_01a15d…/payment_methods \
  -H "Authorization: Bearer $BILLING_KEY"

Products

POST /products scope products:write · SDK billing.products.create()

Create a product

Body · ProductInput

activeboolean
descriptionstring
featuresmap
group_keystring
metadatamapUp to 50 string key/value pairs for your own use.
namestring

Returns

Product

curl https://pay.marthaia.com/v1/products \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
GET /products scope products:read · SDK billing.products.list()

List products

Parameters

activeboolean · queryFilter on active.
limitinteger · query1–100, default 20.
starting_afterstring · queryCursor: id of the last item of the previous page.
ending_beforestring · queryCursor: id of the first item of the next page.

Returns

A list of Product objects (data, has_more).

curl https://pay.marthaia.com/v1/products \
  -H "Authorization: Bearer $BILLING_KEY"
GET /products/{id} scope products:read · SDK billing.products.retrieve()

Retrieve a product

Parameters

id requiredstring · pathObject id.

Returns

Product

curl https://pay.marthaia.com/v1/products/prod_01a15d… \
  -H "Authorization: Bearer $BILLING_KEY"
PATCH /products/{id} scope products:write · SDK billing.products.update()

Update a product

Parameters

id requiredstring · pathObject id.

Body · ProductInput

activeboolean
descriptionstring
featuresmap
group_keystring
metadatamapUp to 50 string key/value pairs for your own use.
namestring

Returns

Product

curl https://pay.marthaia.com/v1/products/prod_01a15d… \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X PATCH \
  -H "Content-Type: application/json" \
  -d '{}'

Prices

POST /prices scope products:write · SDK billing.prices.create()

Create a price

Give an amount for every currency you sell in: there is no exchange-rate conversion.

Body · PriceInput

amounts requiredmapMinor units per currency, e.g. {"XAF": 5000, "USD": 900}.
product requiredstringprod_…
type requiredstring One of: one_time, recurring.
external_checkout_urlstring
intervalstringRecurring only. One of: day, week, month, year.
interval_countintegerRecurring only, default 1.
lookup_keystring
metadatamapUp to 50 string key/value pairs for your own use.
nicknamestring
tax_behaviorstring One of: project, inclusive, exclusive.

Returns

Price

curl https://pay.marthaia.com/v1/prices \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"amounts": {}, "product": "prod_01a15d…", "type": "one_time"}'
GET /prices scope products:read · SDK billing.prices.list()

List prices

Parameters

productstring · queryFilter by prod_….
activeboolean · queryFilter on active.
limitinteger · query1–100, default 20.
starting_afterstring · queryCursor: id of the last item of the previous page.
ending_beforestring · queryCursor: id of the first item of the next page.

Returns

A list of Price objects (data, has_more).

curl https://pay.marthaia.com/v1/prices \
  -H "Authorization: Bearer $BILLING_KEY"
GET /prices/{id} scope products:read · SDK billing.prices.retrieve()

Retrieve a price

Parameters

id requiredstring · pathObject id.

Returns

Price

curl https://pay.marthaia.com/v1/prices/price_01a15d… \
  -H "Authorization: Bearer $BILLING_KEY"
PATCH /prices/{id} scope products:write · SDK billing.prices.update()

Update a price

Parameters

id requiredstring · pathObject id.

Body · PriceUpdate

activeboolean
amountsmapOnly before the price is used.
lookup_keystring
metadatamapUp to 50 string key/value pairs for your own use.
nicknamestring

Returns

Price

curl https://pay.marthaia.com/v1/prices/price_01a15d… \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X PATCH \
  -H "Content-Type: application/json" \
  -d '{}'

Checkout sessions

POST /checkout/sessions scope checkout:write · SDK billing.checkoutSessions.create()

Create a checkout session

Returns the hosted checkout url to redirect the customer to. Send an Idempotency-Key.

Body · CheckoutSessionInput

mode requiredstringpayment = one-off, subscription = recurring prices, setup = save a method without charging. One of: payment, subscription, setup.
success_url requiredstringAbsolute URL; {SESSION_ID} is replaced.
allowed_methodsstring[]Restrict the offer: kinds ("mobile_money"), connections (gwc_…) or one method (gwc_…:card). Pinned connections skip their own country rule.
cancel_urlstring
client_reference_idstring
currencystringDefaults to the customer’s, then the project’s.
customerCheckoutCustomer
customer_idstringAlternative to customer: an existing cus_….
expires_inintegerSeconds, default from settings (24 h).
itemsLineItem[]Required unless mode is setup.
localestringfr or en.
metadatamapUp to 50 string key/value pairs for your own use.

Returns

CheckoutSession

curl https://pay.marthaia.com/v1/checkout/sessions \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"mode": "payment", "success_url": "https://app.example.com/billing"}'
GET /checkout/sessions scope checkout:read · SDK billing.checkoutSessions.list()

List checkout sessions

Parameters

statusstring · queryopen, complete or expired.
limitinteger · query1–100, default 20.
starting_afterstring · queryCursor: id of the last item of the previous page.
ending_beforestring · queryCursor: id of the first item of the next page.

Returns

A list of CheckoutSession objects (data, has_more).

curl https://pay.marthaia.com/v1/checkout/sessions \
  -H "Authorization: Bearer $BILLING_KEY"
GET /checkout/sessions/{id} scope checkout:read · SDK billing.checkoutSessions.retrieve()

Retrieve a checkout session

Call this on return instead of trusting the redirect.

Parameters

id requiredstring · pathObject id.

Returns

CheckoutSession

curl https://pay.marthaia.com/v1/checkout/sessions/cs_01a15d… \
  -H "Authorization: Bearer $BILLING_KEY"
POST /checkout/sessions/{id}/expire scope checkout:write · SDK billing.checkoutSessions.expire()

Expire a checkout session

Parameters

id requiredstring · pathObject id.

Returns

CheckoutSession

curl https://pay.marthaia.com/v1/checkout/sessions/cs_01a15d…/expire \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)"

Subscriptions

POST /subscriptions scope subscriptions:write · SDK billing.subscriptions.create()

Create a subscription

For customers with a saved method; most integrations use a subscription checkout instead.

Body · SubscriptionInput

customer requiredstringcus_…
items requiredLineItem[]
collection_methodstring One of: automatic, send_invoice.
currencystring
gateway_connectionstringgwc_…
mark_paid_reasonstringOperator-assigned plan: first invoice settled manually with this reason.
metadatamapUp to 50 string key/value pairs for your own use.
payment_methodstringpm_…

Returns

Subscription

curl https://pay.marthaia.com/v1/subscriptions \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"customer": "cus_01a15d…", "items": []}'
GET /subscriptions scope subscriptions:read · SDK billing.subscriptions.list()

List subscriptions

Parameters

customerstring · queryFilter by cus_….
statusstring · queryFilter by status.
collection_modestring · queryprovider_managed or platform_managed.
limitinteger · query1–100, default 20.
starting_afterstring · queryCursor: id of the last item of the previous page.
ending_beforestring · queryCursor: id of the first item of the next page.

Returns

A list of Subscription objects (data, has_more).

curl https://pay.marthaia.com/v1/subscriptions \
  -H "Authorization: Bearer $BILLING_KEY"
GET /subscriptions/{id} scope subscriptions:read · SDK billing.subscriptions.retrieve()

Retrieve a subscription

Parameters

id requiredstring · pathObject id.

Returns

Subscription

curl https://pay.marthaia.com/v1/subscriptions/sub_01a15d… \
  -H "Authorization: Bearer $BILLING_KEY"
POST /subscriptions/{id}/change_plan scope subscriptions:write · SDK billing.subscriptions.changePlan()

Change plan

Platform-managed: creates an invoice for the new price, switched on payment. Provider-managed: gateway proration.

Parameters

id requiredstring · pathObject id.

Body · ChangePlanInput

items requiredLineItem[]
proration_behaviorstringProvider-managed only. One of: create_prorations, none, always_invoice.

Returns

Subscription

curl https://pay.marthaia.com/v1/subscriptions/sub_01a15d…/change_plan \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"items": []}'
POST /subscriptions/{id}/cancel scope subscriptions:write · SDK billing.subscriptions.cancel()

Cancel a subscription

Parameters

id requiredstring · pathObject id.

Body · CancelInput

at_period_endbooleanKeep access until the period ends.
reasonstring

Returns

Subscription

curl https://pay.marthaia.com/v1/subscriptions/sub_01a15d…/cancel \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
POST /subscriptions/{id}/resume scope subscriptions:write · SDK billing.subscriptions.resume()

Remove a scheduled cancellation

Parameters

id requiredstring · pathObject id.

Returns

Subscription

curl https://pay.marthaia.com/v1/subscriptions/sub_01a15d…/resume \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)"
POST /subscriptions/{id}/pause scope subscriptions:write · SDK billing.subscriptions.pause()

Pause collection

Parameters

id requiredstring · pathObject id.

Returns

Subscription

curl https://pay.marthaia.com/v1/subscriptions/sub_01a15d…/pause \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)"
POST /subscriptions/{id}/unpause scope subscriptions:write · SDK billing.subscriptions.unpause()

Resume collection

Parameters

id requiredstring · pathObject id.

Returns

Subscription

curl https://pay.marthaia.com/v1/subscriptions/sub_01a15d…/unpause \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)"
POST /subscriptions/{id}/payment_method scope subscriptions:write · SDK billing.subscriptions.setPaymentMethod()

Change the payment method

Retries the open invoice immediately when past due.

Parameters

id requiredstring · pathObject id.

Body · PaymentMethodRef

payment_methodstringpm_…; default method when omitted.

Returns

Subscription

curl https://pay.marthaia.com/v1/subscriptions/sub_01a15d…/payment_method \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'

Invoices

GET /invoices scope invoices:read · SDK billing.invoices.list()

List invoices

Parameters

customerstring · queryFilter by cus_….
subscriptionstring · queryFilter by sub_….
statusstring · queryFilter by status.
limitinteger · query1–100, default 20.
starting_afterstring · queryCursor: id of the last item of the previous page.
ending_beforestring · queryCursor: id of the first item of the next page.

Returns

A list of Invoice objects (data, has_more).

curl https://pay.marthaia.com/v1/invoices \
  -H "Authorization: Bearer $BILLING_KEY"
POST /invoices scope invoices:write · SDK billing.invoices.create()

Create a manual invoice

Body · InvoiceInput

customer requiredstringcus_…
items requiredobject[]
auto_finalizeboolean
collection_methodstring One of: automatic, send_invoice.
currencystring
days_until_dueinteger
descriptionstring
metadatamapUp to 50 string key/value pairs for your own use.

Returns

Invoice

curl https://pay.marthaia.com/v1/invoices \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"customer": "cus_01a15d…", "items": []}'
GET /invoices/{id} scope invoices:read · SDK billing.invoices.retrieve()

Retrieve an invoice

Parameters

id requiredstring · pathObject id.

Returns

Invoice

curl https://pay.marthaia.com/v1/invoices/inv_01a15d… \
  -H "Authorization: Bearer $BILLING_KEY"
GET /invoices/{id}/pdf scope invoices:read · SDK billing.invoices.pdf()

Download the invoice PDF

Parameters

id requiredstring · pathObject id.

Returns

The PDF file.

curl https://pay.marthaia.com/v1/invoices/inv_01a15d…/pdf \
  -H "Authorization: Bearer $BILLING_KEY"
POST /invoices/{id}/finalize scope invoices:write · SDK billing.invoices.finalize()

Finalise a draft invoice

Parameters

id requiredstring · pathObject id.

Returns

Invoice

curl https://pay.marthaia.com/v1/invoices/inv_01a15d…/finalize \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)"
POST /invoices/{id}/pay scope invoices:write · SDK billing.invoices.pay()

Charge an open invoice

Parameters

id requiredstring · pathObject id.

Body · PaymentMethodRef

payment_methodstringpm_…; default method when omitted.

Returns

Payment

curl https://pay.marthaia.com/v1/invoices/inv_01a15d…/pay \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
POST /invoices/{id}/void scope invoices:write · SDK billing.invoices.void()

Void an invoice

Parameters

id requiredstring · pathObject id.

Returns

Invoice

curl https://pay.marthaia.com/v1/invoices/inv_01a15d…/void \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)"
POST /invoices/{id}/mark_uncollectible scope invoices:write · SDK billing.invoices.markUncollectible()

Mark uncollectible

Parameters

id requiredstring · pathObject id.

Returns

Invoice

curl https://pay.marthaia.com/v1/invoices/inv_01a15d…/mark_uncollectible \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)"

Payments

GET /payments scope payments:read · SDK billing.payments.list()

List payments

Parameters

invoicestring · queryFilter by inv_….
customerstring · queryFilter by cus_….
statusstring · queryFilter by status.
limitinteger · query1–100, default 20.
starting_afterstring · queryCursor: id of the last item of the previous page.
ending_beforestring · queryCursor: id of the first item of the next page.

Returns

A list of Payment objects (data, has_more).

curl https://pay.marthaia.com/v1/payments \
  -H "Authorization: Bearer $BILLING_KEY"
GET /payments/{id} scope payments:read · SDK billing.payments.retrieve()

Retrieve a payment

Includes next_action for headless integrations.

Parameters

id requiredstring · pathObject id.

Returns

Payment

curl https://pay.marthaia.com/v1/payments/pay_01a15d… \
  -H "Authorization: Bearer $BILLING_KEY"
POST /payments/{id}/refunds scope payments:write · SDK billing.payments.refund()

Refund a payment

Parameters

id requiredstring · pathObject id.

Body · RefundInput

amountintegerMinor units; default the remaining refundable amount.
manualbooleanRecord a refund made outside the gateway.
reasonstring

Returns

Refund

curl https://pay.marthaia.com/v1/payments/pay_01a15d…/refunds \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
POST /payments/{id}/authorize_otp scope payments:write · SDK billing.payments.authorizeOtp()

Submit a mobile money OTP

Parameters

id requiredstring · pathObject id.

Body · OTPInput

code requiredstringCode typed by the customer; never stored.

Returns

Payment

curl https://pay.marthaia.com/v1/payments/pay_01a15d…/authorize_otp \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"code": "123456"}'
POST /payments/{id}/resend scope payments:write · SDK billing.payments.resend()

Send a new phone prompt

Creates a new attempt on the same invoice and cancels this one.

Parameters

id requiredstring · pathObject id.

Body · ResendInput

operatorstringNew operator code.
phonestringNew number.

Returns

Payment

curl https://pay.marthaia.com/v1/payments/pay_01a15d…/resend \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
POST /payments/{id}/confirm scope payments:write · SDK billing.payments.confirm()

Confirm or reject manually

Secret keys only; audited.

Parameters

id requiredstring · pathObject id.

Body · ConfirmInput

reason requiredstring
confirmbooleanfalse to reject; default true.

Returns

Payment

curl https://pay.marthaia.com/v1/payments/pay_01a15d…/confirm \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"reason": "…"}'
POST /payments/{id}/poll scope payments:write · SDK billing.payments.poll()

Ask the gateway for the current status

Parameters

id requiredstring · pathObject id.

Returns

Payment

curl https://pay.marthaia.com/v1/payments/pay_01a15d…/poll \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)"

Refunds

GET /refunds/{id} scope payments:read · SDK billing.refunds.retrieve()

Retrieve a refund

Parameters

id requiredstring · pathObject id.

Returns

Refund

curl https://pay.marthaia.com/v1/refunds/re_01a15d… \
  -H "Authorization: Bearer $BILLING_KEY"

Payment methods

GET /payment_methods/{id} scope payment_methods:read · SDK billing.paymentMethods.retrieve()

Retrieve a payment method

Parameters

id requiredstring · pathObject id.

Returns

PaymentMethod

curl https://pay.marthaia.com/v1/payment_methods/pm_01a15d… \
  -H "Authorization: Bearer $BILLING_KEY"
POST /payment_methods/{id}/set_default scope payment_methods:write · SDK billing.paymentMethods.setDefault()

Make it the customer’s default

Parameters

id requiredstring · pathObject id.

Returns

PaymentMethod

curl https://pay.marthaia.com/v1/payment_methods/pm_01a15d…/set_default \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)"
DELETE /payment_methods/{id} scope payment_methods:write · SDK billing.paymentMethods.detach()

Detach a payment method

Parameters

id requiredstring · pathObject id.

Returns

PaymentMethod

curl https://pay.marthaia.com/v1/payment_methods/pm_01a15d… \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X DELETE

Portal

POST /portal/sessions scope portal:write · SDK billing.portalSessions.create()

Create a customer portal link

Valid 30 minutes by default.

Body · PortalSessionInput

customer requiredstringcus_…
allowed_actionsstring[]
allowed_pricesstring[]Plans offered in “change plan”.
localestring
return_urlstring

Returns

SessionLink

curl https://pay.marthaia.com/v1/portal/sessions \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"customer": "cus_01a15d…"}'

Pricing page

POST /pricing_sessions scope checkout:write · SDK billing.pricingSessions.create()

Create a pricing page link

Shows the plan list to a known customer, marks their current plan and skips the email step.

Body · PricingSessionInput

customer requiredobjectFields: external_id, country, email, locale, name.
cancel_urlstring
currencystringPreselected currency.
expires_inintegerSeconds, default 86400, max 7 days.
group_keystringOnly plans of this group.
localestring
success_urlstring

Returns

SessionLink

curl https://pay.marthaia.com/v1/pricing_sessions \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"customer": {}}'

Webhook endpoints

POST /webhook_endpoints scope webhooks:write · SDK billing.webhookEndpoints.create()

Create a webhook endpoint

The response carries the signing secret, once.

Body · WebhookEndpointInput

descriptionstring
enabledbooleanUpdate only.
enabled_eventsstring[]Event types, wildcards allowed (subscription.*). Default [*].
urlstringHTTPS URL.

Returns

WebhookEndpoint

curl https://pay.marthaia.com/v1/webhook_endpoints \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
GET /webhook_endpoints scope webhooks:read · SDK billing.webhookEndpoints.list()

List webhook endpoints

Returns

A list of WebhookEndpoint objects (data, has_more).

curl https://pay.marthaia.com/v1/webhook_endpoints \
  -H "Authorization: Bearer $BILLING_KEY"
GET /webhook_endpoints/{id} scope webhooks:read · SDK billing.webhookEndpoints.retrieve()

Retrieve a webhook endpoint

Parameters

id requiredstring · pathObject id.

Returns

WebhookEndpoint

curl https://pay.marthaia.com/v1/webhook_endpoints/we_01a15d… \
  -H "Authorization: Bearer $BILLING_KEY"
PATCH /webhook_endpoints/{id} scope webhooks:write · SDK billing.webhookEndpoints.update()

Update a webhook endpoint

Parameters

id requiredstring · pathObject id.

Body · WebhookEndpointInput

descriptionstring
enabledbooleanUpdate only.
enabled_eventsstring[]Event types, wildcards allowed (subscription.*). Default [*].
urlstringHTTPS URL.

Returns

WebhookEndpoint

curl https://pay.marthaia.com/v1/webhook_endpoints/we_01a15d… \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X PATCH \
  -H "Content-Type: application/json" \
  -d '{}'
DELETE /webhook_endpoints/{id} scope webhooks:write · SDK billing.webhookEndpoints.del()

Delete a webhook endpoint

Parameters

id requiredstring · pathObject id.

Returns

Deleted

curl https://pay.marthaia.com/v1/webhook_endpoints/we_01a15d… \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X DELETE
POST /webhook_endpoints/{id}/rotate_secret scope webhooks:write · SDK billing.webhookEndpoints.rotateSecret()

Rotate the signing secret

Parameters

id requiredstring · pathObject id.

Returns

SecretRotated

curl https://pay.marthaia.com/v1/webhook_endpoints/we_01a15d…/rotate_secret \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)"

Events

GET /events scope events:read · SDK billing.events.list()

List events

Parameters

typestring · queryFilter by type, e.g. invoice.paid.
object_idstring · queryFilter by object id.
limitinteger · query1–100, default 20.
starting_afterstring · queryCursor: id of the last item of the previous page.
ending_beforestring · queryCursor: id of the first item of the next page.

Returns

A list of Event objects (data, has_more).

curl https://pay.marthaia.com/v1/events \
  -H "Authorization: Bearer $BILLING_KEY"
GET /events/{id} scope events:read · SDK billing.events.retrieve()

Retrieve an event

Parameters

id requiredstring · pathObject id.

Returns

Event

curl https://pay.marthaia.com/v1/events/evt_01a15d… \
  -H "Authorization: Bearer $BILLING_KEY"
POST /events/{id}/redeliver scope events:write · SDK billing.events.redeliver()

Redeliver an event to every matching endpoint

Parameters

id requiredstring · pathObject id.

Returns

Redelivered

curl https://pay.marthaia.com/v1/events/evt_01a15d…/redeliver \
  -H "Authorization: Bearer $BILLING_KEY" \
  -X POST \
  -H "Idempotency-Key: $(uuidgen)"

Methods

GET /methods/eligible scope methods:read · SDK billing.methods.eligible()

List eligible payment methods

Parameters

customerstring · querycus_…, used for the country.
amountinteger · queryMinor units.
currencystring · queryISO 4217.
countrystring · queryISO alpha-2.
flowstring · queryone_time (default), subscription or setup.

Returns

A list of EligibleMethod objects (data, has_more).

curl https://pay.marthaia.com/v1/methods/eligible \
  -H "Authorization: Bearer $BILLING_KEY"
GET /methods/operators scope methods:read · SDK billing.methods.operators()

List enabled mobile money operators

Parameters

countrystring · queryISO alpha-2.

Returns

A list of Operator objects (data, has_more).

curl https://pay.marthaia.com/v1/methods/operators \
  -H "Authorization: Bearer $BILLING_KEY"

Objects

Address

Postal address.

citystring
countrystringISO 3166-1 alpha-2.
line1string
line2string
postal_codestring
statestring

CancelInput

at_period_endbooleanKeep access until the period ends.
reasonstring

ChangePlanInput

items alwaysLineItem[]
proration_behaviorstringProvider-managed only. One of: create_prorations, none, always_invoice.

CheckoutCustomer

Customer to create or match (by external_id) for the session.

idstringExisting cus_…
billing_addressAddress
countrystring
emailstring
external_idstringYour user id; creates or matches the customer.
localestring
namestring
phonestring

CheckoutSession

A hosted checkout page for one customer.

id alwaysstringcs_…
mode alwaysstring One of: payment, subscription, setup.
object alwaysstring One of: checkout.session.
status alwaysstring One of: open, complete, expired.
allowed_methodsstring[]
amount_totalintegerMinor units.
cancel_urlstring
client_reference_idstring
completed_attimestamp | null
createdintegerCreation time (Unix seconds)
currencystring | null
customerstring | nullcus_…
eligible_methodsstring[]Kinds the customer can use (creation only).
expires_attimestamp
invoicestring | nullinv_…
itemsLineItem[]
localestring
metadatamapUp to 50 string key/value pairs for your own use.
setup_payment_methodstring | nullpm_…
subscriptionstring | nullsub_…
success_urlstring
urlstringHosted page; only returned on creation.

CheckoutSessionInput

mode alwaysstringpayment = one-off, subscription = recurring prices, setup = save a method without charging. One of: payment, subscription, setup.
success_url alwaysstringAbsolute URL; {SESSION_ID} is replaced.
allowed_methodsstring[]Restrict the offer: kinds ("mobile_money"), connections (gwc_…) or one method (gwc_…:card). Pinned connections skip their own country rule.
cancel_urlstring
client_reference_idstring
currencystringDefaults to the customer’s, then the project’s.
customerCheckoutCustomer
customer_idstringAlternative to customer: an existing cus_….
expires_inintegerSeconds, default from settings (24 h).
itemsLineItem[]Required unless mode is setup.
localestringfr or en.
metadatamapUp to 50 string key/value pairs for your own use.

ConfirmInput

reason alwaysstring
confirmbooleanfalse to reject; default true.

CurrencyOption

Amount of a price in one currency.

amount alwaysintegerMinor units (5000 XAF, 900 = 9.00 USD).
currency alwaysstringISO 4217.

Customer

A person or company that pays you.

id alwaysstringcus_…
object alwaysstring One of: customer.
anonymizedbooleanTrue once personal data was erased.
billing_addressAddress
countrystring | nullISO alpha-2.
createdintegerCreation time (Unix seconds)
currencystring | nullPreferred currency.
default_payment_methodstring | nullpm_…
emailstring
external_idstringYour own user id; unique per environment.
localestringfr or en.
metadatamapUp to 50 string key/value pairs for your own use.
namestring
phonestringE.164.

CustomerInput

Fields to create or update a customer.

billing_addressAddress
countrystringISO alpha-2.
currencystringISO 4217.
emailstring
external_idstringYour user id.
localestring
metadatamapUp to 50 string key/value pairs for your own use.
namestring
phonestring

Deleted

idstring
deletedboolean
objectstring

EligibleMethod

A payment method the customer can use.

assurancestring One of: signed, unsigned, no_status_endpoint.
flowsstring[]
gatewaystring
gateway_connectionstringgwc_…
kindstring
labelstring
needs_phoneboolean
operatorsOperator[]

Entitlement

Access decision for one product.

entitled alwaysbooleanWhether to grant access now.
product_id alwaysstringprod_…
entitled_untiltimestamp | null
featuresmap
group_keystring | null
metadatamapUp to 50 string key/value pairs for your own use.
product_namestring
reasonstringactive, grace_period, …
statusstringSubscription status.
subscription_idstringsub_…

Error

Error envelope returned with every non-2xx response.

error alwaysobjectFields: code, message, type, param, request_id.

Event

Something that happened; also the webhook payload.

id alwaysstringevt_…
object alwaysstring One of: event.
type alwaysstringe.g. subscription.activated, invoice.paid.
api_versionstring
createdintegerCreation time (Unix seconds)
dataobjectFields: object.

Invoice

What a customer owes. The only object that can be paid.

id alwaysstringinv_…
object alwaysstring One of: invoice.
status alwaysstring One of: draft, open, paid, void, uncollectible.
amount_dueinteger
amount_paidinteger
amount_refundedinteger
attempt_countinteger
billing_reasonstring One of: subscription_create, subscription_cycle, subscription_update, manual, checkout.
checkout_sessionstring | nullcs_…
collection_methodstring One of: automatic, send_invoice.
createdintegerCreation time (Unix seconds)
currencystring
customerstringcus_…
customer_snapshotmap
descriptionstring
due_attimestamp | null
finalized_attimestamp | null
linesInvoiceLine[]
metadatamapUp to 50 string key/value pairs for your own use.
next_attempt_attimestamp | null
numberstring | nullGap-free number, assigned at finalisation.
paid_attimestamp | null
periodobjectPeriod this invoice grants (subscription invoices). Fields: end, start.
provider_hosted_urlstring | null
provider_invoice_idstring | null
provider_pdf_urlstring | null
sourcestring
subscriptionstring | nullsub_…
subtotalinteger
tax_totalinteger
totalinteger
voided_attimestamp | null

InvoiceInput

Manual invoice.

customer alwaysstringcus_…
items alwaysobject[]
auto_finalizeboolean
collection_methodstring One of: automatic, send_invoice.
currencystring
days_until_dueinteger
descriptionstring
metadatamapUp to 50 string key/value pairs for your own use.

InvoiceLine

idstringil_…
amountinteger
descriptionstring
periodobjectFields: end, start.
pricestring | nullprice_…
quantityinteger
tax_amountinteger
tax_rate_bpintegerBasis points.
unit_amountinteger

LineItem

price alwaysstringprice_…
quantityintegerDefault 1.

NextAction

What the customer must do next.

type alwaysstring One of: redirect, widget, client_secret, ussd_prompt, otp_required, social_links, crypto_address.
addressstring
client_secretstring
linksmapsocial_links: whatsapp, telegram, dikalo, sms.
messagestring
otp_lengthinteger
publishable_keystring
redirect_urlstring

OTPInput

code alwaysstringCode typed by the customer; never stored.

Operator

A mobile money operator.

idstringgwo_…
codestring
collection_fee_bpinteger
countrystring
enabledboolean
kindstring
namestring
requires_browserboolean
requires_otpboolean

Payment

One attempt to collect an invoice through one gateway.

id alwaysstringpay_…
object alwaysstring One of: payment.
status alwaysstring One of: created, requires_action, processing, succeeded, failed, canceled, expired.
amountinteger
countrystring | null
createdintegerCreation time (Unix seconds)
currencystring
expires_attimestamp | null
failure_codestring | null
failure_messagestring | null
flowstring
gatewaystringstripe, notchpay, …
gateway_connectionstringgwc_…
initiated_bystring
invoicestringinv_…
method_kindstring
needs_manual_reviewboolean
next_actionNextAction
operatorstring | null
otp_attempts_remaininginteger
payer_phonestring | nullMasked.
payment_methodstring | nullpm_…
provider_amountinteger | null
provider_currencystring | null
provider_refstring | null
retryableboolean
review_reasonstring
settled_attimestamp | null

PaymentLinkInput

activebooleanUpdate only.
allowed_methodsstring[]kind ("mobile_money"), gwc_… (every kind of a connection) or gwc_…:kind. Pinned connections skip their own country rule.
cancel_urlstring
currencystring
metadatamapUp to 50 string key/value pairs for your own use.
namestring
pricestringprice_… of the catalogue (create only). Give price or price_data.
price_dataobjectCustom amount: a hidden product and price are created for it (new price on every change, so paid invoices keep their amount). Fields: amount, currency, description, interval, interval_count, name, type.
quantityintegerDefault 1 (create only).
success_urlstringDefault: a hosted thank-you page.

PaymentMethod

A saved card, wallet or mobile money account.

id alwaysstringpm_…
object alwaysstring One of: payment_method.
createdintegerCreation time (Unix seconds)
created_viastring
customerstringcus_…
defaultboolean
displayobjectFields: brand, email, exp_month, exp_year, last4, msisdn_masked, operator.
gatewaystring
gateway_connectionstringgwc_…
kindstringcard, mobile_money, paypal…
statusstring One of: active, expired, detached, failed.

PaymentMethodRef

payment_methodstringpm_…; default method when omitted.

PortalSessionInput

customer alwaysstringcus_…
allowed_actionsstring[]
allowed_pricesstring[]Plans offered in “change plan”.
localestring
return_urlstring

Price

How much a product costs, per currency.

id alwaysstringprice_…
object alwaysstring One of: price.
product alwaysstringprod_…
type alwaysstring One of: one_time, recurring.
activeboolean
createdintegerCreation time (Unix seconds)
currency_optionsCurrencyOption[]One amount per supported currency; no FX conversion exists.
external_checkout_urlstring | null
lookup_keystring | nullStable key your code can use instead of the id.
metadatamapUp to 50 string key/value pairs for your own use.
nicknamestring
recurringobjectSet for recurring prices. Fields: interval, interval_count.
tax_behaviorstring One of: project, inclusive, exclusive.

PriceInput

Fields to create a price.

amounts alwaysmapMinor units per currency, e.g. {"XAF": 5000, "USD": 900}.
product alwaysstringprod_…
type alwaysstring One of: one_time, recurring.
external_checkout_urlstring
intervalstringRecurring only. One of: day, week, month, year.
interval_countintegerRecurring only, default 1.
lookup_keystring
metadatamapUp to 50 string key/value pairs for your own use.
nicknamestring
tax_behaviorstring One of: project, inclusive, exclusive.

PriceUpdate

Mutable fields of a price (amounts only while unused).

activeboolean
amountsmapOnly before the price is used.
lookup_keystring
metadatamapUp to 50 string key/value pairs for your own use.
nicknamestring

PricingSessionInput

Pricing page link bound to a customer you know.

customer alwaysobjectFields: external_id, country, email, locale, name.
cancel_urlstring
currencystringPreselected currency.
expires_inintegerSeconds, default 86400, max 7 days.
group_keystringOnly plans of this group.
localestring
success_urlstring

Product

Something you sell.

id alwaysstringprod_…
name alwaysstring
object alwaysstring One of: product.
activeboolean
createdintegerCreation time (Unix seconds)
descriptionstring
featuresmapFree-form features shown on the pricing page and returned with entitlements.
group_keystring | nullProducts sharing a group key allow one entitled subscription per customer.
metadatamapUp to 50 string key/value pairs for your own use.
updatedintegerLast update (Unix seconds)

ProductInput

Fields to create or update a product.

activeboolean
descriptionstring
featuresmap
group_keystring
metadatamapUp to 50 string key/value pairs for your own use.
namestring

Redelivered

idstringevt_…
deliveries_enqueuedintegerDeliveries queued.

Refund

id alwaysstringre_…
object alwaysstring One of: refund.
status alwaysstring One of: pending, succeeded, failed, canceled.
amountinteger
createdintegerCreation time (Unix seconds)
credit_notestring | nullcn_…
currencystring
failure_messagestring | null
invoicestringinv_…
kindstring
paymentstringpay_…
provider_refstring | null
reasonstring

RefundInput

amountintegerMinor units; default the remaining refundable amount.
manualbooleanRecord a refund made outside the gateway.
reasonstring

ResendInput

operatorstringNew operator code.
phonestringNew number.

SecretRotated

id alwaysstringwe_…
secret alwaysstringNew signing secret, shown once.

Subscription

Recurring billing for one customer.

id alwaysstringsub_…
object alwaysstring One of: subscription.
status alwaysstring One of: incomplete, incomplete_expired, active, past_due, paused, unpaid, canceled.
cancel_attimestamp | null
cancel_at_period_endboolean
canceled_attimestamp | null
collection_methodstring One of: automatic, send_invoice.
collection_modestringprovider_managed = billed by the gateway (Stripe Billing); platform_managed = billed by the platform. One of: provider_managed, platform_managed.
createdintegerCreation time (Unix seconds)
currencystring
current_period_endtimestamp | null
current_period_starttimestamp | null
customerstringcus_…
default_payment_methodstring | nullpm_…
ended_attimestamp | null
gateway_connectionstring | nullgwc_…
group_keystring | null
itemsSubscriptionItem[]
latest_invoicestring | nullinv_…
metadatamapUp to 50 string key/value pairs for your own use.
pause_collectionboolean
pending_changemapPlan change waiting for its invoice to be paid.
provider_subscription_idstring | null
sourcestring
trial_endtimestamp | null

SubscriptionInput

Create a subscription with a saved method (no checkout).

customer alwaysstringcus_…
items alwaysLineItem[]
collection_methodstring One of: automatic, send_invoice.
currencystring
gateway_connectionstringgwc_…
mark_paid_reasonstringOperator-assigned plan: first invoice settled manually with this reason.
metadatamapUp to 50 string key/value pairs for your own use.
payment_methodstringpm_…

SubscriptionItem

idstringsi_…
pricestringprice_…
quantityinteger

WebhookEndpoint

id alwaysstringwe_…
object alwaysstring One of: webhook_endpoint.
url alwaysstring
api_versionstring
createdintegerCreation time (Unix seconds)
descriptionstring
enabledboolean
enabled_eventsstring[]
failing_sincetimestamp | null
secretstringSigning secret, returned once on creation and rotation.

WebhookEndpointInput

descriptionstring
enabledbooleanUpdate only.
enabled_eventsstring[]Event types, wildcards allowed (subscription.*). Default [*].
urlstringHTTPS URL.