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

# Swap Customer IDs

> Atomically exchanges the IDs of two customers. Plans, entities, balances and payment-processor links stay with each underlying customer, so afterwards each ID owns what the other ID had.

Atomically exchanges the IDs of two customers. Nothing else moves: plans, entities, balances, invoices and Stripe links stay with each underlying customer. If `cus_a` has Pro and `cus_b` has Premium, after the swap `cus_a` has Premium and `cus_b` has Pro.

Stripe, Vercel Marketplace and webhooks keep working unchanged, because they're linked to the underlying customer rather than its ID.

> [!WARNING]
>
> Customers linked to RevenueCat can't be swapped. The request is rejected with a `400` if either customer has a RevenueCat subscription or identity.

> [!WARNING]
>
> Every customer JWT minted for either customer is revoked. Requests with those tokens return `401`, so mint new tokens for both customers after the swap.

> [!NOTE]
>
> Only one swap can run per customer at a time. A swap that touches a customer already being swapped is rejected with a `423`; retry it once the first swap finishes.

### Body Parameters

ID of the first customer

ID of the customer whose ID is exchanged with the first customer's

### Response


## OpenAPI

````yaml openapi POST /v1/customers.swap
openapi: 3.1.0
info:
  title: Autumn API
  version: 2.6.0
servers:
  - url: https://api.useautumn.com
    description: Production server
security:
  - secretKey: []
paths:
  /v1/customers.swap:
    post:
      tags:
        - customers
      description: >-
        Atomically exchanges the IDs of two customers. Plans, entities, balances
        and payment-processor links stay with each underlying customer, so
        afterwards each ID owns what the other ID had.
      operationId: swapCustomers
      parameters:
        - name: x-api-version
          in: header
          required: true
          schema:
            type: string
            default: 2.6.0
          x-speakeasy-globals-hidden: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                customer_id:
                  type: string
                  title: CustomerId
                  description: ID of the first customer
                swap_with_customer_id:
                  type: string
                  title: CustomerId
                  description: >-
                    ID of the customer whose ID is exchanged with the first
                    customer's
              required:
                - customer_id
                - swap_with_customer_id
              title: SwapCustomerParams
              examples:
                - customer_id: cus_123
                  swap_with_customer_id: cus_456
            example:
              customer_id: cus_123
              swap_with_customer_id: cus_456
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                required:
                  - success
      x-codeSamples:
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { Autumn } from 'autumn-js'

            const autumn = new Autumn()

            const result = await autumn.customers.swap({
              customerId: "cus_123",
              swapWithCustomerId: "cus_456",
            });
        - lang: python
          label: Python (SDK)
          source: |-
            from autumn_sdk import Autumn

            autumn = Autumn(secret_key="am_sk_test...")

            res = autumn.customers.swap(
                customer_id="cus_123",
                swap_with_customer_id="cus_456",
            )
components:
  securitySchemes:
    secretKey:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.