Xtopay Docs
API Reference

Subscriptions API

Full reference for Plans, Subscriptions, and Invoices endpoints.

Plans

POST /plans

Create a plan.

FieldTypeRequiredDescription
namestringyesPlan display name
amountintegeryesAmount in smallest unit
currencystringyesISO 4217 currency
intervalstringyesday | week | month | year
interval_countintegernoDefault 1
trial_period_daysintegernoDefault trial length for new subscriptions
metadataobjectno

GET /plans/:id

Retrieve a plan.

GET /plans

List all plans. Filter with ?active=true.

POST /plans/:id/archive

Archive a plan. Prevents new subscriptions; existing subscriptions continue.


Subscriptions

POST /subscriptions

Create a subscription.

FieldTypeRequiredDescription
customer_idstringyesCustomer to subscribe
plan_idstringyesPlan to subscribe to
payment_method_idstringnoSaved payment method to charge
trial_period_daysintegernoOverride plan default
trial_endISO 8601noExplicit trial end date
cancel_at_period_endbooleanno
metadataobjectno
curl https://api.xtopay.co/v1/subscriptions \
  -u "$CLIENT_ID:$CLIENT_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "customer_id": "cus_abc123",
    "plan_id": "plan_pro_xyz",
    "trial_period_days": 14
  }'

GET /subscriptions/:id

Retrieve a subscription.

PATCH /subscriptions/:id

Update a subscription. Accepted fields: plan_id, proration_behavior, cancel_at_period_end, payment_method_id, trial_end, metadata.

POST /subscriptions/:id/cancel

FieldTypeDescription
cancel_at_period_endbooleanIf true, cancel at end of period; if false, cancel immediately

POST /subscriptions/:id/reactivate

Reactivate a subscription that was set to cancel at period end but hasn't cancelled yet.

POST /subscriptions/:id/pause

FieldTypeDescription
resumes_atISO 8601Optional auto-resume date

POST /subscriptions/:id/resume

Resume a paused subscription.

GET /subscriptions

List subscriptions. Filter with ?customer_id=, ?status=, ?plan_id=.


Invoices

GET /invoices/:id

Retrieve an invoice.

GET /invoices/:id/pdf

Download invoice as PDF. Returns a redirect to a signed URL.

POST /invoices/:id/void

Void an open invoice.

GET /invoices

List invoices. Filter with ?customer_id=, ?subscription_id=, ?status=.

On this page