API v1
v1
View as Markdown

Open a checkout

POST /api/v1/billing/checkout-sessions

Open a Stripe Checkout session for one of the plans and answer the page to send the buyer to.

Payment is taken at Stripe and nowhere else: this API never receives card details. Access opens when Stripe confirms the payment, which is usually seconds after the buyer finishes, so read the billing object again rather than trusting their return.

A price this account may not take up is refused before any session is opened. That covers an account that already owns the product outright, and a subscriber asking for a plan that does not sit above the one they are on.

Body parameters

Sent as JSON. Anything not listed here is ignored.

price_id string Required

The id of the price at Stripe, from offers in the billing object. Maximum 255 characters.

currency string Optional

Which of the currencies the plan is quoted in to charge, three letters. Left out, Stripe charges in the currency of the price.

Returns

A checkout_session object carrying the URL. 422 when the price is not a plan this account may take up, and 503 when Stripe did not answer, in which case nothing was charged and nothing changed.

data object

The checkout that was opened.

data.type string

Always checkout_session.

data.attributes object

Everything the record holds.

data.attributes.url string

The page at Stripe to send the buyer to. It is short lived, it is the only place a card is ever entered, and opening it charges nothing on its own.

Rate limit

Sixty requests per minute, per user, shared by every key and device. Every answer carries the budget left in X-RateLimit-Remaining.

POST
curl https://my.monicahq.com/api/v1/billing/checkout-sessions \
-X POST \
-H "Authorization: Bearer $MONICA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"price_id": "price_1QdundieMonthly",
"currency": "eur"
}'
const response = await fetch('https://my.monicahq.com/api/v1/billing/checkout-sessions', {
method: 'POST',
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
price_id: 'price_1QdundieMonthly',
currency: 'eur',
}),
})
const data = await response.json()
$response = Http::withToken($token)->post('https://my.monicahq.com/api/v1/billing/checkout-sessions', [
'price_id' => 'price_1QdundieMonthly',
'currency' => 'eur',
]);
Response 201
{
"data": {
"type": "checkout_session",
"attributes": {
"url": "https://checkout.stripe.com/c/pay/cs_test_a1dundermifflin"
}
}
}

Keys act as you, with exactly the access you have. Make one per integration so you can revoke it alone.