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

# Expire a checkout session

> Closes an open page before its time, when the order was canceled on your side. The customer sees the page as expired and is offered `cancel_url`; a `checkout_session.expired` event is emitted. While the customer is paying on the page the session cannot be closed: the call answers `409` with `checkout_session_payment_in_flight`, and once that payment has succeeded or failed you can retrieve the session and try again.



## OpenAPI

````yaml /api-reference/openapi-v1.json post /checkout-sessions/{id}/expire
openapi: 3.1.0
info:
  title: Payra API
  version: v1
  description: >-
    The Payra API. Authenticate with a secret key: `Authorization: Bearer
    sk_test_...`. The two payment method session endpoints Payra Elements calls
    also take a publishable key with the session's `client_secret`.
servers:
  - url: https://api-dashboard.payra.com/v1
    description: 'Sandbox and live: the key decides which'
security: []
paths:
  /checkout-sessions/{id}/expire:
    post:
      tags:
        - Checkout sessions
      summary: Expire a checkout session
      description: >-
        Closes an open page before its time, when the order was canceled on your
        side. The customer sees the page as expired and is offered `cancel_url`;
        a `checkout_session.expired` event is emitted. While the customer is
        paying on the page the session cannot be closed: the call answers `409`
        with `checkout_session_payment_in_flight`, and once that payment has
        succeeded or failed you can retrieve the session and try again.
      parameters:
        - schema:
            type: string
            minLength: 1
            maxLength: 64
          required: true
          name: id
          in: path
      responses:
        '200':
          description: The expired session
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutSession'
        '400':
          description: The session already completed or expired
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Missing, invalid or revoked API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: The API is not enabled for the workspace, or the key lacks the scope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: No such session in this workspace
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: A payment on the page is still in progress
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded; see Retry-After
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    CheckoutSession:
      type: object
      properties:
        object:
          type: string
          enum:
            - checkout_session
        id:
          type: string
          example: cs_test_7Hs2kQ9mL1pXv4cR8tWzAbCd
        status:
          type: string
          enum:
            - open
            - complete
            - expired
          example: open
          description: >-
            `open` while the customer can pay; `complete` once one payment
            succeeded (or, for a bank debit, was accepted) on the page;
            `expired` after `expires_at`, or once you expired it. A session pays
            once.
        amount:
          type: integer
          example: 12550
          description: In the smallest unit of the currency (cents).
        currency:
          type: string
          enum:
            - USD
            - CAD
          example: USD
        reference:
          type:
            - string
            - 'null'
          example: '1042'
        description:
          type:
            - string
            - 'null'
          example: 'Northwind order #1042'
        success_url:
          type: string
          example: https://shop.example/thanks?order=1042
        cancel_url:
          type: string
          example: https://shop.example/cart
        customer_email:
          type:
            - string
            - 'null'
          example: ana@example.com
        customer:
          type:
            - string
            - 'null'
          example: null
        payment_method_types:
          type: array
          items:
            type: string
            enum:
              - card
              - us_bank_account
          example:
            - card
        metadata:
          $ref: '#/components/schemas/CheckoutSessionMetadata'
        payment:
          type:
            - string
            - 'null'
          example: pay_test_7Hs2kQ9mL1pXv4cR8tWzAbCdEf
          description: >-
            The payment made on the page, once the session is `complete`; read
            it at `GET /payments/{id}`.
        livemode:
          type: boolean
          example: false
        expires_at:
          type: string
          example: '2026-09-26T12:00:00.000Z'
        completed_at:
          type:
            - string
            - 'null'
          example: null
        created_at:
          type: string
          example: '2026-09-25T12:00:00.000Z'
      required:
        - object
        - id
        - status
        - amount
        - currency
        - reference
        - description
        - success_url
        - cancel_url
        - customer_email
        - customer
        - payment_method_types
        - metadata
        - payment
        - livemode
        - expires_at
        - completed_at
        - created_at
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              type: string
              enum:
                - invalid_request_error
                - authentication_error
                - permission_error
                - rate_limit_error
                - idempotency_error
                - card_error
                - api_error
            code:
              type: string
            message:
              type: string
            param:
              type: string
            request_id:
              type: string
          required:
            - type
            - code
            - message
            - request_id
          additionalProperties:
            type: string
      required:
        - error
    CheckoutSessionMetadata:
      type:
        - object
        - 'null'
      additionalProperties:
        type: string
        maxLength: 500
      description: >-
        Up to 20 keys of your own (keys up to 40 characters, values up to 500);
        stored and returned, never interpreted.
      example:
        order_id: '1042'
        cart: a1b2c3
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        A secret key, `sk_test_...` or `sk_live_...`; a publishable key
        (`pk_...`) on the browser routes only

````