Subscriptions
Subscriptions bill a customer's card on a schedule. Setting one up takes three calls.
1. Create a customer
POST /subscriptions-customers/ is an upsert keyed on email.
curl -X POST https://api.intasend.com/api/v1/subscriptions-customers/ \
-H "Authorization: Bearer $INTASEND_SECRET_KEY" -H "Content-Type: application/json" \
-d '{"email": "[email protected]", "first_name": "Jane", "last_name": "Doe", "country": "KE", "reference": "user-42"}'
| Field | Required | Description |
|---|---|---|
email | Yes | Customer's email. Creating a customer with an existing email updates that customer. |
first_name, last_name | Yes | Customer's name |
reference | No | Your own ID for the customer. Max 45 characters. |
country | No | ISO-2 country code, for example KE |
address, city, state | No | Billing address. Max 50 characters each. |
zipcode | No | Max 10 characters |
2. Create a plan
POST /subscriptions-plans/ is an upsert keyed on name.
curl -X POST https://api.intasend.com/api/v1/subscriptions-plans/ \
-H "Authorization: Bearer $INTASEND_SECRET_KEY" -H "Content-Type: application/json" \
-d '{"name": "Pro monthly", "amount": 1000, "currency": "KES", "frequency": 1, "frequency_unit": "M", "billing_cycles": 12}'
| Field | Required | Description |
|---|---|---|
name | Yes | Plan name. Creating a plan with an existing name updates that plan. Max 32 characters. |
amount | Yes | Amount charged each billing period |
currency | Yes | Currency of amount, for example KES or USD |
frequency | Yes | Number of frequency_units between charges. 1 with M bills monthly. |
frequency_unit | No | D (day), W (week), M (month, the default) or Y (year) |
billing_cycles | No | How many times to bill the customer |
reference | No | Your own ID for the plan. Max 45 characters. |
redirect_url | No | Where to send the customer after a successful payment |
3. Subscribe the customer
curl -X POST https://api.intasend.com/api/v1/subscriptions/ \
-H "Authorization: Bearer $INTASEND_SECRET_KEY" -H "Content-Type: application/json" \
-d '{"customer_id": "CUSTOMER_ID", "plan_id": "PLAN_ID", "reference": "sub-42", "redirect_url": "https://example.com/done"}'
| Field | Required | Description |
|---|---|---|
customer_id | Yes | The customer's ID from step 1 |
plan_id | Yes | The plan's ID from step 2 |
reference | No | Your own ID for the subscription |
redirect_url | No | Where to send the customer after a successful payment |
Send the customer to the returned setup_url to add their card. The subscription then becomes ACTIVE.
Manage
| Call | Purpose |
|---|---|
GET /subscriptions/{id}/ | Details: status, next_date, completed_cycles, card_mask |
PUT /subscriptions/{id}/ | Change plan_id, and optionally start_date (YYYY-MM-DD, today or later) |
GET /subscriptions/{id}/transactions/ | Payments made |
POST /subscriptions/{id}/unsubscribe/ | Cancel |
status is one of PENDING, ACTIVE, CANCELED, COMPLETE or FAILED. Changes are sent as the subscription_event webhook.