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

# Create Swap

> Execute a previously estimated swap.

Required flow:

1. Call ``estimate`` first — never skip this step.
2. Call this endpoint with the same ``src_asset``,
   ``dst_asset``, and the same one of ``req_spend_amount`` or
   ``req_get_amount`` used in ``estimate``. Also pass
   ``expected_price`` set to the ``estimated_price_exact``
   value returned by ``estimate`` — this provides slippage
   protection; if the market has moved beyond tolerance the
   swap is rejected, in which case re-estimate and retry.
3. On success, the response includes the swap
   ``id`` and an initial ``status`` of ``processing``. Check
   the retrieve operation with that ``id`` roughly once per
   second for up to 10 seconds until processing completes.



## OpenAPI

````yaml /openapi.json post /api/private/swaps/
openapi: 3.0.3
info:
  title: Digital Surge API
  version: '2.0'
  description: >-
    Digital Surge is an Australian cryptocurrency exchange. This API provides
    programmatic access to your account: live AUD pricing for hundreds of
    assets, instant swaps, recurring buys, price triggers, portfolio balances,
    transaction history, and crypto withdrawals.


    **Authentication** — create an API key in the Digital Surge app under
    *Account Settings → API Keys* and send it with every request:
    `Authorization: Bearer <your-api-key>`. Read-only and read & write keys are
    available.


    **Guides and interactive documentation** — https://digitalsurge.com.au/docs


    **AI agents** — connect via the Digital Surge MCP server:
    https://mcp.digitalsurge.com.au/mcp
servers:
  - url: https://app.digitalsurge.com.au
    description: Production
security: []
tags:
  - name: Public
    description: Unauthenticated endpoints — market data, asset info, pricing
  - name: Private
    description: Authenticated endpoints — trading, portfolio, account management
paths:
  /api/private/swaps/:
    post:
      tags:
        - Private
      summary: Create Swap
      description: |-
        Execute a previously estimated swap.

        Required flow:

        1. Call ``estimate`` first — never skip this step.
        2. Call this endpoint with the same ``src_asset``,
           ``dst_asset``, and the same one of ``req_spend_amount`` or
           ``req_get_amount`` used in ``estimate``. Also pass
           ``expected_price`` set to the ``estimated_price_exact``
           value returned by ``estimate`` — this provides slippage
           protection; if the market has moved beyond tolerance the
           swap is rejected, in which case re-estimate and retry.
        3. On success, the response includes the swap
           ``id`` and an initial ``status`` of ``processing``. Check
           the retrieve operation with that ``id`` roughly once per
           second for up to 10 seconds until processing completes.
      operationId: private_swaps_create
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SwapCreateRequest'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/SwapCreateRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/SwapCreateRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SwapCreate'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
          description: ''
      security:
        - bearerAuth: []
components:
  schemas:
    SwapCreateRequest:
      type: object
      description: >-
        A swap: a market-price trade of one asset directly for another (AUD →
        crypto is a buy, crypto → AUD a sell).
      properties:
        src_asset:
          type: string
          minLength: 1
          title: Source asset
        dst_asset:
          type: string
          minLength: 1
          title: Destination asset
        req_get_amount:
          type: string
          format: decimal
          nullable: true
          title: Requested amount to get
          description: Net amount, after subtracting the fee
        req_spend_amount:
          type: string
          format: decimal
          nullable: true
          title: Requested amount to spend
          description: Total amount, incl. the fee
        expected_price:
          type: string
          format: decimal
          nullable: true
          title: Expected price from user
      required:
        - dst_asset
        - src_asset
    SwapCreate:
      type: object
      description: >-
        A swap: a market-price trade of one asset directly for another (AUD →
        crypto is a buy, crypto → AUD a sell).
      properties:
        id:
          type: integer
          readOnly: true
        status:
          allOf:
            - $ref: '#/components/schemas/Status168Enum'
          readOnly: true
        src_asset:
          type: string
          title: Source asset
        dst_asset:
          type: string
          title: Destination asset
        req_get_amount:
          type: string
          format: decimal
          nullable: true
          title: Requested amount to get
          description: Net amount, after subtracting the fee
        req_spend_amount:
          type: string
          format: decimal
          nullable: true
          title: Requested amount to spend
          description: Total amount, incl. the fee
        expected_price:
          type: string
          format: decimal
          nullable: true
          title: Expected price from user
        bought_amount:
          type: string
          format: decimal
          readOnly: true
          nullable: true
          description: Final amount bought by the customer
        sold_amount:
          type: string
          format: decimal
          readOnly: true
          nullable: true
          description: Final amount sold by the customer
        src_fee:
          type: string
          format: decimal
          readOnly: true
          nullable: true
          title: Fee (sold asset)
        dst_fee:
          type: string
          format: decimal
          readOnly: true
          nullable: true
          title: Fee (bought asset)
      required:
        - bought_amount
        - dst_asset
        - dst_fee
        - id
        - sold_amount
        - src_asset
        - src_fee
        - status
    ErrorMessage:
      type: object
      description: >-
        Reusable serializer for endpoints that return {"message": "..."} on
        error.
      properties:
        message:
          type: string
      required:
        - message
    Status168Enum:
      enum:
        - 5
        - 10
        - 12
        - 15
        - 20
        - 40
        - 60
      type: integer
      description: |-
        * `5` - quote
        * `10` - pending
        * `12` - estimated
        * `15` - processing
        * `20` - error
        * `40` - rejected
        * `60` - processed
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Personal API key, created in the Digital Surge app under Account
        Settings → API Keys. Send it with every request as `Authorization:
        Bearer <your-api-key>`.

````