Start a subscription checkout
const url = 'https://api.pitch2sale.com/api/v1/billing/checkout';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"plan_slug":"example","interval":"monthly","seats":1,"coupon_code":"example","replace_current":true,"switch_now":true,"billing":{"legal_name":"example","country":"example","state":"example","gstin":"example","address":"example","phone_e164":"example"}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.pitch2sale.com/api/v1/billing/checkout \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "plan_slug": "example", "interval": "monthly", "seats": 1, "coupon_code": "example", "replace_current": true, "switch_now": true, "billing": { "legal_name": "example", "country": "example", "state": "example", "gstin": "example", "address": "example", "phone_e164": "example" } }'Creates a monthly Cashfree subscription for plan_slug and returns the hosted checkout session_id. The amount is always computed on the server from the current plan price, the active org discount or an optional percent coupon_code (never both), plus 18% GST for INR. replace_current: true replaces a live subscription (it is canceled at Cashfree, keeps access to its period end, and the new first charge waits for that date). During a trial, or with a period already paid, nothing is charged until that date; otherwise the first month is charged when the mandate is authorised (UPI or card) and monthly after that. collect_at_auth, charge_now_minor, first_charge_at and charge_note state which. Switch to yearly now (switch_now: true with replace_current: true and interval: yearly, on a monthly subscription that has been charged): a yearly mandate is authorised beside the monthly one and nothing is charged at authorisation; once it is authorised an order for the yearly price less the unused part of the current month (rounded down, plus GST for INR) is opened and offered in the app and by email (GET /billing/subscription switch_to_yearly.order). Paying it ends the monthly mandate and starts the yearly term; an unpaid order (48 hours, or the start of the 48 hours before the monthly payment) drops the switch and cancels the yearly mandate. The answer has switch_to_yearly.pay_now_minor (priced as of now). 409 change_locked inside the 48 hours before a monthly payment; 409 switch_to_yearly_unavailable for a lower plan, fewer seats, or a subscription never charged. Owners and admins only; 409 self_serve_disabled when the kill switch is off; 5 per 10 minutes per organization.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
object
Responses
Section titled “Responses”OK
Validation failed
object
object
Examplegenerated
{ "error": "example", "code": "example", "message": "example", "details": [ { "field": "example", "message": "example", "code": "example" } ]}Authentication required or token invalid
object
object
Examplegenerated
{ "error": "example", "code": "example", "message": "example", "details": [ { "field": "example", "message": "example", "code": "example" } ]}Role permission or token scope missing; OAuth app tokens are not accepted on this route
object
object
Examplegenerated
{ "error": "example", "code": "example", "message": "example", "details": [ { "field": "example", "message": "example", "code": "example" } ]}Rate limit exceeded
object
object
Examplegenerated
{ "error": "example", "code": "example", "message": "example", "details": [ { "field": "example", "message": "example", "code": "example" } ]}