const { result, error } = await unprice.customers.getSubscription("cus_1234567890");
if (error) {
// handle potential network or bad request error
// a link to our docs will be in the `error.docs` field
console.error(error.message);
return;
}
console.log(result);
{
"subscription": {
"id": "sub_1234567890",
"status": "active",
"currentPeriodStart": 1678900000,
"currentPeriodEnd": 1681492000,
"cancelAtPeriodEnd": false,
"phases": [
{
"id": "phase_1234567890",
"startDate": 1678900000,
"endDate": 1681492000,
"planVersionId": "pv_1234567890",
"status": "active"
}
]
}
}
Request
The ID of the customer to get subscription for
Response
The subscription information
The ID of the subscription
The status of the subscription (active, canceled, etc.)
subscription.currentPeriodStart
The start timestamp of the current period
subscription.currentPeriodEnd
The end timestamp of the current period
subscription.cancelAtPeriodEnd
Whether the subscription will be canceled at the end of the current period
Array of subscription phases
subscription.phases[].startDate
The start timestamp of the phase
subscription.phases[].endDate
The end timestamp of the phase
subscription.phases[].planVersionId
The ID of the plan version for this phase
subscription.phases[].status
The status of the phase (active, upcoming, etc.)