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"
      }
    ]
  }
}
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

customerId
string
required
The ID of the customer to get subscription for

Response

subscription
object
required
The subscription information
subscription.id
string
required
The ID of the subscription
subscription.status
string
required
The status of the subscription (active, canceled, etc.)
subscription.currentPeriodStart
number
required
The start timestamp of the current period
subscription.currentPeriodEnd
number
required
The end timestamp of the current period
subscription.cancelAtPeriodEnd
boolean
required
Whether the subscription will be canceled at the end of the current period
subscription.phases
array
required
Array of subscription phases
subscription.phases[].id
string
required
The ID of the phase
subscription.phases[].startDate
number
required
The start timestamp of the phase
subscription.phases[].endDate
number
required
The end timestamp of the phase
subscription.phases[].planVersionId
string
required
The ID of the plan version for this phase
subscription.phases[].status
string
required
The status of the phase (active, upcoming, etc.)