Skip to main content

Subscriptions

Manage customer subscriptions.

Create Subscription

Initiates a new subscription in PAUSED state and returns a checkout URL for the customer to complete the first payment.

Endpoint: POST /subscription/create

Request Body

FieldTypeDescriptionRequired
planIdstringID of the subscription plan (UUID)Yes
customerEmailstringEmail address of the customerYes
customerNamestringName of the customerNo
metadataobjectAdditional metadata for the subscriptionNo

Example Request

{
"planId": "550e8400-e29b-41d4-a716-446655440000",
"customerEmail": "john@example.com",
"customerName": "John Doe"
}

Success Response

{
"success": true,
"data": {
"subscriptionId": "uuid-v4-subscription-id",
"checkoutUrl": "https://paysgator.com/checkout/sub_...",
"status": "PAUSED"
}
}

Get Subscription

Retrieve details of a specific subscription.

Endpoint: GET /subscription/{id}

Parameters

ParameterTypeDescriptionRequired
idstringThe UUID of the subscriptionYes

Success Response

{
"success": true,
"data": {
"id": "uuid-v4-subscription-id",
"planId": "uuid-v4-plan-id",
"customerEmail": "john@example.com",
"status": "ACTIVE",
"currentPeriodStart": "2023-10-27T10:00:00Z",
"currentPeriodEnd": "2023-11-27T10:00:00Z",
"createdAt": "2023-10-27T10:00:00Z"
}
}

List Subscriptions

List all subscriptions for your company. You can filter by customer email, status, or plan ID.

Endpoint: GET /subscriptions

Query Parameters

ParameterTypeDescriptionRequired
customerEmailstringFilter by customer emailNo
statusstringFilter by status (ACTIVE, CANCELED, PAST_DUE, PAUSED)No
planIdstringFilter by plan ID (UUID)No

Success Response

{
"success": true,
"data": [
{
"id": "uuid-v4-subscription-id",
"planId": "uuid-v4-plan-id",
"customerEmail": "john@example.com",
"status": "ACTIVE",
"currentPeriodStart": "2023-10-27T10:00:00Z",
"currentPeriodEnd": "2023-11-27T10:00:00Z",
"createdAt": "2023-10-27T10:00:00Z"
}
]
}

Update Subscription

Update the status of an existing subscription. Use this endpoint to cancel, pause, or resume a subscription.

Endpoint: PATCH /subscriptions/{id}

Parameters

ParameterTypeDescriptionRequired
idstringThe UUID of the subscriptionYes

Request Body

FieldTypeDescriptionRequired
actionstringAction to perform: cancel, pause, or resumeYes

Example Request

{
"action": "cancel"
}

Success Response

{
"id": "uuid-v4-subscription-id",
"status": "CANCELED",
"customerEmail": "customer@example.com",
"currentPeriodEnd": "2023-11-27T10:00:00Z"
}