Skip to content

Subscriptions API

Manage recurring subscriptions in your store.

List Subscriptions

http
GET /api/external/v1/subscriptions

Query Parameters

ParameterTypeDescription
pageintegerPage number (default: 1)
per_pageintegerItems per page (default: 15, max: 100)
statusstringFilter: active, trialing, past_due, canceled, incomplete
customer_idintegerFilter by customer ID
product_idintegerFilter by product ID
sortstringSort field: created_at, current_period_end
orderstringSort order: asc, desc

Example Request

bash
curl -X GET "https://yourstore.pixlpay.net/api/external/v1/subscriptions?status=active" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json"

Response

json
{
  "success": true,
  "data": [
    {
      "id": 1,
      "customer_id": 42,
      "product_id": 5,
      "status": "active",
      "payment_gateway": "stripe",
      "gateway_subscription_id": "sub_1234567890",
      "product": {
        "id": 5,
        "name": "VIP Monthly",
        "price": "9.99",
        "currency": "usd"
      },
      "customer": {
        "id": 42,
        "email": "player@example.com",
        "username": "Player123"
      },
      "current_period_start": "2025-01-01T00:00:00Z",
      "current_period_end": "2025-02-01T00:00:00Z",
      "trial_ends_at": null,
      "cancel_at_period_end": false,
      "canceled_at": null,
      "created_at": "2025-01-01T00:00:00Z"
    }
  ],
  "meta": {
    "current_page": 1,
    "last_page": 3,
    "per_page": 15,
    "total": 42
  }
}

Get Single Subscription

http
GET /api/external/v1/subscriptions/{id}

Example Request

bash
curl -X GET "https://yourstore.pixlpay.net/api/external/v1/subscriptions/1" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json"

Response

json
{
  "success": true,
  "data": {
    "id": 1,
    "customer_id": 42,
    "product_id": 5,
    "status": "active",
    "payment_gateway": "stripe",
    "gateway_subscription_id": "sub_1234567890",
    "gateway_customer_id": "cus_1234567890",
    "product": {
      "id": 5,
      "name": "VIP Monthly",
      "description": "Monthly VIP membership with exclusive perks",
      "price": "9.99",
      "currency": "usd",
      "formatted_price": "$9.99"
    },
    "customer": {
      "id": 42,
      "email": "player@example.com",
      "username": "Player123",
      "discord_id": "123456789"
    },
    "quantity": 1,
    "trial_ends_at": null,
    "current_period_start": "2025-01-01T00:00:00Z",
    "current_period_end": "2025-02-01T00:00:00Z",
    "cancel_at_period_end": false,
    "canceled_at": null,
    "ended_at": null,
    "is_active": true,
    "is_on_trial": false,
    "is_past_due": false,
    "is_canceled": false,
    "days_until_renewal": 12,
    "renewal_date": "February 1, 2025",
    "created_at": "2025-01-01T00:00:00Z",
    "updated_at": "2025-01-01T00:00:00Z"
  }
}

Cancel Subscription

Cancel a subscription immediately or at the end of the billing period.

http
POST /api/external/v1/subscriptions/{id}/cancel

Request Body

ParameterTypeRequiredDescription
immediatelybooleanNoIf true, cancel immediately. If false (default), cancel at period end.

Example Request (Cancel at Period End)

bash
curl -X POST "https://yourstore.pixlpay.net/api/external/v1/subscriptions/1/cancel" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"immediately": false}'

Response

json
{
  "success": true,
  "data": {
    "id": 1,
    "status": "active",
    "cancel_at_period_end": true,
    "canceled_at": "2025-01-20T14:30:00Z",
    "current_period_end": "2025-02-01T00:00:00Z"
  },
  "message": "Subscription will be canceled at the end of the billing period"
}

Example Request (Cancel Immediately)

bash
curl -X POST "https://yourstore.pixlpay.net/api/external/v1/subscriptions/1/cancel" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"immediately": true}'

Response

json
{
  "success": true,
  "data": {
    "id": 1,
    "status": "canceled",
    "cancel_at_period_end": false,
    "canceled_at": "2025-01-20T14:30:00Z",
    "ended_at": "2025-01-20T14:30:00Z"
  },
  "message": "Subscription canceled successfully"
}

Resume Subscription

Resume a subscription that was scheduled for cancellation (before it actually ends).

http
POST /api/external/v1/subscriptions/{id}/resume

TIP

This only works for subscriptions with cancel_at_period_end: true that haven't reached their cancellation date yet. Already-canceled subscriptions cannot be resumed.

Example Request

bash
curl -X POST "https://yourstore.pixlpay.net/api/external/v1/subscriptions/1/resume" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json"

Response

json
{
  "success": true,
  "data": {
    "id": 1,
    "status": "active",
    "cancel_at_period_end": false,
    "canceled_at": null,
    "current_period_end": "2025-02-01T00:00:00Z"
  },
  "message": "Subscription resumed successfully"
}

Subscription Object

FieldTypeDescription
idintegerUnique identifier
customer_idintegerID of the customer
product_idintegerID of the subscription product
statusstringCurrent status (see below)
payment_gatewaystringPayment gateway: stripe, paypal, mollie, etc.
gateway_subscription_idstringPayment gateway's subscription ID
gateway_customer_idstringPayment gateway's customer ID
productobjectProduct details
customerobjectCustomer details
quantityintegerSubscription quantity (usually 1)
trial_ends_atstringTrial end timestamp (null if no trial)
current_period_startstringCurrent billing period start
current_period_endstringCurrent billing period end
cancel_at_period_endbooleanWhether scheduled to cancel at period end
canceled_atstringWhen cancellation was requested
ended_atstringWhen subscription actually ended
is_activebooleanWhether subscription is currently active
is_on_trialbooleanWhether subscription is in trial period
is_past_duebooleanWhether payment is past due
is_canceledbooleanWhether subscription is canceled
days_until_renewalintegerDays until next billing
renewal_datestringHuman-readable renewal date
created_atstringISO 8601 timestamp
updated_atstringISO 8601 timestamp

Subscription Statuses

StatusDescription
activeSubscription is active and payments are current
trialingSubscription is in trial period
past_duePayment failed, subscription still active pending retry
canceledSubscription has been canceled and ended
incompleteInitial payment failed, awaiting action
incomplete_expiredIncomplete subscription expired
unpaidPayment failures exhausted, subscription paused

Product Object (Nested)

FieldTypeDescription
idintegerProduct ID
namestringProduct name
descriptionstringProduct description
pricestringSubscription price per period
currencystringCurrency code (e.g., usd, eur)
formatted_pricestringHuman-readable price (e.g., $9.99)

Customer Object (Nested)

FieldTypeDescription
idintegerCustomer ID
emailstringCustomer email
usernamestringDisplay username
discord_idstringDiscord user ID (if connected)

Errors

StatusErrorDescription
400Bad RequestCannot cancel already-canceled subscription
400Bad RequestCannot resume non-canceled subscription
401UnauthorizedInvalid or missing token
403ForbiddenToken lacks required scope
404Not FoundSubscription doesn't exist
422UnprocessableInvalid request parameters

Required Scopes

EndpointRequired Scope
GET /subscriptionssubscriptions:read
GET /subscriptions/{id}subscriptions:read
POST /subscriptions/{id}/cancelsubscriptions:write
POST /subscriptions/{id}/resumesubscriptions:write

Webhook Events

Subscribe to these events to stay updated on subscription changes:

EventDescription
subscription.createdNew subscription created
subscription.updatedSubscription status or details changed
subscription.canceledSubscription was canceled
subscription.renewedSubscription successfully renewed
subscription.payment_failedRenewal payment failed

See Webhook Events for payload details.

Built for game developers, by game developers.