Search Documentation

Search for a documentation page...

Subscription Plans API

REST API endpoints for managing recurring purchase plans.

Subscription plans let customers buy products on a recurring schedule at a discount. A plan's billing frequency is cadence (month or week) multiplied by interval (e.g. cadence month × interval 3 = every quarter). discountPercent is the discount applied versus a one-time purchase. A plan can step that discount as a subscriber keeps renewing: each entry of discountSteps replaces the discount before it from order afterCycle + 1 on, counting the checkout order as order 1 (e.g. discountPercent 10 with steps [{ "afterCycle": 1, "percent": 15 }, { "afterCycle": 2, "percent": 20 }] = 10% on the first order, 15% on the second, 20% from the third). recurringDiscountPercent and recurringDiscountAfterCycle are the older single-step form and mirror the first step. A plan can also add a free product variant (giftVariantId) to one renewal order (giftOnOrder, 2 = the first renewal) at no charge. With giftHidden set, shoppers see "Surprise gift with order N" instead of the product's name until the order that carries the gift. Each plan can be assigned to a set of products that customers may subscribe to.

List Subscription Plans

GET /api/v1/subscription-plans

Returns subscription plans ordered by position. Each plan includes the IDs of products it's assigned to.

Query Parameters

ParameterTypeDefaultDescription
limitnumber50Plans per page (1-100)
offsetnumber0Plans to skip
querystring–Search term for plan name
activeboolean–Filter by active status
curl -H "Authorization: Bearer your_api_key" \
https://your-store.yns.store/api/v1/subscription-plans

Response (200)

{
"data": [
{
"id": "0191abc0-1234-7def-8000-000000000001",
"name": "Monthly delivery",
"cadence": "month",
"interval": 1,
"discountPercent": 10,
"recurringDiscountPercent": null,
"recurringDiscountAfterCycle": 1,
"discountSteps": [],
"giftVariantId": null,
"giftOnOrder": null,
"giftHidden": false,
"description": "Delivered every month",
"benefits": "Free shipping, cancel anytime",
"position": 0,
"active": true,
"productIds": ["0191abc0-0000-7000-8000-000000000200"],
"createdAt": "2024-06-15T10:30:00.000Z",
"updatedAt": "2024-06-15T10:30:00.000Z"
}
],
"meta": {
"count": 1,
"offset": 0,
"limit": 50
}
}

Get Subscription Plan

GET /api/v1/subscription-plans/{id}

Returns a single subscription plan by UUID, including assigned product IDs.

curl -H "Authorization: Bearer your_api_key" \
https://your-store.yns.store/api/v1/subscription-plans/0191abc0-1234-7def-8000-000000000001

Response (200)

{
"id": "0191abc0-1234-7def-8000-000000000001",
"name": "Monthly delivery",
"cadence": "month",
"interval": 1,
"discountPercent": 10,
"description": "Delivered every month",
"benefits": "Free shipping, cancel anytime",
"position": 0,
"active": true,
"productIds": ["0191abc0-0000-7000-8000-000000000200"],
"createdAt": "2024-06-15T10:30:00.000Z",
"updatedAt": "2024-06-15T10:30:00.000Z"
}

Create Subscription Plan

POST /api/v1/subscription-plans

Creates a recurring purchase plan. Assign products by passing their UUIDs in products.

Request Body

FieldTypeRequiredDescription
namestringYesPlan display name, e.g. "Monthly delivery"
cadencestringYesBilling cadence unit: month or week
intervalnumberNoNumber of cadence units between charges (default: 1)
discountPercentnumberNoPercentage discount vs. one-time purchase (0-100). With a second step set, it covers only the first recurringDiscountAfterCycle orders
recurringDiscountPercentnumber | nullNoOptional second discount step (0-100) used from order recurringDiscountAfterCycle + 1 on. null removes the step
recurringDiscountAfterCyclenumberNoOrders, counting the checkout order, that get discountPercent before the second step applies (default: 1)
discountSteps{ afterCycle, percent }[] | nullNoEvery discount step after discountPercent, up to 10. Each percent (0-100) applies from order afterCycle + 1 (afterCycle 1-100). Replaces the two fields above, which then mirror the first step. null or [] removes every step
giftVariantIdstring | nullNoProduct variant UUID added free to renewal order giftOnOrder. null removes the gift
giftOnOrdernumber | nullNoThe order that carries the gift, counting the checkout order as 1 (2-100; 2 = the first renewal)
giftHiddenbooleanNoKeep the gift a surprise: the product page, checkout, the confirmation email and the customer account show "Surprise gift with order N" instead of the product. The renewal order that carries the gift lists it as a normal line. Removing the gift turns it off
descriptionstringNoOptional plan description
benefitsstringNoOptional plan benefits text
positionnumberNoSort order (lower shows first)
activebooleanNoWhether the plan is selectable (default: true)
productsstring[]NoProduct UUIDs offered on this plan (replaces the existing set)
curl -X POST \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{
"name": "Monthly delivery",
"cadence": "month",
"interval": 1,
"discountPercent": 10,
"products": ["0191abc0-0000-7000-8000-000000000200"]
}' \
https://your-store.yns.store/api/v1/subscription-plans

Response (201)

Returns the created subscription plan (same shape as Get Subscription Plan).


Update Subscription Plan

PATCH /api/v1/subscription-plans/{id}

Partially updates a subscription plan. Only provided fields change. Passing products replaces the entire assigned product set.

Request Body

All fields from Create Subscription Plan are accepted and optional.

curl -X PATCH \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{"discountPercent": 15, "active": false}' \
https://your-store.yns.store/api/v1/subscription-plans/0191abc0-1234-7def-8000-000000000001

Response (200)

Returns the updated subscription plan.


Delete Subscription Plan

DELETE /api/v1/subscription-plans/{id}

Hard-deletes the subscription plan by UUID.

curl -X DELETE \
-H "Authorization: Bearer your_api_key" \
https://your-store.yns.store/api/v1/subscription-plans/0191abc0-1234-7def-8000-000000000001

Response (200)

{
"ok": true,
"deleted": 1
}