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

# Create Swap

> Move funds between your own books using a firm quote from
`POST /fx/quotes` with `purpose: swap`. Requires `Idempotency-Key`.
The API key replaces the workspace PIN.




## OpenAPI

````yaml /openapi.yaml post /swaps
openapi: 3.1.0
info:
  title: Keette API
  version: 1.0.0
  description: |
    Public HTTP API for Keette workspaces. One base URL — live vs sandbox is
    selected by your API key (`sk_live_…` / `sk_test_…`).

    Endpoints are added as each implementation phase ships.
  contact:
    name: Keette Support
    email: talk@keette.com
servers:
  - url: https://20b9-41-90-209-232.ngrok-free.app/v1
    description: Local (ngrok)
  - url: https://api.keette.com/v1
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Account
    description: Identity for the authenticating API key
  - name: Balances
    description: Wallet books
  - name: Beneficiaries
    description: Payout recipients
  - name: Transactions
    description: Unified transaction index
  - name: FX
    description: Indicative rates and firm quotes
  - name: Catalog
    description: Payout corridors and relationships
  - name: Payouts
    description: Send money to a beneficiary
  - name: Payins
    description: Collect money into your books
  - name: Swaps
    description: FX between your own books
  - name: Events
    description: Durable event log for webhook polling
paths:
  /swaps:
    post:
      tags:
        - Swaps
      summary: Create Swap
      description: |
        Move funds between your own books using a firm quote from
        `POST /fx/quotes` with `purpose: swap`. Requires `Idempotency-Key`.
        The API key replaces the workspace PIN.
      operationId: createSwap
      parameters:
        - name: Idempotency-Key
          in: header
          required: true
          description: Client-generated key so retries do not create duplicate swaps.
          schema:
            type: string
            minLength: 1
            maxLength: 128
          example: swap-2026-10-27-001
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - quote_id
              properties:
                quote_id:
                  type: string
                  format: uuid
                  description: >
                    Id from `POST /fx/quotes` with `purpose: swap`. Must still
                    be

                    unexpired and unused.
                  example: e6bd10ee-6e53-4aaa-9cd0-a2bb980cf73e
            examples:
              swap:
                value:
                  quote_id: e6bd10ee-6e53-4aaa-9cd0-a2bb980cf73e
      responses:
        '200':
          description: Swap (processing, completed, or failed)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Swap'
              examples:
                processing:
                  value:
                    object: swap
                    id: 14d2759d-c6b1-5e5f-85b2-af84bc650f57
                    status: processing
                    origin: keette
                    from: USD
                    to: NGN
                    amount_from: 10000
                    amount_to: 1550000
                    scale_from: 2
                    scale_to: 2
                    fx_rate: '155.00'
                    quote_id: e6bd10ee-6e53-4aaa-9cd0-a2bb980cf73e
                    stan: SWP-2610-ABCDEF12
                    created_at: '2026-10-27T13:00:00Z'
                    updated_at: '2026-10-27T13:00:01Z'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  schemas:
    Swap:
      type: object
      required:
        - object
        - id
        - status
        - from
        - to
        - amount_from
        - amount_to
        - stan
      properties:
        object:
          type: string
          enum:
            - swap
          description: Object type discriminator.
        id:
          type: string
          format: uuid
          description: Swap id.
        status:
          type: string
          enum:
            - processing
            - completed
            - failed
            - reversed
          description: Lifecycle status of the book-to-book transfer.
        origin:
          type: string
          description: How the swap was initiated (`keette` for API/dashboard).
        from:
          type: string
          description: Debited book currency.
        to:
          type: string
          description: Credited book currency.
        amount_from:
          type: integer
          description: Debit amount in Ledger minor units.
        amount_to:
          type: integer
          description: Credit amount in Ledger minor units.
        scale_from:
          type: integer
          description: Decimal places for `from`.
        scale_to:
          type: integer
          description: Decimal places for `to`.
        fx_rate:
          type: string
          description: Applied rate as a decimal string.
        quote_id:
          type: string
          format: uuid
          description: Firm quote that locked the rate.
        reason:
          type: string
          description: Failure or reversal reason when applicable.
        stan:
          type: string
          description: System trace / reference shown in statements.
        created_at:
          type: string
          format: date-time
          description: Creation time (UTC).
        updated_at:
          type: string
          format: date-time
          description: Last status change (UTC).
        completed_at:
          type: string
          format: date-time
          description: When the swap finished successfully, if completed.
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - type
            - code
            - message
          properties:
            type:
              type: string
              description: Broad error class for client handling.
              enum:
                - invalid_request
                - authentication_error
                - permission_error
                - rate_limit
                - api_error
            code:
              type: string
              description: Stable machine-readable code (e.g. `parameter_invalid`).
            message:
              type: string
              description: Human-readable explanation safe to show developers.
            param:
              type: string
              description: Request field that failed validation, when applicable.
            doc_url:
              type: string
              format: uri
              description: Optional link to docs for this error.
  responses:
    Unauthorized:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              type: authentication_error
              code: invalid_api_key
              message: Invalid API key provided.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key
      description: |
        Secret API key from **Settings → Developers → API keys**.
        Example: `Authorization: Bearer sk_test_…`

````

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