Recur Subscriptions API
Subscription lifecycle - create, read and manage subscriptions
Subscription lifecycle - create, read and manage subscriptions
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/recur-tw:recur-tw-subscriptions-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: Recur Subscriptions API
version: 1.0.0
description: 'Recur is a subscription billing REST API for the Taiwan market. Amounts are whole-number TWD: 499 means NT$499, never cents.
## Authentication
Recur uses API keys, in two kinds:
- **Secret key** (`sk_xxx`): server side, full access
- **Publishable key** (`pk_xxx`): client side, limited access
### Environments
| Environment | Key prefix | Use |
|-------------|-----------|-----|
| Sandbox | `sk_test_` / `pk_test_` | testing |
| Production | `sk_live_` / `pk_live_` | live payments |
### Sending the key
Put the key in the request header:
```
Authorization: Bearer sk_test_xxx
```
or use the dedicated headers:
```
X-Recur-Secret-Key: sk_test_xxx
X-Recur-Publishable-Key: pk_test_xxx
```
## Field naming
Every REST response is snake_case: the v1 app runs the whole response through a conversion step, so `expires_at`, not `expiresAt`. Requests accept either case and are normalized on the way in; the request examples below use camelCase. The official SDK converts responses back to camelCase, so its types are camelCase and this spec is not.'
contact:
name: Recur Support
email: support@recur.tw
url: https://recur.tw
license:
name: Elastic License 2.0
url: https://www.elastic.co/licensing/elastic-license
servers:
- url: https://api.recur.tw/v1
description: Production
- url: http://localhost:3000/api/v1
description: Development
security:
- SecretKey: []
- SecretKeyHeader: []
- PublishableKey: []
- OAuth2:
- openid
- products:read
- orders:read
- subscriptions:read
- customers:read
- analytics:read
tags:
- name: Subscriptions
description: Subscription lifecycle - create, read and manage subscriptions
paths:
/subscriptions/{subscriptionId}/cancel:
post:
summary: Cancel a subscription
description: 'Cancel a subscription, at the end of the current period (the default) or now.
- **At period end** (`cancel_at_period_end: true`, or an empty body): the subscription
keeps its status (`ACTIVE` / `TRIAL`) until `current_period_end`, then
expires and is not renewed. `cancel_at_period_end` becomes `true` and `canceled_at` is set.
A `PAST_DUE` subscription has no period left to run out and answers `400`: cancel it
immediately.
- **Immediately** (`cancel_at_period_end: false`): irreversible. The status becomes
`CANCELED` now, the subscription leaves the renewal pipeline, its pending invoices are
voided and their payment intents cancelled, and a pending scheduled switch is cancelled.
A subscription already scheduled to cancel at period end can still be cancelled immediately.
Both send the `subscription.cancelled` webhook. The customer is not emailed.
The key must belong to the subscription''s organization and environment: a sandbox key
never sees a production subscription, and either case answers `404`.
Retrying is safe without an `Idempotency-Key`: a repeated cancel of the same subscription
changes nothing and answers `409 conflict`.'
operationId: cancelSubscription
tags:
- Subscriptions
security:
- SecretKey: []
- SecretKeyHeader: []
parameters:
- name: subscriptionId
in: path
required: true
description: Subscription ID
schema:
type: string
example: sub_abc123
requestBody:
required: false
content:
application/json:
schema:
$ref: '#/components/schemas/CancelSubscriptionRequest'
examples:
period_end:
summary: Cancel at period end (default)
value: {}
immediately:
summary: Cancel now, with a reason
value:
cancel_at_period_end: false
reason: too_expensive
comment: Moving to a cheaper plan
responses:
'200':
description: The subscription after the cancel
content:
application/json:
schema:
$ref: '#/components/schemas/Subscription'
example:
object: subscription
id: sub_abc123
status: ACTIVE
product:
id: cmfxq8n2a0002l8yzb4k7m2xq
slug: pro-monthly
name: Pro
price: 599
interval: month
interval_count: 1
customer:
id: cmfxq8n2a0009l8yzd1k2m3np
email: user@example.com
name: Wang Xiaoming
external_id: user_42
amount: 599
interval: month
interval_count: 1
current_period_start: '2025-01-15T10:30:00.000Z'
current_period_end: '2025-02-15T10:30:00.000Z'
cancel_at_period_end: true
canceled_at: '2025-01-20T08:00:00.000Z'
started_at: '2024-12-15T10:30:00.000Z'
trial_start: null
trial_end: null
coupon: null
promotion_code_id: null
discount_amount: 0
invoices: []
metadata: null
created_at: '2024-12-15T10:30:00.000Z'
livemode: false
'400':
description: '`bad_request`: invalid JSON, a status that cannot be cancelled (`PENDING`, `EXPIRED`), or a period-end cancel of a `PAST_DUE` subscription'
content:
application/json:
schema:
$ref: '#/components/schemas/CancelSubscriptionErrorResponse'
'401':
description: '`unauthorized`: no key, an invalid key, or a publishable key'
content:
application/json:
schema:
$ref: '#/components/schemas/CancelSubscriptionErrorResponse'
'404':
description: '`not_found`: no such subscription for this key''s organization and environment'
content:
application/json:
schema:
$ref: '#/components/schemas/CancelSubscriptionErrorResponse'
'409':
description: '`conflict`: already cancelled, already scheduled to cancel at period end (when asking for a period-end cancel again), or changed by a concurrent request'
content:
application/json:
schema:
$ref: '#/components/schemas/CancelSubscriptionErrorResponse'
'422':
description: '`validation_error`: a field has the wrong type or value, or the body has an unknown field'
content:
application/json:
schema:
$ref: '#/components/schemas/CancelSubscriptionErrorResponse'
components:
schemas:
Subscription:
type: object
description: A subscription with its product, customer and 10 most recent invoices
required:
- object
- id
- status
- product
- customer
- amount
- interval
- interval_count
- current_period_start
- current_period_end
- cancel_at_period_end
- created_at
- livemode
properties:
object:
type: string
enum:
- subscription
id:
type: string
status:
type: string
enum:
- PENDING
- TRIAL
- ACTIVE
- PAST_DUE
- CANCELED
- EXPIRED
product:
type: object
properties:
id:
type: string
slug:
type: string
nullable: true
name:
type: string
price:
type: integer
description: TWD, a whole number (499 is NT$499)
interval:
type: string
interval_count:
type: integer
customer:
type: object
properties:
id:
type: string
email:
type: string
name:
type: string
nullable: true
external_id:
type: string
nullable: true
amount:
type: integer
description: TWD, a whole number (499 is NT$499)
interval:
type: string
interval_count:
type: integer
current_period_start:
type: string
format: date-time
current_period_end:
type: string
format: date-time
cancel_at_period_end:
type: boolean
canceled_at:
type: string
format: date-time
nullable: true
started_at:
type: string
format: date-time
nullable: true
trial_start:
type: string
format: date-time
nullable: true
trial_end:
type: string
format: date-time
nullable: true
coupon:
type: object
nullable: true
properties:
id:
type: string
name:
type: string
discount_type:
type: string
discount_amount:
type: integer
duration:
type: string
duration_months:
type: integer
nullable: true
promotion_code_id:
type: string
nullable: true
discount_amount:
type: integer
description: Discount the coupon gives on the product price, in TWD
invoices:
type: array
description: The 10 most recent invoices
items:
type: object
properties:
id:
type: string
status:
type: string
amount:
type: integer
period_start:
type: string
format: date-time
period_end:
type: string
format: date-time
paid_at:
type: string
format: date-time
nullable: true
metadata:
type: object
nullable: true
additionalProperties: true
created_at:
type: string
format: date-time
livemode:
type: boolean
CancelSubscriptionErrorResponse:
type: object
required:
- error
properties:
error:
type: object
required:
- code
- message
properties:
code:
type: string
enum:
- bad_request
- unauthorized
- not_found
- conflict
- validation_error
- rate_limit_exceeded
- internal_server_error
message:
type: string
details:
type: array
description: For validation_error, one entry per failing field
items:
type: object
properties:
path:
type: string
message:
type: string
code:
type: string
CancellationReason:
type: string
enum:
- too_expensive
- missing_features
- switched_service
- unused
- customer_service
- other
description: Why the subscription was cancelled
CancelSubscriptionRequest:
type: object
additionalProperties: false
properties:
cancel_at_period_end:
type: boolean
default: true
description: '`true`: cancel at the end of the current period. `false`: cancel now (irreversible).'
reason:
$ref: '#/components/schemas/CancellationReason'
comment:
type: string
maxLength: 1000
description: Free-text cancellation comment
securitySchemes:
SecretKey:
type: http
scheme: bearer
description: 'Secret API key (`sk_xxx`) - server side, full access. Can set metadata.
'
PublishableKey:
type: apiKey
in: header
name: X-Recur-Publishable-Key
description: 'Publishable API key (`pk_xxx`) - client side, limited access. Cannot set metadata.
'
OAuth2:
type: oauth2
description: 'OAuth 2.1 (Authorization Code + PKCE) for AI agents and MCP clients.
Used by the Recur MCP server (https://mcp.recur.tw) so agents can request
least-privilege, scoped access on behalf of a user. Human-facing API
integrations should use `SecretKey`/`PublishableKey` instead.
Discovery: https://app.recur.tw/.well-known/openid-configuration
'
flows:
authorizationCode:
authorizationUrl: https://app.recur.tw/api/auth/oauth2/authorize
tokenUrl: https://app.recur.tw/api/auth/oauth2/token
refreshUrl: https://app.recur.tw/api/auth/oauth2/token
scopes:
openid: OpenID Connect authentication.
profile: Read the user's basic profile.
email: Read the user's email address.
org:read: Read organization details.
api-keys:read: List and read API keys.
api-keys:write: Create and revoke API keys.
products:read: Read products and pricing.
products:write: Create and update products.
integration:verify: Verify integration and connection status.
orders:read: Read orders and payment history.
subscriptions:read: Read subscriptions and their schedules.
customers:read: Read customer records.
analytics:read: Read revenue analytics (MRR, ARR, churn, LTV).
SecretKeyHeader:
type: apiKey
in: header
name: X-Recur-Secret-Key
description: 'Header form of the secret API key (`sk_xxx`); equivalent to `Authorization: Bearer sk_xxx`.
'