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

# Execute a routed order

> Authorizes the payment of an order from POST /v1/routed-orders, with your signature over its `typed_data` or with Lean’s delegated signer, and starts the route. Call it before the payment expires.



## OpenAPI

````yaml api-reference/openapi.json POST /routed-orders/{id}/execute
openapi: 3.0.0
info:
  title: Lean API
  version: 0.1.0
  description: >-
    Programmatic access to Lean: canonical sports markets, quotes, orders,
    positions and balances.
servers:
  - url: '{baseUrl}/v1'
    description: Lean API
    variables:
      baseUrl:
        default: https://api.lean.xyz
        description: >-
          The Lean API base URL, without /v1. Same value as LEAN_API_URL in the
          guides.
security:
  - apiKey: []
paths:
  /routed-orders/{id}/execute:
    post:
      tags:
        - Orders
      summary: Execute a routed order
      description: >-
        Authorizes the payment of an order from POST /v1/routed-orders, with
        your signature over its `typed_data` or with Lean’s delegated signer,
        and starts the route. Call it before the payment expires.
      operationId: executeRoutedOrder
      parameters:
        - schema:
            type: string
            format: uuid
            example: 8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1
          required: true
          name: id
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - type: object
                  properties:
                    authorization:
                      type: string
                      enum:
                        - signature
                    payment_signature:
                      type: string
                      pattern: ^0x[a-fA-F0-9]{130}$
                      description: >-
                        EIP-712 signature over `payment.typed_data`, by
                        `payment.signer_address`.
                    agent_approval_signature:
                      type: string
                      pattern: ^0x[a-fA-F0-9]{130}$
                      description: >-
                        Signature over `payment.agent_approval`, when the
                        payment carries one.
                  required:
                    - authorization
                    - payment_signature
                - type: object
                  properties:
                    authorization:
                      type: string
                      enum:
                        - delegated
                  required:
                    - authorization
            example:
              authorization: signature
              payment_signature: >-
                0xababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab
      responses:
        '200':
          description: >-
            The order once its payment is accepted, with payment null. A test
            order is filled; a live order stays pending while the router moves
            the payment. Sending the same authorization again returns the
            current order
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      success:
                        type: boolean
                        enum:
                          - true
                      data:
                        type: object
                        properties:
                          id:
                            type: string
                            format: uuid
                          client_order_id:
                            type: string
                            minLength: 1
                          market_id:
                            type: string
                            minLength: 1
                            description: >-
                              The market id from GET /markets, however the
                              request named the market.
                          title:
                            type: string
                            nullable: true
                            minLength: 1
                          outcome:
                            type: string
                            nullable: true
                            minLength: 1
                          venue:
                            type: string
                            nullable: true
                            enum:
                              - kalshi
                              - polymarket
                              - polymarket_us
                              - hyperliquid
                          ticker:
                            type: string
                            nullable: true
                            minLength: 1
                          side:
                            type: string
                            nullable: true
                            enum:
                              - 'yes'
                              - 'no'
                          action:
                            type: string
                            enum:
                              - buy
                              - sell
                          type:
                            type: string
                            enum:
                              - limit
                              - market
                          time_in_force:
                            type: string
                            enum:
                              - gtc
                              - ioc
                              - fok
                              - gtd
                          expires_at:
                            type: string
                            nullable: true
                            format: date-time
                          quantity:
                            type: string
                            pattern: ^\d+(?:\.\d+)?$
                          filled_quantity:
                            type: string
                            pattern: ^\d+(?:\.\d+)?$
                          remaining_quantity:
                            type: string
                            pattern: ^\d+(?:\.\d+)?$
                            description: >-
                              Shares still working on the venues: the unfilled
                              size of each live venue order. Zero once the order
                              is final, since a canceled, expired or rejected
                              remainder no longer works.
                          limit_price:
                            type: string
                          avg_fill_price:
                            type: string
                            nullable: true
                            description: >-
                              Average price per share filled, size-weighted
                              across the venue orders that filled, excluding
                              fees. Null until every filled venue order has a
                              price.
                          notional_usd:
                            type: string
                            pattern: ^\d+(?:\.\d+)?$
                          filled_notional_usd:
                            type: string
                            nullable: true
                            pattern: ^\d+(?:\.\d+)?$
                          status:
                            type: string
                            enum:
                              - pending
                              - open
                              - partially_filled
                              - filled
                              - canceled
                              - rejected
                              - expired
                              - unconfirmed
                              - needs_attention
                              - cancel_requested
                          venue_status:
                            type: string
                            nullable: true
                          venue_order_id:
                            type: string
                            nullable: true
                          status_reason:
                            type: object
                            nullable: true
                            properties:
                              code:
                                type: string
                                minLength: 1
                              message:
                                type: string
                                minLength: 1
                            required:
                              - code
                              - message
                          legs:
                            type: array
                            items:
                              type: object
                              properties:
                                venue:
                                  type: string
                                  enum:
                                    - kalshi
                                    - polymarket
                                    - polymarket_us
                                    - hyperliquid
                                ticker:
                                  type: string
                                  minLength: 1
                                side:
                                  type: string
                                  enum:
                                    - 'yes'
                                    - 'no'
                                quantity:
                                  type: string
                                  pattern: ^\d+(?:\.\d+)?$
                                filled_quantity:
                                  type: string
                                  pattern: ^\d+(?:\.\d+)?$
                                limit_price:
                                  type: string
                                avg_fill_price:
                                  type: string
                                  nullable: true
                                status:
                                  type: string
                                  enum:
                                    - pending
                                    - open
                                    - partially_filled
                                    - filled
                                    - canceled
                                    - rejected
                                    - expired
                                    - unconfirmed
                                    - needs_attention
                                    - cancel_requested
                                venue_status:
                                  type: string
                                  nullable: true
                                venue_order_id:
                                  type: string
                                  nullable: true
                                cancel_requested_at:
                                  type: string
                                  nullable: true
                                  format: date-time
                                status_reason:
                                  type: object
                                  nullable: true
                                  properties:
                                    code:
                                      type: string
                                      minLength: 1
                                    message:
                                      type: string
                                      minLength: 1
                                  required:
                                    - code
                                    - message
                              required:
                                - venue
                                - ticker
                                - side
                                - quantity
                                - filled_quantity
                                - limit_price
                                - avg_fill_price
                                - status
                                - venue_status
                                - venue_order_id
                                - cancel_requested_at
                                - status_reason
                          post_only:
                            type: boolean
                          replaces_order_id:
                            type: string
                            nullable: true
                            format: uuid
                          replaced_by_order_id:
                            type: string
                            nullable: true
                            format: uuid
                          created_at:
                            type: string
                            format: date-time
                          updated_at:
                            type: string
                            format: date-time
                          livemode:
                            type: boolean
                          route:
                            type: object
                            properties:
                              funding_venue:
                                type: string
                                enum:
                                  - polymarket
                                  - hyperliquid
                              execution_venue:
                                type: string
                                enum:
                                  - polymarket
                                  - hyperliquid
                              notional_usd:
                                type: string
                                pattern: ^\d+(?:\.\d+)?$
                              costs:
                                type: object
                                properties:
                                  rebalance_fee_usd:
                                    type: string
                                    pattern: ^\d+(?:\.\d+)?$
                                  gas_usd:
                                    type: string
                                    pattern: ^\d+(?:\.\d+)?$
                                  activation_fee_usd:
                                    type: string
                                    pattern: ^\d+(?:\.\d+)?$
                                  network_cost_usd:
                                    type: string
                                    pattern: ^\d+(?:\.\d+)?$
                                required:
                                  - rebalance_fee_usd
                                  - gas_usd
                                  - activation_fee_usd
                                  - network_cost_usd
                            required:
                              - funding_venue
                              - execution_venue
                              - notional_usd
                              - costs
                          payment:
                            oneOf:
                              - type: object
                                properties:
                                  scheme:
                                    type: string
                                    enum:
                                      - hyperliquid_send_asset
                                  signer_address:
                                    type: string
                                    pattern: ^0x[a-fA-F0-9]{40}$
                                  typed_data:
                                    type: object
                                    properties:
                                      domain:
                                        type: object
                                        properties:
                                          name:
                                            type: string
                                            enum:
                                              - HyperliquidSignTransaction
                                          version:
                                            type: string
                                            enum:
                                              - '1'
                                          chainId:
                                            type: number
                                            enum:
                                              - 421614
                                          verifyingContract:
                                            type: string
                                            enum:
                                              - >-
                                                0x0000000000000000000000000000000000000000
                                        required:
                                          - name
                                          - version
                                          - chainId
                                          - verifyingContract
                                      types:
                                        type: object
                                        properties:
                                          HyperliquidTransaction:SendAsset:
                                            type: array
                                            items:
                                              anyOf:
                                                - type: object
                                                  properties:
                                                    name:
                                                      type: string
                                                      enum:
                                                        - hyperliquidChain
                                                    type:
                                                      type: string
                                                      enum:
                                                        - string
                                                  required:
                                                    - name
                                                    - type
                                                - type: object
                                                  properties:
                                                    name:
                                                      type: string
                                                      enum:
                                                        - destination
                                                    type:
                                                      type: string
                                                      enum:
                                                        - string
                                                  required:
                                                    - name
                                                    - type
                                                - type: object
                                                  properties:
                                                    name:
                                                      type: string
                                                      enum:
                                                        - sourceDex
                                                    type:
                                                      type: string
                                                      enum:
                                                        - string
                                                  required:
                                                    - name
                                                    - type
                                                - type: object
                                                  properties:
                                                    name:
                                                      type: string
                                                      enum:
                                                        - destinationDex
                                                    type:
                                                      type: string
                                                      enum:
                                                        - string
                                                  required:
                                                    - name
                                                    - type
                                                - type: object
                                                  properties:
                                                    name:
                                                      type: string
                                                      enum:
                                                        - token
                                                    type:
                                                      type: string
                                                      enum:
                                                        - string
                                                  required:
                                                    - name
                                                    - type
                                                - type: object
                                                  properties:
                                                    name:
                                                      type: string
                                                      enum:
                                                        - amount
                                                    type:
                                                      type: string
                                                      enum:
                                                        - string
                                                  required:
                                                    - name
                                                    - type
                                                - type: object
                                                  properties:
                                                    name:
                                                      type: string
                                                      enum:
                                                        - fromSubAccount
                                                    type:
                                                      type: string
                                                      enum:
                                                        - string
                                                  required:
                                                    - name
                                                    - type
                                                - type: object
                                                  properties:
                                                    name:
                                                      type: string
                                                      enum:
                                                        - nonce
                                                    type:
                                                      type: string
                                                      enum:
                                                        - uint64
                                                  required:
                                                    - name
                                                    - type
                                            minItems: 8
                                            maxItems: 8
                                        required:
                                          - HyperliquidTransaction:SendAsset
                                      primaryType:
                                        type: string
                                        enum:
                                          - HyperliquidTransaction:SendAsset
                                      message:
                                        type: object
                                        properties:
                                          hyperliquidChain:
                                            type: string
                                            enum:
                                              - Mainnet
                                          destination:
                                            type: string
                                            pattern: ^0x[a-fA-F0-9]{40}$
                                          sourceDex:
                                            type: string
                                          destinationDex:
                                            type: string
                                          token:
                                            type: string
                                            minLength: 1
                                          amount:
                                            type: string
                                            pattern: ^\d+(?:\.\d+)?$
                                          fromSubAccount:
                                            type: string
                                          nonce:
                                            type: integer
                                            minimum: 0
                                            maximum: 9007199254740991
                                        required:
                                          - hyperliquidChain
                                          - destination
                                          - sourceDex
                                          - destinationDex
                                          - token
                                          - amount
                                          - fromSubAccount
                                          - nonce
                                    required:
                                      - domain
                                      - types
                                      - primaryType
                                      - message
                                required:
                                  - scheme
                                  - signer_address
                                  - typed_data
                              - type: object
                                properties:
                                  scheme:
                                    type: string
                                    enum:
                                      - polymarket_deposit_wallet_batch
                                  signer_address:
                                    type: string
                                    pattern: ^0x[a-fA-F0-9]{40}$
                                  typed_data:
                                    type: object
                                    properties:
                                      domain:
                                        type: object
                                        properties:
                                          name:
                                            type: string
                                            enum:
                                              - DepositWallet
                                          version:
                                            type: string
                                            enum:
                                              - '1'
                                          chainId:
                                            type: integer
                                            minimum: 0
                                            exclusiveMinimum: true
                                          verifyingContract:
                                            type: string
                                            pattern: ^0x[a-fA-F0-9]{40}$
                                        required:
                                          - name
                                          - version
                                          - chainId
                                          - verifyingContract
                                      types:
                                        type: object
                                        properties:
                                          Call:
                                            type: array
                                            items:
                                              anyOf:
                                                - type: object
                                                  properties:
                                                    name:
                                                      type: string
                                                      enum:
                                                        - target
                                                    type:
                                                      type: string
                                                      enum:
                                                        - address
                                                  required:
                                                    - name
                                                    - type
                                                - type: object
                                                  properties:
                                                    name:
                                                      type: string
                                                      enum:
                                                        - value
                                                    type:
                                                      type: string
                                                      enum:
                                                        - uint256
                                                  required:
                                                    - name
                                                    - type
                                                - type: object
                                                  properties:
                                                    name:
                                                      type: string
                                                      enum:
                                                        - data
                                                    type:
                                                      type: string
                                                      enum:
                                                        - bytes
                                                  required:
                                                    - name
                                                    - type
                                            minItems: 3
                                            maxItems: 3
                                          Batch:
                                            type: array
                                            items:
                                              anyOf:
                                                - type: object
                                                  properties:
                                                    name:
                                                      type: string
                                                      enum:
                                                        - wallet
                                                    type:
                                                      type: string
                                                      enum:
                                                        - address
                                                  required:
                                                    - name
                                                    - type
                                                - type: object
                                                  properties:
                                                    name:
                                                      type: string
                                                      enum:
                                                        - nonce
                                                    type:
                                                      type: string
                                                      enum:
                                                        - uint256
                                                  required:
                                                    - name
                                                    - type
                                                - type: object
                                                  properties:
                                                    name:
                                                      type: string
                                                      enum:
                                                        - deadline
                                                    type:
                                                      type: string
                                                      enum:
                                                        - uint256
                                                  required:
                                                    - name
                                                    - type
                                                - type: object
                                                  properties:
                                                    name:
                                                      type: string
                                                      enum:
                                                        - calls
                                                    type:
                                                      type: string
                                                      enum:
                                                        - Call[]
                                                  required:
                                                    - name
                                                    - type
                                            minItems: 4
                                            maxItems: 4
                                        required:
                                          - Call
                                          - Batch
                                      primaryType:
                                        type: string
                                        enum:
                                          - Batch
                                      message:
                                        type: object
                                        properties:
                                          wallet:
                                            type: string
                                            pattern: ^0x[a-fA-F0-9]{40}$
                                          nonce:
                                            type: string
                                            pattern: ^\d+$
                                          deadline:
                                            type: string
                                            pattern: ^\d+$
                                          calls:
                                            type: array
                                            items:
                                              type: object
                                              properties:
                                                target:
                                                  type: string
                                                  pattern: ^0x[a-fA-F0-9]{40}$
                                                value:
                                                  type: string
                                                  pattern: ^\d+$
                                                data:
                                                  type: string
                                                  pattern: ^0x[a-fA-F0-9]+$
                                              required:
                                                - target
                                                - value
                                                - data
                                        required:
                                          - wallet
                                          - nonce
                                          - deadline
                                          - calls
                                    required:
                                      - domain
                                      - types
                                      - primaryType
                                      - message
                                  agent_approval:
                                    type: object
                                    nullable: true
                                    properties:
                                      masterAddress:
                                        type: string
                                        pattern: ^0x[a-fA-F0-9]{40}$
                                      agentAddress:
                                        type: string
                                        pattern: ^0x[a-fA-F0-9]{40}$
                                      action:
                                        type: object
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - approveAgent
                                          hyperliquidChain:
                                            type: string
                                            enum:
                                              - Mainnet
                                          signatureChainId:
                                            type: string
                                            enum:
                                              - '0x66eee'
                                          agentAddress:
                                            type: string
                                            pattern: ^0x[a-fA-F0-9]{40}$
                                          agentName:
                                            type: string
                                            minLength: 1
                                          nonce:
                                            type: integer
                                            minimum: 0
                                            maximum: 9007199254740991
                                        required:
                                          - type
                                          - hyperliquidChain
                                          - signatureChainId
                                          - agentAddress
                                          - agentName
                                          - nonce
                                      typedData:
                                        type: object
                                        properties:
                                          domain:
                                            type: object
                                            properties:
                                              name:
                                                type: string
                                                enum:
                                                  - HyperliquidSignTransaction
                                              version:
                                                type: string
                                                enum:
                                                  - '1'
                                              chainId:
                                                type: number
                                                enum:
                                                  - 421614
                                              verifyingContract:
                                                type: string
                                                enum:
                                                  - >-
                                                    0x0000000000000000000000000000000000000000
                                            required:
                                              - name
                                              - version
                                              - chainId
                                              - verifyingContract
                                          types:
                                            type: object
                                            properties:
                                              HyperliquidTransaction:ApproveAgent:
                                                type: array
                                                items:
                                                  anyOf:
                                                    - type: object
                                                      properties:
                                                        name:
                                                          type: string
                                                          enum:
                                                            - hyperliquidChain
                                                        type:
                                                          type: string
                                                          enum:
                                                            - string
                                                      required:
                                                        - name
                                                        - type
                                                    - type: object
                                                      properties:
                                                        name:
                                                          type: string
                                                          enum:
                                                            - agentAddress
                                                        type:
                                                          type: string
                                                          enum:
                                                            - address
                                                      required:
                                                        - name
                                                        - type
                                                    - type: object
                                                      properties:
                                                        name:
                                                          type: string
                                                          enum:
                                                            - agentName
                                                        type:
                                                          type: string
                                                          enum:
                                                            - string
                                                      required:
                                                        - name
                                                        - type
                                                    - type: object
                                                      properties:
                                                        name:
                                                          type: string
                                                          enum:
                                                            - nonce
                                                        type:
                                                          type: string
                                                          enum:
                                                            - uint64
                                                      required:
                                                        - name
                                                        - type
                                                minItems: 4
                                                maxItems: 4
                                            required:
                                              - HyperliquidTransaction:ApproveAgent
                                          primaryType:
                                            type: string
                                            enum:
                                              - HyperliquidTransaction:ApproveAgent
                                          message:
                                            type: object
                                            properties:
                                              hyperliquidChain:
                                                type: string
                                                enum:
                                                  - Mainnet
                                              agentAddress:
                                                type: string
                                                pattern: ^0x[a-fA-F0-9]{40}$
                                              agentName:
                                                type: string
                                                minLength: 1
                                              nonce:
                                                type: integer
                                                minimum: 0
                                                maximum: 9007199254740991
                                            required:
                                              - hyperliquidChain
                                              - agentAddress
                                              - agentName
                                              - nonce
                                        required:
                                          - domain
                                          - types
                                          - primaryType
                                          - message
                                    required:
                                      - masterAddress
                                      - agentAddress
                                      - action
                                      - typedData
                                required:
                                  - scheme
                                  - signer_address
                                  - typed_data
                                  - agent_approval
                              - type: object
                                properties:
                                  scheme:
                                    type: string
                                    enum:
                                      - lean_test_payment
                                  signer_address:
                                    type: string
                                    pattern: ^0x[a-fA-F0-9]{40}$
                                  typed_data:
                                    type: object
                                    properties:
                                      domain:
                                        type: object
                                        properties:
                                          name:
                                            type: string
                                            enum:
                                              - Lean API test routed payment
                                          version:
                                            type: string
                                            enum:
                                              - '1'
                                        required:
                                          - name
                                          - version
                                      types:
                                        type: object
                                        additionalProperties:
                                          type: array
                                          items:
                                            type: object
                                            properties:
                                              name:
                                                type: string
                                              type:
                                                type: string
                                            required:
                                              - name
                                              - type
                                      primaryType:
                                        type: string
                                        enum:
                                          - RoutedPayment
                                      message:
                                        type: object
                                        properties:
                                          orderId:
                                            type: string
                                            format: uuid
                                          nonce:
                                            type: string
                                            pattern: ^0x[a-fA-F0-9]{64}$
                                          fundingVenue:
                                            type: string
                                            enum:
                                              - polymarket
                                              - hyperliquid
                                          executionVenue:
                                            type: string
                                            enum:
                                              - polymarket
                                              - hyperliquid
                                          paymentMicros:
                                            type: string
                                            pattern: ^\d+$
                                          expiresAt:
                                            type: string
                                            pattern: ^\d+$
                                        required:
                                          - orderId
                                          - nonce
                                          - fundingVenue
                                          - executionVenue
                                          - paymentMicros
                                          - expiresAt
                                    required:
                                      - domain
                                      - types
                                      - primaryType
                                      - message
                                required:
                                  - scheme
                                  - signer_address
                                  - typed_data
                              - nullable: true
                        required:
                          - id
                          - client_order_id
                          - market_id
                          - title
                          - outcome
                          - venue
                          - ticker
                          - side
                          - action
                          - type
                          - time_in_force
                          - expires_at
                          - quantity
                          - filled_quantity
                          - remaining_quantity
                          - limit_price
                          - avg_fill_price
                          - notional_usd
                          - filled_notional_usd
                          - status
                          - venue_status
                          - venue_order_id
                          - status_reason
                          - legs
                          - post_only
                          - replaces_order_id
                          - replaced_by_order_id
                          - created_at
                          - updated_at
                          - livemode
                          - route
                          - payment
                      meta:
                        type: object
                        properties:
                          timestampMs:
                            type: integer
                            minimum: 0
                          requestId:
                            type: string
                            minLength: 1
                          traceId:
                            type: string
                            minLength: 1
                          cachedAtMs:
                            type: integer
                            minimum: 0
                          source:
                            type: string
                            enum:
                              - cache
                              - database
                              - clickhouse
                              - upstream
                              - fallback
                              - internal
                        required:
                          - timestampMs
                          - requestId
                    required:
                      - success
                      - data
                      - meta
                  - $ref: '#/components/schemas/ApiError'
              example:
                success: true
                data:
                  id: 8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1
                  client_order_id: bot-0001
                  market_id: >-
                    mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4
                  title: >-
                    Denver Broncos at Los Angeles Chargers: DEN -3.5, Denver
                    Broncos -3.5
                  outcome: DEN
                  venue: null
                  ticker: null
                  side: null
                  action: buy
                  type: limit
                  time_in_force: gtc
                  expires_at: null
                  quantity: '10'
                  filled_quantity: '10'
                  remaining_quantity: '0'
                  limit_price: '0.55'
                  avg_fill_price: '0.55'
                  notional_usd: '5.511'
                  filled_notional_usd: '5.5'
                  status: filled
                  venue_status: null
                  venue_order_id: null
                  status_reason: null
                  legs: []
                  post_only: false
                  replaces_order_id: null
                  replaced_by_order_id: null
                  created_at: '2026-10-29T18:00:00.000Z'
                  updated_at: '2026-10-29T18:00:00.000Z'
                  livemode: false
                  route:
                    funding_venue: hyperliquid
                    execution_venue: polymarket
                    notional_usd: '5.511'
                    costs:
                      rebalance_fee_usd: '0.011'
                      gas_usd: '0'
                      activation_fee_usd: '0'
                      network_cost_usd: '0.011'
                  payment: null
                meta:
                  timestampMs: 1792771200000
                  requestId: 7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17
        '400':
          description: >-
            The payment signature is invalid (INVALID_SIGNATURE) or not by the
            signer (SIGNER_MISMATCH)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                success: false
                error:
                  code: VALIDATION_ERROR
                  message: Invalid request
                meta:
                  timestampMs: 1792771200000
                  requestId: 7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17
        '401':
          description: Missing, invalid, expired or revoked API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                success: false
                error:
                  code: UNAUTHORIZED
                  message: Invalid, expired or revoked API key
                meta:
                  timestampMs: 1792771200000
                  requestId: 7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17
        '403':
          description: >-
            The key lacks the route scope, or delegated authorization on an
            account that has not enabled trading in the Lean app
            (ACCOUNT_NOT_DELEGATED)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                success: false
                error:
                  code: FORBIDDEN
                  message: This API key lacks the scope this route needs
                meta:
                  timestampMs: 1792771200000
                  requestId: 7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17
        '404':
          description: No routed order with this id for this key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                success: false
                error:
                  code: NOT_FOUND
                  message: No routed order with this id for this key
                meta:
                  timestampMs: 1792771200000
                  requestId: 7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17
        '409':
          description: >-
            QUOTE_EXPIRED, ROUTE_MOVED, ORDER_NOT_PENDING,
            PAYMENT_ALREADY_AUTHORIZED when the order was already authorized
            differently, PAYMENT_MISMATCH when delegated authorization finds a
            stored payment that differs from the route, or
            AGENT_APPROVAL_REQUIRED when a delegated instant bridge still needs
            the Hyperliquid agent approved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                success: false
                error:
                  code: CONFLICT
                  message: The request conflicts with the current state
                meta:
                  timestampMs: 1792771200000
                  requestId: 7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17
        '422':
          description: Rejected by a key or account limit
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                success: false
                error:
                  code: VALIDATION_ERROR
                  message: Rejected by a key or account limit
                meta:
                  timestampMs: 1792771200000
                  requestId: 7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17
        '429':
          description: API error
          headers:
            Retry-After:
              description: Seconds remaining in the upstream read cooldown, when available
              schema:
                type: integer
                minimum: 0
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                success: false
                error:
                  code: RATE_LIMITED
                  message: Too many requests for this API key
                meta:
                  timestampMs: 1792771200000
                  requestId: 7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17
        '500':
          description: API error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                success: false
                error:
                  code: INTERNAL_ERROR
                  message: An internal error occurred.
                meta:
                  timestampMs: 1792771200000
                  requestId: 7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17
        '503':
          description: >-
            FEATURE_DISABLED with details.reason ROUTING_DISABLED,
            TRADING_PAUSED, LIVE_TRADING_DISABLED, or
            DELEGATED_ROUTE_SIGNING_DISABLED when server signing is switched
            off; UPSTREAM_ERROR when the payment could not be signed, in which
            case nothing was paid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                success: false
                error:
                  code: FEATURE_DISABLED
                  message: A required service is temporarily unavailable.
                meta:
                  timestampMs: 1792771200000
                  requestId: 7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17
components:
  schemas:
    ApiError:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - VALIDATION_ERROR
                - NOT_FOUND
                - UNAUTHORIZED
                - FORBIDDEN
                - CONFLICT
                - UPSTREAM_ERROR
                - RATE_LIMITED
                - INTERNAL_ERROR
                - FEATURE_DISABLED
                - CONDITIONAL_SELL_REJECTED
                - CONDITIONAL_SELL_ACTIVE
            message:
              type: string
              minLength: 1
            details:
              nullable: true
          required:
            - code
            - message
        meta:
          type: object
          properties:
            timestampMs:
              type: integer
              minimum: 0
            requestId:
              type: string
              minLength: 1
            traceId:
              type: string
              minLength: 1
            cachedAtMs:
              type: integer
              minimum: 0
            source:
              type: string
              enum:
                - cache
                - database
                - clickhouse
                - upstream
                - fallback
                - internal
          required:
            - timestampMs
            - requestId
      required:
        - success
        - error
        - meta
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: >-
        A Lean API key, sent as `Authorization: Bearer <key>`. A test key
        (`lean_sk_test_...`) simulates orders and fills with no money; a live
        key (`lean_sk_live_...`) trades for real within the key's limits. Every
        successful response says which mode answered in `data.livemode`.

````

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