Skip to main content

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"}'
FieldRequiredDescription
emailYesCustomer's email. Creating a customer with an existing email updates that customer.
first_name, last_nameYesCustomer's name
referenceNoYour own ID for the customer. Max 45 characters.
countryNoISO-2 country code, for example KE
address, city, stateNoBilling address. Max 50 characters each.
zipcodeNoMax 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}'
FieldRequiredDescription
nameYesPlan name. Creating a plan with an existing name updates that plan. Max 32 characters.
amountYesAmount charged each billing period
currencyYesCurrency of amount, for example KES or USD
frequencyYesNumber of frequency_units between charges. 1 with M bills monthly.
frequency_unitNoD (day), W (week), M (month, the default) or Y (year)
billing_cyclesNoHow many times to bill the customer
referenceNoYour own ID for the plan. Max 45 characters.
redirect_urlNoWhere 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"}'
FieldRequiredDescription
customer_idYesThe customer's ID from step 1
plan_idYesThe plan's ID from step 2
referenceNoYour own ID for the subscription
redirect_urlNoWhere 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​

CallPurpose
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.