Shop API

The Kaching Subscriptions REST API: its base URL, authentication, token permissions, rate limits and errors.

Subscriptions docs
On this page

Create rich subscription flows and streamline store operations on Shopify using our full-featured, enterprise-ready REST APIs.

Prerequisites

  • A Shopify store with the Kaching Subscriptions app installed
  • A Kaching Subscriptions API token (created in the app admin under Settings → Integrations → API)
  • The Advanced plan or higher — the API is not available on lower plans, and requests from a shop below it are rejected with 403 Unauthorized

Base URL

text
https://subscriptions.kachingappz.app/shop-api

All responses are JSON.

Authentication

Every request must include a Bearer token in the Authorization header:

http
Authorization: Bearer <your-api-token>

If the header is missing, malformed, or the token is unknown, the API responds with 401 Unauthorized:

json
{
  "error": "Unauthorized",
  "message": "Invalid token"
}

Permissions

A shop can have up to 10 API tokens, so each integration can have its own. The merchant creates them under Settings → Integrations → API, choosing Full access or Custom; for Custom they tick the permissions the token gets, grouped as below: each permission, its id, and the endpoints it opens. Ask for exactly the permissions the endpoints you call need.

Analytics

  • View analytics (analytics:read): GET /shop-api/analytics

Subscriptions

  • View contracts (contracts:read): GET /shop-api/contracts
  • Pause contracts (contracts:pause): POST /shop-api/contracts/pause
  • Resume contracts (contracts:resume): POST /shop-api/contracts/resume
  • Cancel contracts (contracts:cancel): POST /shop-api/contracts/cancel
  • Reactivate contracts (contracts:reactivate): POST /shop-api/contracts/reactivate

Upcoming orders

  • View billing cycles (contract_billing_cycles:read): GET /shop-api/contracts/billing-cycles and GET /shop-api/billing-cycles
  • Skip billing cycles (contract_billing_cycles:skip): POST /shop-api/contracts/billing-cycles/skip
  • Unskip billing cycles (contract_billing_cycles:unskip): POST /shop-api/contracts/billing-cycles/unskip
  • Reschedule billing cycles (contract_billing_cycles:reschedule): POST /shop-api/contracts/billing-cycles/reschedule

Line items

  • Add line items (contracts:add_line_item): POST /shop-api/contracts/add-line-item
  • Update line items (contracts:update_line_item): POST /shop-api/contracts/update-line-item
  • Remove line items (contracts:remove_line_item): POST /shop-api/contracts/remove-line-item
  • Add discounts (contracts:add_discount): POST /shop-api/contracts/add-discount

Selling plans

  • View plans (selling_plans:read): GET /shop-api/plans
  • Create plans (selling_plans:create): POST /shop-api/plans/create
  • Edit plans (selling_plans:update): POST /shop-api/plans/update, POST /shop-api/plans/add-products and POST /shop-api/plans/remove-products
  • Delete plans (selling_plans:delete): POST /shop-api/plans/delete, and a remove-products call that would leave a plan with no products (see Remove products from a plan)

GET /shop-api takes any valid token. The id in brackets is what a 403 reports as requiredScope.

A write permission does not include its read: a token that can pause contracts cannot list them unless it also has View contracts. The admin ticks the matching read when the merchant ticks a write, but they can untick it.

A Full access token can call every endpoint, including ones added later. Every token created before permissions existed has full access, so existing integrations keep working unchanged.

A valid token without the permission an endpoint needs gets 403 Forbidden. requiredScope names the missing permission by its id; the list above maps it to the name the merchant sees. The check runs before the rate limit, so a refused request does not count against it:

json
{
  "error": "Forbidden",
  "message": "insufficient_scope",
  "requiredScope": "contracts:pause"
}

Rate limiting

The API allows 60 requests per 60 seconds per shop. Requests over the limit receive 429 Too Many Requests:

json
{
  "toast": {
    "message": "Too many requests, please try again later.",
    "isError": true
  }
}

`GET /shop-api/analytics` carries its own, tighter budgets because a single call computes around twenty metrics. See Caching and rate limits.

The selling plan endpoints have budgets of their own too, per shop: GET /shop-api/plans 60 per minute; create, update and delete 20 per minute together; add-products and remove-products 60 per minute together. A refusal from these budgets also carries a Retry-After header (seconds).

List responses also include a throttle field reflecting the remaining Shopify GraphQL budget. When that budget drops below 1000, the API automatically delays the response by ~3 seconds to avoid tripping Shopify-side limits — design your integration to tolerate that latency.

Errors

StatusWhenExample body
400Missing or malformed request body (e.g. no contractId, or a pausedCycleCount that is not 1, 2 or 3) or invalid query parameter (e.g. email is not a valid address, or an analytics date range that is reversed or not a real date){ "error": "Missing contractId" }
400Product or variant ids that do not exist in this store (plan endpoints){ "error": "Unknown ids", "unknownIds": ["gid://shopify/ProductVariant/1"] }
401Missing, malformed, or unknown Bearer token{ "error": "Unauthorized", "message": "Invalid token" }
403The token lacks the endpoint's permission{ "error": "Forbidden", "message": "insufficient_scope", "requiredScope": "contracts:pause" }
403The shop is not on the Advanced plan or higher{ "error": "Unauthorized" }
403The line is a streak reward (line item endpoints){ "error": "This line item is a streak reward and cannot be changed" }
404No contract with that ID on this shop, no such line on the contract, or no such variant on this shop{ "error": "Line item not found on this subscription contract" }
404No plan with that ID on this shop (plan endpoints){ "error": "Plan not found" }
409The contract is being changed by something else; nothing was applied (line item endpoints){ "error": "The subscription is being updated, please try again" }
409The billing cycle's state or the requested date forbids the change (billing cycle endpoints){ "error": "This billing cycle has already been billed" }
409The contract is not cancelled, or has already been reactivated (reactivate){ "error": "Subscription has already been reactivated" }
409Another published plan has that merchantCode (plan create / update){ "error": "Conflict", "message": "plan_title_taken", "planIds": ["gid://shopify/SellingPlanGroup/123456"] }
409Live subscriptions are on the plan or option being removed; send force: true (plan endpoints){ "error": "Conflict", "message": "plan_has_subscriptions", "subscriptionCount": 3 }
422Shopify rejected the change, or the contract cannot be modified (add-discount, line item endpoints){ "error": "Cannot remove the last line item of a subscription contract" }
422The contract cannot be reactivated as it stands (reactivate){ "error": "Payment method has been revoked. Please add new payment method" }
422The contract cannot be paused for that pausedCycleCount (pause){ "error": "This pause length is not available for the subscription" }
429Rate limit exceeded (60 requests / 60 seconds per shop; different for `analytics`){ "toast": { "message": "Too many requests, please try again later.", "isError": true } }
500Upstream Shopify error or mutation failure{ "error": "Failed to pause subscription contract" }
503The contract's status could not be read from Shopify. Nothing was changed, so the request can be retried{ "error": "Couldn't read the subscription's status from Shopify, nothing was changed. Please try again" }

Mutation endpoints (pause, resume, cancel, reactivate, add-discount, add-line-item, update-line-item, remove-line-item, the billing-cycles/skip, billing-cycles/unskip and billing-cycles/reschedule endpoints, and the plan writes) surface Shopify-side validation messages in the error field when Shopify returns userErrors, so prefer showing the raw message to operators rather than masking it. A plan write refused by Shopify answers 400.

Can’t find what you need?

Ask the Kaching team about your integration in chat.