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

# Preflight

> Check that the candidate you selected is still submit-ready and receive nextActions - an ordered execution plan covering everything between selection and a submitted order: approvals to mine, deposits for bridge legs, the exact payload to sign, and where to send it. Actions marked frequency reusableSetup (like a bounded Permit2 grant) persist across trades and stop appearing once done. Re-run preflight whenever an action lists rerunPreflight in its after steps - multi-leg routes often need a second pass after the first leg mines.



## OpenAPI

````yaml /api-reference/specs/router-api.json post /orders/preflight
openapi: 3.1.0
info:
  title: TetraFi Router API
  version: '1'
  description: >-
    Multi-source routing over every eligible execution source. One intent fans
    out across direct DEX liquidity, the RFQ venue, bridges, issuers, and fiat
    rails, and comes back as ranked executable candidates - each stating its own
    guarantees.
servers:
  - url: https://api.tetrafi.io/api/v1/router
    description: >-
      Router namespace base URL. The chain is no longer part of the URL - every
      asset in an intent names its network via chainId. The same host serves the
      sandbox: authenticate with a tfk_test_ key to route against test
      corridors, tfk_live_ for production.
security:
  - apiKeyAuth: []
paths:
  /orders/preflight:
    post:
      summary: Preflight
      description: >-
        Check that the candidate you selected is still submit-ready and receive
        nextActions - an ordered execution plan covering everything between
        selection and a submitted order: approvals to mine, deposits for bridge
        legs, the exact payload to sign, and where to send it. Actions marked
        frequency reusableSetup (like a bounded Permit2 grant) persist across
        trades and stop appearing once done. Re-run preflight whenever an action
        lists rerunPreflight in its after steps - multi-leg routes often need a
        second pass after the first leg mines.
      operationId: preflightOrder
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              title: OrderPreflightRequest
              properties:
                quoteResponse:
                  $ref: '#/components/schemas/QuoteCandidate'
                  title: Selected candidate
                  description: >-
                    The candidate to preflight, passed back exactly as it
                    appeared in the quotes response. The plan is computed
                    against this candidate's terms and the user's current
                    on-chain state.
              required:
                - quoteResponse
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderPreflightResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    QuoteCandidate:
      properties:
        quoteId:
          type: string
          title: Quoteid
          description: >-
            Identifier that follows the candidate through preflight, submission,
            and status.
        solverId:
          type: string
          title: Solverid
          description: >-
            Source that produced the candidate - e.g. tetrafi-native, a DEX
            adapter, or a bridge route.
        executionMode:
          type: string
          enum:
            - apiSubmit
            - walletBroadcast
          title: Executionmode
          description: >-
            Who lands the transaction on-chain: apiSubmit means TetraFi submits
            the settlement after you sign; walletBroadcast means you broadcast a
            prepared transaction yourself. This per-candidate property replaces
            a request-level gasless flag.
        order:
          anyOf:
            - $ref: '#/components/schemas/StandardOrder'
            - type: 'null'
          description: >-
            The escrow-v0 payload to sign, present on direct candidates.
            Composite planner routes carry prepared transactions via preflight
            instead.
        validUntil:
          type: integer
          title: Validuntil
          description: >-
            Unix timestamp ending the firmness window; the candidate expires at
            this moment.
        eta:
          anyOf:
            - type: integer
            - type: 'null'
          title: Eta
          description: Expected seconds until settlement.
        preview:
          type: object
          title: Preview
          description: >-
            Human-readable ins and outs - what the user sends and what arrives
            if the candidate executes as quoted.
          properties:
            inputs:
              items:
                $ref: '#/components/schemas/PreviewInput'
              type: array
              title: Inputs
            outputs:
              items:
                $ref: '#/components/schemas/PreviewOutput'
              type: array
              title: Outputs
          required:
            - inputs
            - outputs
        integrityChecksum:
          type: string
          title: Integritychecksum
          description: >-
            Tamper-evidence binding the terms you were shown to the terms you
            submit; any drift between them is rejected.
        routingPath:
          type: string
          title: Routingpath
          description: >-
            Route shape - direct for a single-source fill; multi-leg routes
            describe their legs in composite.
        platformFeeBps:
          anyOf:
            - type: integer
            - type: 'null'
          title: Platformfeebps
          description: >-
            Platform fee applied to this candidate, in basis points.
            Monetization is configured per workspace, not passed per request.
        lpSpreadBps:
          anyOf:
            - type: integer
            - type: 'null'
          title: Lpspreadbps
          description: >-
            Spread earned by the liquidity provider on this candidate, in basis
            points.
        composite:
          anyOf:
            - type: object
              properties:
                legs:
                  type: array
                  items:
                    type: object
                  title: Legs
                  description: >-
                    Ordered legs of the planner route, each naming its kind and
                    chain.
                executionModel:
                  type: string
                  title: Executionmodel
                  description: How the legs run, e.g. sequential.
            - type: 'null'
          title: Composite
          description: >-
            Present on planner-assembled multi-leg routes; absent on direct
            single-source quotes.
        gas:
          anyOf:
            - $ref: '#/components/schemas/GasEstimate'
            - type: 'null'
          description: >-
            Gas context for the candidate; the ranking already compares
            candidates net of gas and explicit fees.
        warnings:
          items:
            $ref: '#/components/schemas/PriceWarning'
          type: array
          title: Warnings
          description: Non-blocking warnings attached to the candidate.
          default: []
      type: object
      required:
        - quoteId
        - solverId
        - executionMode
        - validUntil
        - preview
        - integrityChecksum
      title: QuoteCandidate
    OrderPreflightResponse:
      properties:
        quoteId:
          type: string
          title: Quoteid
          description: Candidate the plan applies to.
        ready:
          type: boolean
          title: Ready
          description: >-
            True when nothing stands between you and submission - the remaining
            nextActions are just the signature and the POST.
        fundingLock:
          anyOf:
            - $ref: '#/components/schemas/FundingLockType'
            - type: 'null'
          description: >-
            Lock mechanism preflight selected for pulling the input - your code
            stays the same whichever it picks.
        lockDetails:
          anyOf:
            - $ref: '#/components/schemas/Permit2Lock'
            - $ref: '#/components/schemas/Eip3009Authorization'
            - $ref: '#/components/schemas/ResourceLock'
            - type: 'null'
          title: Lockdetails
          description: >-
            Parameters of the selected funding lock, when it needs client-side
            material.
        nextActions:
          items:
            $ref: '#/components/schemas/PreflightNextAction'
          type: array
          title: Nextactions
          description: >-
            Ordered execution plan; empty when the candidate is immediately
            submittable.
      type: object
      required:
        - quoteId
        - ready
        - nextActions
      title: OrderPreflightResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    StandardOrder:
      properties:
        type:
          type: string
          title: Type
          description: Order payload type; escrow-v0 for the current settlement contract.
        payload:
          type: object
          title: Payload
          description: >-
            Complete EIP-712 envelope - domain, types, and the StandardOrder
            message - delivered verbatim by the API. Treat it as opaque: sign
            exactly what arrives in quote.order (or the typedData on preflight's
            orderSignature action) and never assemble or edit it locally. The
            signed terms cover the parties, the inputs you escrow, the minimum
            outputs that must be delivered, an expiry after which the unfilled
            order refunds, and a domain-scoped nonce; they are bound to your
            submission by the integrityChecksum.
      type: object
      required:
        - type
        - payload
      title: StandardOrder
      description: >-
        The escrow-v0 order payload a candidate asks you to sign. Anything you
        would want different - receiver, amounts, expiry - changes at quote
        time, not signing time.
    PreviewInput:
      properties:
        asset:
          type: string
          title: Asset
          description: >-
            Escrowed asset in CAIP-19 form, e.g.
            eip155:10/erc20:0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85.
        amount:
          type: string
          title: Amount
          description: Base-unit amount the user sends.
        decimals:
          anyOf:
            - type: integer
            - type: 'null'
          title: Decimals
          description: Token decimals, for converting base units to a display amount.
        symbol:
          anyOf:
            - type: string
            - type: 'null'
          title: Symbol
          description: Token ticker symbol.
        priceUsd:
          anyOf:
            - type: number
            - type: 'null'
          title: Priceusd
          description: Reference US-dollar price per whole token, when available.
      type: object
      required:
        - asset
        - amount
      title: PreviewInput
    PreviewOutput:
      properties:
        asset:
          type: string
          title: Asset
          description: >-
            Delivered asset in CAIP-19 form, e.g.
            eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913.
        amount:
          type: string
          title: Amount
          description: >-
            Base-unit amount delivered if the candidate executes exactly as
            quoted.
        minimumAmount:
          anyOf:
            - type: string
            - type: 'null'
          title: Minimumamount
          description: >-
            Floor the settlement must deliver - the per-candidate guarantee that
            replaces a request-level slippage parameter.
        decimals:
          anyOf:
            - type: integer
            - type: 'null'
          title: Decimals
          description: Token decimals, for converting base units to a display amount.
        symbol:
          anyOf:
            - type: string
            - type: 'null'
          title: Symbol
          description: Token ticker symbol.
        priceUsd:
          anyOf:
            - type: number
            - type: 'null'
          title: Priceusd
          description: Reference US-dollar price per whole token, when available.
        receiver:
          anyOf:
            - type: string
            - type: 'null'
          title: Receiver
          description: Wallet this output is delivered to.
      type: object
      required:
        - asset
        - amount
      title: PreviewOutput
    GasEstimate:
      properties:
        native:
          type: string
          title: Native
          description: >-
            Estimated gas cost in the execution chain's native currency, base
            units. Zero on apiSubmit candidates, where TetraFi carries the gas.
        usd:
          anyOf:
            - type: number
            - type: 'null'
          title: Usd
          description: The same estimate in US dollars, when a price is available.
      type: object
      required:
        - native
      title: GasEstimate
    PriceWarning:
      properties:
        code:
          type: integer
          title: Code
          description: Numeric warning identifier.
        message:
          type: string
          title: Message
          description: >-
            What the warning flags - unusual pricing, thin liquidity, or
            similar.
      type: object
      required:
        - code
        - message
      title: PriceWarning
      description: >-
        Non-blocking warning attached to a candidate's warnings array so unusual
        conditions surface before you select it.
    FundingLockType:
      type: string
      enum:
        - Permit2
        - EIP-3009
        - ResourceLock
      title: FundingLockType
      description: >-
        Mechanism the escrow uses to pull the input asset. Never requested by
        the client - preflight picks whichever the corridor and token support: a
        reusable Permit2 allowance, an EIP-3009 in-signature authorization, or a
        pre-funded resource lock in the compact settler.
    Permit2Lock:
      properties:
        signature:
          type: string
          title: Signature
          description: >-
            Signed Permit2 permit authorizing the escrow to pull the input
            token.
        deadline:
          type: integer
          title: Deadline
          description: Unix timestamp after which the permit is void.
      type: object
      required:
        - signature
        - deadline
      title: Permit2Lock
      description: >-
        Permit2 funding lock: one reusable approval of the Permit2 contract,
        after which each order authorizes its own pull inside the signature.
    Eip3009Authorization:
      properties:
        signature:
          type: string
          title: Signature
          description: Signed transferWithAuthorization message.
        validAfter:
          type: integer
          title: Valid After
          description: Unix timestamp from which the authorization becomes usable.
        validBefore:
          type: integer
          title: Valid Before
          description: Unix timestamp at which the authorization expires.
        nonce:
          type: string
          title: Nonce
          description: Random 32-byte nonce making the authorization single-use.
      type: object
      required:
        - signature
        - validAfter
        - validBefore
        - nonce
      title: Eip3009Authorization
      description: >-
        EIP-3009 funding lock for USDC-style tokens: the transfer is authorized
        entirely inside the signed message, so no approval transaction ever
        exists.
    ResourceLock:
      properties:
        token:
          type: string
          title: Token
          description: Asset held in the compact settler.
        amount:
          type: string
          title: Amount
          description: Locked balance drawn per order, base units.
      type: object
      required:
        - token
        - amount
      title: ResourceLock
      description: >-
        Resource-lock funding: balance pre-deposited into the compact settler
        and drawn per order - no approval or in-signature authorization needed
        at trade time.
    PreflightNextAction:
      properties:
        type:
          type: string
          enum:
            - evmTransaction
            - signTypedData
            - postOrder
            - linkWallet
            - fundLpAccount
          title: Type
          description: >-
            What kind of step this is: a transaction to broadcast, typed data to
            sign, an order to POST, a wallet to link, or an LP account to fund.
        purpose:
          type: string
          enum:
            - tokenApproval
            - bridgeDeposit
            - orderSignature
            - orderSubmit
            - walletLink
            - tradeLedgerAuthorization
            - lpFunding
          title: Purpose
          description: >-
            Why the step exists: a token approval to mine, a deposit for a
            bridge leg, the order payload to sign, the submission itself, a
            wallet link, a trade-ledger authorization, or LP account funding.
        actor:
          type: string
          enum:
            - userWallet
            - tetrafiApi
          title: Actor
          description: >-
            Who performs the step: userWallet means your side signs or
            broadcasts; tetrafiApi means it goes through the API under your key.
        frequency:
          type: string
          enum:
            - perTrade
            - reusableSetup
          title: Frequency
          description: >-
            perTrade steps recur on every order; reusableSetup steps - like a
            bounded Permit2 grant - persist across trades and stop appearing
            once completed.
        chainId:
          anyOf:
            - type: integer
            - type: 'null'
          title: Chainid
          description: Chain the step touches, when it is chain-bound.
        tx:
          anyOf:
            - $ref: '#/components/schemas/PreflightEvmTransaction'
            - type: 'null'
          description: Ready-to-broadcast transaction for evmTransaction steps.
        typedData:
          anyOf:
            - $ref: '#/components/schemas/StandardOrder'
            - type: 'null'
          description: EIP-712 envelope for signTypedData steps - sign it verbatim.
        submitTo:
          anyOf:
            - type: string
            - type: 'null'
          title: Submitto
          description: >-
            Where the resulting artifact goes, e.g. /orders for a signed
            payload.
        after:
          items:
            type: string
            enum:
              - waitForTransactionMined
              - rerunPreflight
              - postOrder
          type: array
          title: After
          description: >-
            Follow-ups once the step completes: wait for the transaction to
            mine, run preflight again (multi-leg routes often need this after
            the first leg), or post the order.
          default: []
        details:
          anyOf:
            - type: object
            - type: 'null'
          title: Details
          description: Free-form human-readable context for the step.
      type: object
      required:
        - type
        - purpose
        - actor
        - frequency
      title: PreflightNextAction
      description: >-
        One step in the ordered execution plan preflight returns. Execute the
        actions in order; together they cover everything between candidate
        selection and a submitted order.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    PreflightEvmTransaction:
      properties:
        chainId:
          type: integer
          title: Chainid
          description: Chain to broadcast on.
        from:
          anyOf:
            - type: string
            - type: 'null'
          title: From
          description: >-
            Sender - your wallet; fill it in when assembling the final
            transaction.
        to:
          type: string
          title: To
          description: Contract the transaction calls.
        value:
          type: string
          title: Value
          description: Native value to attach, as prepared.
        data:
          type: string
          title: Data
          description: Calldata - broadcast exactly as prepared.
        gas:
          anyOf:
            - type: integer
            - type: 'null'
          title: Gas
          description: Suggested gas limit.
        gasPrice:
          anyOf:
            - type: integer
            - type: 'null'
          title: Gasprice
          description: Suggested gas price; you may re-estimate from your own RPC.
      type: object
      required:
        - to
        - value
        - data
      title: PreflightEvmTransaction
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: Service-account API key (tfk_test_/tfk_live_).

````