Create a subscription (first charge confirmed by frontend)
POST
/api/v1/subscriptions
const url = 'https://example.com/api/v1/subscriptions';const options = { method: 'POST', headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'}, body: '{"customerId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","planId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","trialPeriodDays":14,"idempotencyKey":"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://example.com/api/v1/subscriptions \ --header 'Content-Type: application/json' \ --header 'x-api-key: <x-api-key>' \ --data '{ "customerId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "planId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "trialPeriodDays": 14, "idempotencyKey": "example" }'Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
customerId
required
Local customer id (UUID)
string format: uuid
planId
required
Local plan id (UUID)
string format: uuid
trialPeriodDays
Free trial length in days — Stripe schedules the first charge
number
Example
14idempotencyKey
Pass the same key on retries to guarantee the subscription is created at most once
string
Responses
Section titled “Responses”Media typeapplication/json
object
subscription
required
object
id
required
string
stripeSubscriptionId
required
string
customerId
required
string
planId
required
string
status
required
string
currentPeriodStart
required
string format: date-time
currentPeriodEnd
required
string format: date-time
trialEnd
required
string format: date-time
createdAt
required
string format: date-time
updatedAt
required
string format: date-time
clientSecret
required
string
Example
{ "subscription": { "status": "active" }}