Xtopay Docs
API Reference

Customers API

Full reference for Customer and Payment Method endpoints.

Customers

POST /customers

Create a customer.

FieldTypeRequiredDescription
emailstringyesCustomer email address
namestringnoFull name
phonestringnoE.164 format
currencystringnoDefault currency (ISO 4217)
metadataobjectno
curl https://api.xtopay.co/v1/customers \
  -u "$CLIENT_ID:$CLIENT_SECRET" \
  -H "Content-Type: application/json" \
  -d '{ "email": "ama@example.com", "name": "Ama Owusu" }'

Response 201

{
  "id": "cus_a1b2c3",
  "email": "ama@example.com",
  "name": "Ama Owusu",
  "phone": null,
  "currency": "GHS",
  "created_at": "2026-05-24T10:00:00Z"
}

GET /customers/:id

Retrieve a customer with their subscriptions and payment methods.

PATCH /customers/:id

Update customer fields. Any field except id can be updated.

DELETE /customers/:id

Delete a customer. Cancels all active subscriptions immediately.

GET /customers

List customers.

ParameterDescription
emailSearch by exact email
limit1–100, default 20
afterCursor for next page

Payment Methods

POST /setup-intents

Create a setup intent to securely collect and save a payment method.

curl https://api.xtopay.co/v1/setup-intents \
  -u "$CLIENT_ID:$CLIENT_SECRET" \
  -H "Content-Type: application/json" \
  -d '{ "customer_id": "cus_a1b2c3" }'

Response

{
  "id": "si_a1b2c3",
  "customer_id": "cus_a1b2c3",
  "setup_url": "https://checkout.xtopay.co/setup/tok_xyz",
  "expires_at": "2026-05-24T10:30:00Z"
}

GET /payment-methods/:id

Retrieve a saved payment method.

GET /payment-methods

List payment methods for a customer.

curl "https://api.xtopay.co/v1/payment-methods?customer_id=cus_a1b2c3" \
  -u "$CLIENT_ID:$CLIENT_SECRET"

DELETE /payment-methods/:id

Detach a payment method from the customer.


Customer Portal

POST /customer-portal/sessions

Create a portal session.

FieldTypeRequiredDescription
customer_idstringyes
return_urlstringyesURL to return to after portal visit

Response

{
  "id": "cps_a1b2c3",
  "url": "https://billing.xtopay.co/portal/sess_xyz",
  "expires_at": "2026-05-24T10:30:00Z"
}

On this page