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

> ## Agent Instructions
> To integrate AGG, start with Quickstart: REST (https://docs.agg.market/quickstart/rest), then Order lifecycle & statuses (https://docs.agg.market/concepts/order-lifecycle).
> Track every trade until it reaches a terminal status. Before retrying a failed or timed-out call, read Errors, retries & idempotency (https://docs.agg.market/concepts/errors).
> The API reference is generated from https://docs.agg.market/openapi/openapi.json.

# Execute quote

> Accepts a previously quoted smart-route quote and returns pending order IDs for the submitted fill execution.



## OpenAPI

````yaml /openapi/openapi.json post /execution/fill
openapi: 3.0.2
info:
  title: AGG API
  version: 1.0.0
  description: >-
    Prediction market aggregator REST API — authentication, users, venue events,
    venue markets, orderbooks, charts, and execution workflows.
servers:
  - url: https://api.agg.market
    description: Production
security: []
tags:
  - name: Authentication
    description: Sign users in and manage their session tokens.
  - name: Markets
    description: Find events, markets and outcomes to trade.
  - name: Market Data
    description: Live orderbooks, prices, charts and scores for those markets.
  - name: Trading
    description: Quote, place, sign, track and cancel orders.
  - name: Portfolio
    description: A user's orders, positions, balances and activity.
  - name: Funding
    description: Deposit addresses, withdrawals, balance refills and fiat on-ramp.
  - name: Users
    description: The signed-in user's profile, linked accounts, KYC and venue keys.
  - name: Hosted Venue Accounts
    description: Provision, fund and withdraw from venue accounts hosted for the user.
  - name: Webhooks
    description: Configure and operate webhook delivery to your server.
  - name: Partner Admin
    description: Server-side reads across your app's users, orders and analytics.
  - name: Paper Trading
    description: Simulated accounts and orders for testing without real funds.
  - name: News
    description: News feeds linked to markets.
  - name: Correlated Markets
    description: Markets related to a given market and the effect of its resolution.
paths:
  /execution/fill:
    post:
      tags:
        - Trading
      summary: Execute quote
      description: >-
        Accepts a previously quoted smart-route quote and returns pending order
        IDs for the submitted fill execution.
      operationId: fillManaged
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - quoteId
              properties:
                quoteId:
                  description: '`quoteId` from GET /orderbook/{venueMarketOutcomeId}/route.'
                  type: string
                mode:
                  description: >-
                    `live` (default) or `paper` to fill against the user's paper
                    account.
                  type: string
                  enum:
                    - live
                    - paper
                fallbackToLatest:
                  description: >-
                    Used only when `quoteId` has expired: the server fills
                    against the user's latest quote with this same intent
                    instead of returning 400. A different spend, mode or venue
                    scope is a different intent and does not match.
                  type: object
                  required:
                    - outcomeId
                    - side
                  properties:
                    outcomeId:
                      description: Outcome of the original quote.
                      type: string
                    side:
                      description: Side of the original quote.
                      type: string
                      enum:
                        - buy
                        - sell
                    maxSpend:
                      description: 'Buy: the original spend, in USD as a float.'
                      type: number
                    sellShares:
                      description: 'Sell: the original share count, as a float.'
                      type: number
                    allowedVenues:
                      description: Venue scope of the original quote.
                      type: array
                      items:
                        $ref: '#/components/schemas/Venue'
                signingAddress:
                  minLength: 42
                  maxLength: 42
                  description: >-
                    Self-custody: the wallet that signs this fill. Must already
                    be linked to the account. Omit for managed custody (the
                    default).
                  type: string
                fundingAddresses:
                  description: >-
                    Self-custody: other linked wallets this fill may spend from
                    (`signingAddress` is always included). Order does not
                    matter: per token, the wallet with the largest balance is
                    used first. Omit to fund from the signing wallet only.
                  type: array
                  items:
                    minLength: 42
                    maxLength: 42
                    type: string
                approveMode:
                  description: >-
                    Self-custody, cross-chain fills only: how the token approval
                    a bridge needs is made. `sponsored` (default): the wallet
                    does not send the approve itself; it signs a one-time
                    EIP-7702 authorization per chain, over a raw digest (not
                    EIP-191 or EIP-712), which many wallets cannot produce.
                    `user_broadcast`: the user sends the approve transaction
                    from their wallet and pays its gas, on every bridge. Pick
                    based on what the wallet software supports. Neither mode
                    makes bridging free: quote with `deepEstimate` and read
                    `feeBreakdown.bridgeFees` and `feeBreakdown.setupCosts`.
                  type: string
                  enum:
                    - sponsored
                    - user_broadcast
            example:
              quoteId: k2r8v5n1x7c4m9t3b6q0w2za
      responses:
        '200':
          description: '200'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FillResponse'
              example:
                quoteId: k2r8v5n1x7c4m9t3b6q0w2za
                orderIds:
                  - cmf3r1a2b00c4mw0lq8y7e3uj
                  - cmf3r1a3c00c5mw0lt2k9w6nd
                status: pending
        '400':
          description: '400'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QuoteError'
        '401':
          description: '401'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '403':
          description: '403'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '404':
          description: '404'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
      security:
        - appId: []
          bearerAuth: []
components:
  schemas:
    Venue:
      type: string
      enum:
        - kalshi
        - polymarket
        - limitless
        - opinion
        - predict
        - pred
        - tiprun
        - probable
        - myriad
        - hyperliquid
        - novig
        - prophetx
        - betdex
    FillResponse:
      type: object
      required:
        - quoteId
        - orderIds
        - status
      properties:
        alreadyAccepted:
          description: >-
            `true` when this quote was already accepted; the call had no new
            effect.
          type: boolean
        quoteId:
          description: The quote being filled. Poll GET /execution/status with it.
          type: string
        orderIds:
          description: >-
            Orders created for the fill, including tracking orders for shares
            redeemed instead of sold.
          type: array
          items:
            type: string
        status:
          description: >-
            Always `pending`: accepted, not yet executed. Poll GET
            /execution/status.
          type: string
          enum:
            - pending
        redeemId:
          description: >-
            Present when a sell quote includes resolved shares that are redeemed
            rather than sold.
          type: string
        message:
          description: Readable note about redemption, when relevant.
          type: string
        pendingSignatures:
          description: >-
            Self-custody only: requests the user's wallet must sign before
            execution continues. Absent for managed custody. Answer them on POST
            /execution/fill/{quoteId}/signatures.
          type: array
          items:
            $ref: '#/components/schemas/PendingSignature'
    QuoteError:
      type: object
      required:
        - message
      properties:
        message:
          type: string
        code:
          type: string
          enum:
            - quote_not_found
            - quote_expired
            - quote_already_executed
            - quote_cancelled
            - quote_user_mismatch
            - quote_app_blocked
            - quote_unfillable
            - quote_min_order_size
            - quote_stale_status
            - quote_stale_price
            - quote_insufficient_balance
            - quote_market_inactive
            - quote_self_custody_unsupported_venue
            - quote_self_custody_app_fee
            - quote_self_custody_redeem_unsupported
            - venue_not_executable
            - outcome_ambiguous
    ErrorMessage:
      type: object
      required:
        - message
      properties:
        message:
          type: string
    PendingSignature:
      description: >-
        One request the user's wallet must sign (or send) before execution
        continues.
      type: object
      required:
        - stepId
        - type
        - venue
        - signerAddress
        - payload
        - expiresAt
      properties:
        stepId:
          description: >-
            Id of the execution step waiting on this request. Send it back
            verbatim.
          type: string
        type:
          $ref: '#/components/schemas/SignatureRequestType'
        venue:
          description: >-
            Who the request is for. Open set: usually a venue (`polymarket`,
            `hyperliquid`); `relay` for a bridge transfer and `referral` for a
            referral payout.
          type: string
        signerAddress:
          description: >-
            Address that must sign (or send) this request. For Hyperliquid it
            may be the user's approved agent address.
          type: string
        chainId:
          description: >-
            Chain the request is for, when set. Often absent: read the chain
            from `payload.domain.chainId` or `payload.chainId`.
          type: number
        payload:
          description: >-
            The data to sign or send, verbatim. Shape depends on `type`:
            `eip712`: viem-style typed data `{ domain, types, primaryType,
            message }`; sign it with signTypedData. `personal_sign`: either a
            string message, or `{ raw: "0x…" }` meaning sign those raw bytes
            (`signMessage({ message: { raw } })`). `transaction`: `{ chainId,
            to, value, data }` where `chainId` is a decimal string, `value` a
            decimal wei string and `data` hex; broadcast it from `signerAddress`
            and return `txHash`. `hl_l1_action`: EIP-712 typed data for a
            Hyperliquid action (primary type `Agent`, chainId 1337); sign with
            signTypedData. `eip7702_authorization`: `{ contractAddress, chainId,
            nonce }` (numbers for `chainId` and `nonce`); sign the EIP-7702
            authorization for them. `safe_tx`: `{ domain, types, primaryType:
            "SafeTx", message, safeTxHash }`; sign the raw 32-byte `safeTxHash`
            with personal_sign (`signMessage({ message: { raw: safeTxHash }
            })`), not with signTypedData.
        expiresAt:
          description: >-
            ISO-8601. After this the request is void and the trade must be
            re-quoted.
          type: string
        purpose:
          description: >-
            Why the request is asked for, when known; for display and routing
            only. Open set. Known values: `funding`, `funding_and_fee`, `fee` (a
            self-custody funding batch), `app_fee` (the app fee),
            `referral_payout` (an app-paid referral, signed by
            `referralPayerAddress`; read `type`, it is a `transaction` on EVM
            chains and an `eip712` on HyperCore), `hl_referral` (a partner
            referral code for the user's Hyperliquid account; see `optional`).
          type: string
        optional:
          description: >-
            `true` when the trade proceeds without this request, e.g. `purpose:
            "hl_referral"`. If your signer declines it, skip it and submit the
            rest.
          type: boolean
    SignatureRequestType:
      description: >-
        What to do with `payload`. `eip712`: sign typed data. `personal_sign`:
        sign a message (EIP-191). `transaction`: broadcast a transaction and
        return its hash. `solana_transaction`: sign a Solana transaction (not
        currently issued). `hl_l1_action`: sign a Hyperliquid action's typed
        data. `eip7702_authorization`: sign an EIP-7702 authorization (a raw
        digest many wallets cannot produce; if yours cannot, fill with
        `approveMode: "user_broadcast"` instead of throwing). `safe_tx`: a
        Polymarket Safe transaction; see `payload`.
      type: string
      enum:
        - eip712
        - personal_sign
        - transaction
        - solana_transaction
        - hl_l1_action
        - eip7702_authorization
        - safe_tx
  securitySchemes:
    appId:
      type: apiKey
      in: header
      name: x-app-id
      description: Your application ID. Required for all app-tier and user-tier routes.
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT access token returned by POST /auth/verify. Required for user-tier
        routes.

````