> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blink.store/llms.txt
> Use this file to discover all available pages before exploring further.

# Update or swap a subscription

> Updates the status of a subscription, allowing actions such as cancelation, immediate cancelation, resumption, or executing a **swap** (upgrade/downgrade). To execute a swap, set `action` to `swap` and provide `variant_id` or `product_id` in the body.



## OpenAPI

````yaml patch /subscriptions/{id}
openapi: 3.0.0
info:
  title: Blink API
  description: Comprehensive API documentation for Blink.
  version: 1.0.0
servers:
  - url: https://api.blink.store/v1
security: []
paths:
  /subscriptions/{id}:
    patch:
      tags:
        - Subscriptions
      summary: Update or swap a subscription
      description: >-
        Updates the status of a subscription, allowing actions such as
        cancelation, immediate cancelation, resumption, or executing a **swap**
        (upgrade/downgrade). To execute a swap, set `action` to `swap` and
        provide `variant_id` or `product_id` in the body.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
        - name: x-store-id
          in: header
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubscriptionUpdateRequest'
      responses:
        '200':
          description: Subscription updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubscriptionDetailResponse'
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
        '404':
          description: Not Found
components:
  schemas:
    SubscriptionUpdateRequest:
      type: object
      properties:
        action:
          type: string
          enum:
            - cancel
            - cancel_immediately
            - resume
            - swap
        variant_id:
          type: string
          description: Required if action is swap
        product_id:
          type: string
          description: Required if action is swap
      required:
        - action
    SubscriptionDetailResponse:
      type: object
      properties:
        data:
          type: object
          properties:
            id:
              type: string
            store_id:
              type: string
            product_id:
              type: string
            variant_id:
              type: string
            status:
              type: string
            current_period_end:
              type: string
              format: date-time
            cancel_at_period_end:
              type: boolean
            metadata:
              type: object
            created_at:
              type: string
              format: date-time
            updated_at:
              type: string
              format: date-time
            stripe_subscription_id:
              type: string
            stripe_customer_id:
              type: string
            product:
              type: object
              properties:
                id:
                  type: string
                name:
                  type: string
                pricing_model:
                  type: string
                  enum:
                    - one_time
                    - subscription
                    - pay_what_you_want
                subscription_interval:
                  type: string
                  enum:
                    - day
                    - week
                    - month
                    - year
            variant:
              type: object
              properties:
                id:
                  type: string
                name:
                  type: string
                price:
                  type: integer
                subscription_interval:
                  type: string
                  enum:
                    - day
                    - week
                    - month
                    - year

````