Recur Subscription Switching API

Plan switching API - upgrades, downgrades, period changes and crossgrades. ## Switch types | Type | Meaning | How it runs | |------|---------|-------------| | `UPGRADE` | to a higher-priced plan | immediately, with proration | | `DOWNGRADE` | to a lower-priced plan | scheduled for the end of the period | | `PERIOD_CHANGE` | change the billing period (monthly to yearly, or the reverse) | depends on the price direction | | `CROSSGRADE` | a different plan at the same price | immediately, no proration | ## Proration On an upgrade Recur computes: - **Credit**: refund for the unused days on the current plan - **Charge**: a full period on the new plan - **Net amount**: what the customer actually pays

GitHub OpenAPI

Operations 2

GET /subscriptions/{subscriptionId}/switch-preview Preview a plan switch #
POST /subscriptions/{subscriptionId}/switch Execute a plan switch #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • 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.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/recur-tw:recur-tw-subscription-switching-api"
All apis
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.

Get an API 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 Specification

recur-tw-subscription-switching-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Recur Subscription Switching 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: Subscription Switching
  description: 'Plan switching API - upgrades, downgrades, period changes and crossgrades.


    ## Switch types


    | Type | Meaning | How it runs |

    |------|---------|-------------|

    | `UPGRADE` | to a higher-priced plan | immediately, with proration |

    | `DOWNGRADE` | to a lower-priced plan | scheduled for the end of the period |

    | `PERIOD_CHANGE` | change the billing period (monthly to yearly, or the reverse) | depends on the price direction |

    | `CROSSGRADE` | a different plan at the same price | immediately, no proration |


    ## Proration


    On an upgrade Recur computes:

    - **Credit**: refund for the unused days on the current plan

    - **Charge**: a full period on the new plan

    - **Net amount**: what the customer actually pays'
paths:
  /subscriptions/{subscriptionId}/switch-preview:
    get:
      summary: Preview a plan switch
      description: 'Preview a switch to another plan. Nothing is changed.


        Use it to show the customer, before they commit:

        - the switch type (upgrade, downgrade, period change, crossgrade)

        - how it will run (immediately or scheduled)

        - proration details, when they apply

        - the new end of the billing period'
      operationId: getSwitchPreview
      tags:
      - Subscription Switching
      security:
      - SecretKey: []
      - SecretKeyHeader: []
      parameters:
      - name: subscriptionId
        in: path
        required: true
        description: Subscription ID
        schema:
          type: string
          example: sub_abc123
      - name: target_product_id
        in: query
        required: true
        description: Target product ID
        schema:
          type: string
          example: cmfxq8n2a0002l8yzb4k7m2xq
      responses:
        '200':
          description: Switch preview
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SwitchPreviewResponse'
              examples:
                upgrade:
                  summary: Upgrade preview
                  value:
                    object: switch_preview
                    subscription_id: sub_abc123
                    switch_type: UPGRADE
                    execution_mode: immediate
                    current_plan:
                      product_id: cmfxq8n2a0003l8yzc9p1n5rt
                      product_name: 基本版
                      amount: 299
                      currency: TWD
                      interval: month
                      interval_count: 1
                      monthly_equivalent: 299
                    new_plan:
                      product_id: cmfxq8n2a0002l8yzb4k7m2xq
                      product_name: 專業版
                      amount: 599
                      currency: TWD
                      interval: month
                      interval_count: 1
                      monthly_equivalent: 599
                    proration:
                      credit_amount: 150
                      charge_amount: 599
                      net_amount: 449
                      unused_days: 15
                      total_days_in_period: 30
                      credit_description: 15 unused days on 基本版
                    effective_date: '2025-01-15T10:30:00Z'
                    next_billing_date: '2025-02-15T10:30:00Z'
                    proration_behavior: create_prorations
                    requires_payment: true
                    can_proceed: true
                    blocking_reason: null
                    is_in_trial: false
                    trial_end: null
                downgrade:
                  summary: Downgrade preview (scheduled)
                  value:
                    object: switch_preview
                    subscription_id: sub_abc123
                    switch_type: DOWNGRADE
                    execution_mode: scheduled
                    current_plan:
                      product_id: cmfxq8n2a0002l8yzb4k7m2xq
                      product_name: 專業版
                      amount: 599
                      currency: TWD
                      interval: month
                      interval_count: 1
                      monthly_equivalent: 599
                    new_plan:
                      product_id: cmfxq8n2a0003l8yzc9p1n5rt
                      product_name: 基本版
                      amount: 299
                      currency: TWD
                      interval: month
                      interval_count: 1
                      monthly_equivalent: 299
                    proration: null
                    effective_date: '2025-02-01T00:00:00Z'
                    next_billing_date: '2025-03-01T00:00:00Z'
                    proration_behavior: none
                    requires_payment: false
                    can_proceed: true
                    blocking_reason: null
                    is_in_trial: false
                    trial_end: null
        '400':
          description: Invalid request, for example switching to the same product
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SwitchErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Subscription or product not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SwitchErrorResponse'
  /subscriptions/{subscriptionId}/switch:
    post:
      summary: Execute a plan switch
      description: 'Switch a subscription to another plan.


        How it runs follows the switch type:

        - **Upgrade / crossgrade**: immediately, with proration

        - **Downgrade / yearly-to-monthly period change**: scheduled for the end of the period


        An immediate switch that owes a difference creates an invoice.'
      operationId: executeSwitch
      tags:
      - Subscription Switching
      security:
      - SecretKey: []
      - SecretKeyHeader: []
      parameters:
      - name: subscriptionId
        in: path
        required: true
        description: Subscription ID
        schema:
          type: string
          example: sub_abc123
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExecuteSwitchRequest'
            examples:
              basic:
                summary: Basic switch
                value:
                  target_product_id: cmfxq8n2a0002l8yzb4k7m2xq
              with_proration:
                summary: With an explicit proration behavior
                value:
                  target_product_id: cmfxq8n2a0002l8yzb4k7m2xq
                  proration_behavior: create_prorations
      responses:
        '200':
          description: Switch executed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExecuteSwitchResponse'
              examples:
                immediate:
                  summary: Executed immediately (upgrade)
                  value:
                    object: switch_result
                    execution_mode: immediate
                    subscription:
                      id: sub_abc123
                      product_id: cmfxq8n2a0002l8yzb4k7m2xq
                      product_name: 專業版
                      status: ACTIVE
                      amount: 599
                      currency: TWD
                      interval: month
                      interval_count: 1
                      current_period_start: '2025-01-15T10:30:00Z'
                      current_period_end: '2025-02-15T10:30:00Z'
                      next_billing_date: '2025-02-15T10:30:00Z'
                      previous_product_id: cmfxq8n2a0003l8yzc9p1n5rt
                      switched_at: '2025-01-15T10:30:00Z'
                      switch_type: UPGRADE
                    invoice:
                      id: inv_xyz789
                      invoice_number: INV-2025-001
                      amount: 449
                      currency: TWD
                      status: PENDING
                      billing_reason: SUBSCRIPTION_UPDATE
                      billing_entries:
                      - id: entry_1
                        type: PRORATION_CREDIT
                        direction: CREDIT
                        amount: 150
                        description: 15 unused days on 基本版
                      - id: entry_2
                        type: PRORATION_DEBIT
                        direction: DEBIT
                        amount: 599
                        description: 專業版 - Full billing period
                    schedule: null
                    switch_type: UPGRADE
                    proration:
                      credit_amount: 150
                      charge_amount: 599
                      net_amount: 449
                      unused_days: 15
                      total_days_in_period: 30
                      credit_description: 15 unused days on 基本版
                    effective_date: '2025-01-15T10:30:00Z'
                scheduled:
                  summary: Scheduled (downgrade)
                  value:
                    object: switch_result
                    execution_mode: scheduled
                    subscription:
                      id: sub_abc123
                    invoice: null
                    schedule:
                      id: sched_abc123
                      target_product_id: cmfxq8n2a0003l8yzc9p1n5rt
                      target_product_name: 基本版
                      switch_type: DOWNGRADE
                      effective_at: '2025-02-01T00:00:00Z'
                      status: PENDING
                      created_at: '2025-01-15T10:30:00Z'
                    switch_type: DOWNGRADE
                    proration: null
                    effective_date: '2025-02-01T00:00:00Z'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SwitchErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Payment required, or the payment failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SwitchErrorResponse'
        '404':
          description: Subscription or product not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SwitchErrorResponse'
components:
  schemas:
    ScheduleStatus:
      type: string
      enum:
      - PENDING
      - EXECUTED
      - CANCELLED
      description: 'Schedule status:

        - `PENDING`: waiting to run

        - `EXECUTED`: already run

        - `CANCELLED`: cancelled

        '
    ProrationBehavior:
      type: string
      enum:
      - create_prorations
      - none
      - always_invoice
      description: 'Proration behavior:

        - `create_prorations`: create proration line items

        - `none`: no proration

        - `always_invoice`: always create an invoice

        '
    SwitchErrorResponse:
      type: object
      required:
      - error
      properties:
        error:
          type: object
          required:
          - code
          - message
          properties:
            code:
              type: string
              enum:
              - subscription_not_found
              - product_not_found
              - product_not_available
              - same_product
              - subscription_not_active
              - past_due_blocks_switch
              - trial_period_active
              - payment_failed
              - payment_required
              - schedule_already_exists
              - schedule_not_found
              - schedule_already_executed
              - schedule_already_cancelled
              - insufficient_permissions
              - no_pending_schedule
              - validation_error
              description: Switch error code
            message:
              type: string
              description: Error message
            details:
              type: object
              additionalProperties: true
              description: Additional error details
    PlanSummary:
      type: object
      required:
      - product_id
      - product_name
      - amount
      - currency
      - interval
      - interval_count
      - monthly_equivalent
      properties:
        product_id:
          type: string
          description: Product ID
        product_name:
          type: string
          description: Product name
        amount:
          type: integer
          description: 'Price. TWD is a whole-number integer: 499 means NT$499, not cents'
        currency:
          type: string
          description: Currency
        interval:
          type: string
          enum:
          - day
          - week
          - month
          - year
          description: Billing interval
        interval_count:
          type: integer
          description: Interval count
        monthly_equivalent:
          type: integer
          description: Monthly equivalent, for comparison
    ProrationDetails:
      type: object
      required:
      - credit_amount
      - charge_amount
      - net_amount
      - unused_days
      - total_days_in_period
      - credit_description
      properties:
        credit_amount:
          type: integer
          description: Credit for the unused days on the current plan
        charge_amount:
          type: integer
          description: Charge for a full period on the new plan
        net_amount:
          type: integer
          description: Net amount the customer pays
        unused_days:
          type: integer
          description: Days remaining on the current plan
        total_days_in_period:
          type: integer
          description: Total days in the billing period
        credit_description:
          type: string
          description: Credit description
    SwitchPreviewResponse:
      type: object
      required:
      - object
      - subscription_id
      - switch_type
      - execution_mode
      - current_plan
      - new_plan
      - effective_date
      - next_billing_date
      - proration_behavior
      - requires_payment
      - can_proceed
      properties:
        object:
          type: string
          enum:
          - switch_preview
        subscription_id:
          type: string
        switch_type:
          $ref: '#/components/schemas/SwitchType'
        execution_mode:
          $ref: '#/components/schemas/ExecutionMode'
        current_plan:
          $ref: '#/components/schemas/PlanSummary'
        new_plan:
          $ref: '#/components/schemas/PlanSummary'
        proration:
          $ref: '#/components/schemas/ProrationDetails'
          nullable: true
        effective_date:
          type: string
          format: date-time
          description: Effective date
        next_billing_date:
          type: string
          format: date-time
          description: Next billing date
        proration_behavior:
          $ref: '#/components/schemas/ProrationBehavior'
        requires_payment:
          type: boolean
          description: Whether a payment is required
        can_proceed:
          type: boolean
          description: Whether the switch can be executed
        blocking_reason:
          type: string
          nullable: true
          description: Why the switch is blocked, when it cannot run
        is_in_trial:
          type: boolean
          description: Whether the subscription is in its trial
        trial_end:
          type: string
          format: date-time
          nullable: true
          description: When the trial ends
    ExecuteSwitchRequest:
      type: object
      required:
      - target_product_id
      properties:
        target_product_id:
          type: string
          description: Target product ID
        proration_behavior:
          $ref: '#/components/schemas/ProrationBehavior'
          description: Proration behavior (optional; defaults to the merchant setting)
    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
    BillingEntry:
      type: object
      required:
      - id
      - type
      - direction
      - amount
      properties:
        id:
          type: string
        type:
          type: string
          enum:
          - CYCLE
          - PRORATION_CREDIT
          - PRORATION_DEBIT
          - ADJUSTMENT
        direction:
          type: string
          enum:
          - DEBIT
          - CREDIT
        amount:
          type: integer
        description:
          type: string
          nullable: true
    SwitchType:
      type: string
      enum:
      - UPGRADE
      - DOWNGRADE
      - PERIOD_CHANGE
      - CROSSGRADE
      description: 'Switch type:

        - `UPGRADE`: to a higher-priced plan

        - `DOWNGRADE`: to a lower-priced plan

        - `PERIOD_CHANGE`: change the billing period, for example monthly to yearly

        - `CROSSGRADE`: to a different plan at the same price

        '
    SwitchInvoice:
      type: object
      required:
      - id
      - invoice_number
      - amount
      - currency
      - status
      - billing_reason
      properties:
        id:
          type: string
        invoice_number:
          type: string
        amount:
          type: integer
        currency:
          type: string
        status:
          type: string
          enum:
          - PENDING
          - PAID
          - FAILED
          - VOIDED
        billing_reason:
          type: string
          enum:
          - SUBSCRIPTION_UPDATE
        billing_entries:
          type: array
          items:
            $ref: '#/components/schemas/BillingEntry'
    ScheduleSummary:
      type: object
      required:
      - id
      - target_product_id
      - switch_type
      - effective_at
      - status
      - created_at
      properties:
        id:
          type: string
        target_product_id:
          type: string
        target_product_name:
          type: string
          nullable: true
        switch_type:
          $ref: '#/components/schemas/SwitchType'
        effective_at:
          type: string
          format: date-time
        status:
          $ref: '#/components/schemas/ScheduleStatus'
        created_at:
          type: string
          format: date-time
    ExecutionMode:
      type: string
      enum:
      - immediate
      - scheduled
      description: 'How the switch runs:

        - `immediate`: right away

        - `scheduled`: at the end of the billing period

        '
    SubscriptionSummary:
      type: object
      required:
      - id
      - product_id
      - status
      - amount
      - currency
      - interval
      - interval_count
      - current_period_start
      - current_period_end
      properties:
        id:
          type: string
        product_id:
          type: string
        product_name:
          type: string
        status:
          type: string
          enum:
          - ACTIVE
          - TRIAL
          - PAST_DUE
          - CANCELLED
          - EXPIRED
        amount:
          type: integer
        currency:
          type: string
        interval:
          type: string
        interval_count:
          type: integer
        current_period_start:
          type: string
          format: date-time
        current_period_end:
          type: string
          format: date-time
        next_billing_date:
          type: string
          format: date-time
          nullable: true
        previous_product_id:
          type: string
          nullable: true
        switched_at:
          type: string
          format: date-time
          nullable: true
        switch_type:
          $ref: '#/components/schemas/SwitchType'
          nullable: true
    ExecuteSwitchResponse:
      type: object
      required:
      - object
      - execution_mode
      - subscription
      - switch_type
      - effective_date
      properties:
        object:
          type: string
          enum:
          - switch_result
        execution_mode:
          $ref: '#/components/schemas/ExecutionMode'
        subscription:
          $ref: '#/components/schemas/SubscriptionSummary'
        invoice:
          $ref: '#/components/schemas/SwitchInvoice'
          nullable: true
        schedule:
          $ref: '#/components/schemas/ScheduleSummary'
          nullable: true
        switch_type:
          $ref: '#/components/schemas/SwitchType'
        proration:
          $ref: '#/components/schemas/ProrationDetails'
          nullable: true
        effective_date:
          type: string
          format: date-time
  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`.

        '