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

# Update a subscription

> Updates an existing subscription. Only payment method, cancel at period end flag, and metadata can be updated.



## OpenAPI

````yaml /api-reference/orchestrator-openapi.json patch /v1/subscriptions/{id}
openapi: 3.0.0
info:
  title: Payment Orchestrator API
  description: API documentation for the Payment Orchestrator service
  version: 1.0.0
servers:
  - url: https://api.sandbox.cheqpay.mx/pos
    description: Sandbox environment
  - url: https://prod.cheqpay.mx/pos
    description: Production environment
security:
  - ApiKeyAuth: []
    MerchantIdAuth: []
tags:
  - name: Customer
    description: Customer management endpoints (v1)
  - name: Customer V2
    description: >-
      Customer management endpoints (v2) - merchant-scoped, no external ID
      required
  - name: Payment Order
    description: Payment order management endpoints
  - name: Checkout
    description: Payment checkout endpoints
  - name: Payment Method
    description: Payment method management endpoints
  - name: Subscription Plan
    description: Subscription plan management endpoints for recurring payments
  - name: Subscription
    description: Subscription management endpoints for recurring billing
  - name: Subscription Invoice
    description: Subscription invoice management endpoints
paths:
  /v1/subscriptions/{id}:
    patch:
      tags:
        - Subscription
      summary: Update a subscription
      description: >-
        Updates an existing subscription. Only payment method, cancel at period
        end flag, and metadata can be updated.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Subscription unique identifier
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateSubscriptionRequest'
      responses:
        '200':
          description: Subscription updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubscriptionResponse'
        '400':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '404':
          description: Subscription or payment method not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalError'
components:
  schemas:
    UpdateSubscriptionRequest:
      type: object
      description: At least one field must be provided for update
      properties:
        paymentMethodId:
          type: string
          format: uuid
          description: New payment method ID for billing
          example: 123e4567-e89b-12d3-a456-426614174003
        cancelAtPeriodEnd:
          type: boolean
          description: Whether to cancel at the end of the current billing period
          example: true
        metadata:
          type: object
          additionalProperties: true
          nullable: true
          description: Additional metadata for the subscription
    SubscriptionResponse:
      type: object
      required:
        - id
        - merchantId
        - customerId
        - planId
        - paymentMethodId
        - status
        - currentPeriodStart
        - currentPeriodEnd
        - cancelAtPeriodEnd
        - nextBillingDate
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
          format: uuid
          description: Unique subscription identifier
          example: 123e4567-e89b-12d3-a456-426614174000
        merchantId:
          type: string
          description: Merchant identifier
          example: merchant_123
        customerId:
          type: string
          format: uuid
          description: Customer identifier
          example: 123e4567-e89b-12d3-a456-426614174001
        planId:
          type: string
          format: uuid
          description: Plan identifier
          example: 123e4567-e89b-12d3-a456-426614174002
        paymentMethodId:
          type: string
          format: uuid
          description: Payment method identifier
          example: 123e4567-e89b-12d3-a456-426614174003
        status:
          type: string
          enum:
            - TRIALING
            - ACTIVE
            - PAST_DUE
            - CANCELED
            - UNPAID
          description: Subscription status
          example: ACTIVE
        currentPeriodStart:
          type: string
          format: date-time
          description: Start of the current billing period
          example: '2025-01-01T00:00:00.000Z'
        currentPeriodEnd:
          type: string
          format: date-time
          description: End of the current billing period
          example: '2025-02-01T00:00:00.000Z'
        trialStart:
          type: string
          format: date-time
          nullable: true
          description: Trial period start date
          example: '2025-01-01T00:00:00.000Z'
        trialEnd:
          type: string
          format: date-time
          nullable: true
          description: Trial period end date
          example: '2025-01-15T00:00:00.000Z'
        cancelAtPeriodEnd:
          type: boolean
          description: Whether the subscription will cancel at period end
          example: false
        canceledAt:
          type: string
          format: date-time
          nullable: true
          description: When the subscription was canceled
          example: null
        endedAt:
          type: string
          format: date-time
          nullable: true
          description: When the subscription ended
          example: null
        nextBillingDate:
          type: string
          format: date-time
          description: >-
            Date of the next billing charge (trial end date while trialing,
            otherwise the current period end date)
          example: '2025-02-01T00:00:00.000Z'
        metadata:
          type: object
          additionalProperties: true
          nullable: true
          description: Additional metadata
        createdAt:
          type: string
          format: date-time
          description: Creation timestamp
          example: '2025-01-01T00:00:00.000Z'
        updatedAt:
          type: string
          format: date-time
          description: Last update timestamp
          example: '2025-01-15T10:00:00.000Z'
        plan:
          type: object
          description: Associated plan details
          properties:
            id:
              type: string
              format: uuid
              description: Plan identifier
            name:
              type: string
              description: Plan name
            amount:
              type: string
              description: Plan amount
            currency:
              type: string
              description: Plan currency
            interval:
              type: string
              enum:
                - DAY
                - WEEK
                - MONTH
                - YEAR
              description: Billing interval
            intervalCount:
              type: integer
              description: Number of intervals
    ValidationError:
      type: object
      description: Validation error response
      required:
        - message
        - errors
      properties:
        message:
          type: string
          description: Error message
          example: Validation failed
        errors:
          type: array
          description: List of validation errors
          items:
            type: object
            properties:
              field:
                type: string
                description: Field that failed validation
                example: name
              message:
                type: string
                description: Validation error message
                example: Required
      example:
        message: Validation failed
        errors:
          - field: name
            message: Required
    UnauthorizedError:
      type: object
      description: Unauthorized error response
      properties:
        message:
          type: string
          description: Error message
          example: Invalid api key
      example:
        message: Invalid api key
    NotFoundError:
      type: object
      description: Not found error response
      properties:
        message:
          type: string
          description: Error message
          example: Merchant not found
      example:
        message: Merchant not found
    InternalError:
      type: object
      description: Error response
      properties:
        message:
          type: string
          description: Error message
          example: Error message
      example:
        message: Error message
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for authentication (required)
    MerchantIdAuth:
      type: apiKey
      in: header
      name: x-merchant-id
      description: Merchant ID for identifying the merchant (required)

````