Recur Checkout Sessions API
Hosted Checkout Sessions API - create and read hosted checkout sessions. Redirects the customer to a Recur-hosted checkout page.
Hosted Checkout Sessions API - create and read hosted checkout sessions. Redirects the customer to a Recur-hosted checkout page.
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-checkout-sessions-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 Checkout Sessions 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: Checkout Sessions
description: 'Hosted Checkout Sessions API - create and read hosted checkout sessions.
Redirects the customer to a Recur-hosted checkout page.'
paths:
/checkout/sessions:
post:
summary: Create a checkout session
description: 'Create a checkout session and redirect the customer to the hosted checkout page.
Creates the order and the payment intent (a setup intent in SETUP mode) for you,
and returns the checkout page URL.'
operationId: createCheckoutSession
tags:
- Checkout Sessions
security:
- SecretKey: []
- SecretKeyHeader: []
- PublishableKey: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateCheckoutSessionRequest'
examples:
payment:
summary: One-time payment
value:
productId: cmfxq8n2a0001l8yz3k5p9t7d
mode: PAYMENT
successUrl: https://example.com/success?session_id={CHECKOUT_SESSION_ID}
cancelUrl: https://example.com/cancel
subscription:
summary: Subscription checkout
value:
productId: cmfxq8n2a0001l8yz3k5p9t7d
mode: SUBSCRIPTION
successUrl: https://example.com/welcome
cancelUrl: https://example.com/pricing
customerEmail: user@example.com
setup:
summary: Save a card only
value:
productId: cmfxq8n2a0001l8yz3k5p9t7d
mode: SETUP
successUrl: https://example.com/card-saved
cancelUrl: https://example.com/settings
responses:
'201':
description: Checkout session created
content:
application/json:
schema:
$ref: '#/components/schemas/CreateCheckoutSessionResponse'
example:
id: cs_abc123xyz
url: https://checkout.recur.tw/cs_abc123xyz
expires_at: '2025-01-01T00:30:00Z'
amount: 499
requires_payment_method: true
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'401':
description: Unauthorized - the API key is missing or invalid
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Product not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
parameters:
- $ref: '#/components/parameters/IdempotencyKey'
/checkout/sessions/{id}:
get:
summary: Retrieve a checkout session
description: 'Retrieve a checkout session.
Use it to check the session status after the customer returns.'
operationId: getCheckoutSession
tags:
- Checkout Sessions
security:
- SecretKey: []
- SecretKeyHeader: []
parameters:
- name: id
in: path
required: true
description: Checkout Session ID
schema:
type: string
example: cs_abc123xyz
responses:
'200':
description: Checkout session details
content:
application/json:
schema:
$ref: '#/components/schemas/CheckoutSession'
'404':
description: Session not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/checkout/sessions/{id}/expire:
post:
summary: Expire a checkout session
description: 'Expire an open checkout session so the customer can no longer pay through it.
Its payment intent and pending order are cancelled. Expiring an already expired session succeeds again.
Refused with 409 when the session is complete or its payment has started (processing, or waiting on 3D Secure).
Requires a secret key.'
operationId: expireCheckoutSession
tags:
- Checkout Sessions
security:
- SecretKey: []
- SecretKeyHeader: []
parameters:
- name: id
in: path
required: true
description: Checkout Session ID
schema:
type: string
example: cs_abc123xyz
responses:
'200':
description: The expired checkout session
content:
application/json:
schema:
$ref: '#/components/schemas/CheckoutSession'
'401':
description: Missing or publishable key
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Session not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'409':
description: The session is complete, or its payment has started
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
components:
schemas:
CreateCheckoutSessionRequest:
type: object
required:
- successUrl
- cancelUrl
anyOf:
- required:
- productId
- required:
- productSlug
description: 'Identify the product by `productId` or `productSlug`; at least one is required.
When both are sent, `productId` wins.
'
properties:
productId:
type: string
description: Product ID, a CUID returned by the API
example: cmfxq8n2a0001l8yz3k5p9t7d
productSlug:
type: string
description: 'Product slug, the URL-safe name chosen when the product was created.
An alternative to `productId`.
'
example: pro-monthly
mode:
type: string
enum:
- PAYMENT
- SUBSCRIPTION
- SETUP
default: PAYMENT
description: 'Checkout mode:
- `PAYMENT`: one-time payment
- `SUBSCRIPTION`: subscription, binds the card
- `SETUP`: save the card only, no charge
'
successUrl:
type: string
format: uri
description: 'Redirect URL after a successful payment. HTTPS is required in production.
For local development the API also accepts `http://` on `localhost`, `127.0.0.1`
and any `.local`, `.test` or `.dev` host.
Supports the `{CHECKOUT_SESSION_ID}` placeholder.
'
example: https://example.com/success?session_id={CHECKOUT_SESSION_ID}
cancelUrl:
type: string
format: uri
description: 'Redirect URL when the customer cancels. HTTPS is required in production; the same
local-development hosts allowed for `successUrl` are accepted here.
'
example: https://example.com/cancel
customerEmail:
type: string
format: email
description: 'Pre-fill the customer''s email (optional).
When omitted, the customer enters it on the checkout page.
An email is always required to complete checkout, for the receipt.
'
example: user@example.com
customerName:
type: string
description: 'Pre-fill the customer''s name (optional).
When omitted, the customer can enter it on the checkout page.
'
example: 王小明
promotionCode:
type: string
description: 'Promotion code to apply up front (optional).
The discount is calculated at creation and recorded on the session and the order.
'
example: SUMMER20
collectPaymentMethod:
type: string
enum:
- always
- if_required
default: always
description: 'When to collect a card:
- `always` (default): ask for a card even at NT$0, with an NT$2 verification charge
- `if_required`: skip the card at NT$0 and complete the subscription directly
'
metadata:
type: object
additionalProperties: true
description: Custom metadata (secret key only)
ErrorResponse:
type: object
required:
- error
properties:
error:
type: object
required:
- code
- message
properties:
code:
type: string
enum:
- invalid_request
- resource_not_found
- unauthorized
- forbidden
- internal_error
description: Error code
message:
type: string
description: Error message
details:
type: object
additionalProperties: true
description: Additional error details
CreateCheckoutSessionResponse:
type: object
required:
- id
- url
- expires_at
- amount
- requires_payment_method
properties:
id:
type: string
description: Checkout Session ID
example: cs_abc123xyz
url:
type: string
format: uri
description: Hosted checkout page URL
example: https://checkout.recur.tw/cs_abc123xyz
expires_at:
type: string
format: date-time
description: When the session expires (30 minutes after creation)
example: '2025-01-01T00:30:00Z'
amount:
type: integer
description: Amount actually charged after discount (whole TWD)
example: 0
requires_payment_method:
type: boolean
description: 'Whether a card is required. Derived from `collectPaymentMethod` and the amount:
- `always` → always `true`
- `if_required` with amount > 0 → `true`
- `if_required` with amount = 0 → `false`
'
example: true
client_secret:
type: string
description: PaymentIntent client secret, used by the client SDK to poll status safely
example: pi_secret_abc123
discount:
type: object
description: Discount details, present only when a promotion code was applied
properties:
code:
type: string
description: Promotion code
coupon_id:
type: string
description: Coupon ID
coupon_name:
type: string
description: Coupon name
discount_type:
type: string
enum:
- PERCENTAGE
- FIXED_AMOUNT
- FIRST_PERIOD_PRICE
discount_amount:
type: integer
description: Discount amount (whole TWD)
final_amount:
type: integer
description: Amount after discount
original_amount:
type: integer
description: Original price
CheckoutSession:
type: object
required:
- id
- status
- mode
- amount_total
- currency
- product
- created_at
properties:
id:
type: string
example: cs_abc123xyz
status:
type: string
enum:
- OPEN
- COMPLETE
- EXPIRED
description: 'Session status:
- `OPEN`: awaiting payment
- `COMPLETE`: paid
- `EXPIRED`: expired
'
mode:
type: string
enum:
- PAYMENT
- SUBSCRIPTION
- SETUP
customer_email:
type: string
format: email
nullable: true
description: Customer email
customer_name:
type: string
nullable: true
description: Customer name
order_id:
type: string
nullable: true
description: ID of the created order
subscription_id:
type: string
nullable: true
description: ID of the created subscription (SUBSCRIPTION mode only)
payment_intent_id:
type: string
nullable: true
description: PaymentIntent ID
amount_total:
type: integer
description: 'Total amount. TWD is a whole-number integer: 499 means NT$499, not cents'
example: 499
currency:
type: string
example: TWD
product:
type: object
properties:
id:
type: string
name:
type: string
expires_at:
type: string
format: date-time
created_at:
type: string
format: date-time
completed_at:
type: string
format: date-time
nullable: true
parameters:
IdempotencyKey:
name: Idempotency-Key
in: header
required: false
description: Stripe-style idempotency key for POSTs. Optional; Recur generates one when omitted. The legacy alias X-Idempotency-Key is also accepted.
schema:
type: string
example: order_12345_checkout
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`.
'