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

# Execute an x402 agent round

> Self-funded pay-per-request round via agent escrow.



## OpenAPI

````yaml gateway-openapi.yaml POST /v1/agent/execute
openapi: 3.1.0
info:
  contact: {}
  description: HTTP entry point to the Molpha oracle protocol.
  title: Molpha Gateway API
  version: '1.0'
  x-mint:
    metadata:
      description: >-
        Dispatch oracle rounds, collect threshold signatures, and return
        payloads for Solana, EVM, and Starknet verification.
servers:
  - url: https://dev-gateway.molpha.io
    description: Devnet (SDK default)
security: []
tags:
  - name: health
    x-group: Health
    description: Liveness probes
  - name: nodes
    x-group: Nodes
    description: Oracle node discovery
  - name: round
    x-group: Subscription rounds
    description: Subscription and delegate execute path
  - name: agent
    x-group: Agent (x402)
    description: Pay-per-request agent path (requires `agent.enabled`)
paths:
  /v1/agent/execute:
    post:
      tags:
        - agent
      summary: Execute an x402 agent round
      description: Self-funded pay-per-request round via agent escrow.
      requestBody:
        required: true
        description: Agent round execution request
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentExecuteRequest'
            example:
              payer: 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
              canonical_timestamp: 1700100000
              signatures_required: 3
              amount: 1030
              registry_version: 42
              agent_request_auth_sig: >-
                5VERv8NMvzbJMEkV8xnrLkEaWRtSz9ibyvq8CJ7qJqJqJqJqJqJqJqJqJqJqJqJqJqJqJqJqJqJqJqJqJq
              apiConfig:
                url: https://api.example.com/v1/price
                method: GET
                headers: {}
                responseParser: $.data.price
                valueTransform: multiply:1e6
      responses:
        '200':
          description: Signed payload ready for submission or verification
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataUpdateResponse'
        '400':
          description: Validation failure, `amount` mismatch, or stale `registry_version`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing or invalid `agent_request_auth_sig` on a funded request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Escrow ATA underfunded — returns x402 payment envelope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentRequiredResponse'
        '403':
          description: Escrow paused or payer/authority mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: Duplicate `canonical_timestamp` for this feed identity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Node round timeout or upstream failure
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    AgentExecuteRequest:
      type: object
      description: >-
        Request body for `POST /v1/agent/execute`. Agent-specific fields use
        snake_case.
      required:
        - payer
        - canonical_timestamp
        - signatures_required
        - amount
        - registry_version
        - apiConfig
      properties:
        payer:
          type: string
          description: >-
            Payer Ed25519 identity and on-chain escrow authority (base58
            pubkey).
          example: 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
        canonical_timestamp:
          type: integer
          description: >-
            Node round timestamp and on-chain replay key. Must be within gateway
            clock skew.
          example: 1700100000
        signatures_required:
          type: integer
          description: Requested quorum for this round.
          example: 3
        amount:
          type: integer
          description: >-
            Locked round price in USDC atomic units. Must equal the computed
            price exactly.
          example: 1030
        registry_version:
          type: integer
          description: Active on-chain registry version. Must match the current version.
          example: 42
        agent_request_auth_sig:
          type: string
          description: >-
            Payer Ed25519 signature over `H(AgentRequestAuth)` (base58 or `0x`
            hex).

            Omit only on the unfunded first request of the 402 discovery flow.
        apiConfig:
          $ref: '#/components/schemas/ApiConfigRequest'
        encKeyBundle:
          $ref: '#/components/schemas/EncKeyBundleRequest'
    DataUpdateResponse:
      type: object
      description: >-
        Successful round response envelope shared by subscription and agent
        execute paths.
      properties:
        status:
          type: string
          description: Round completion status.
          example: completed
        data:
          $ref: '#/components/schemas/DataUpdate'
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message.
          example: validation failed
    PaymentRequiredResponse:
      type: object
      description: Standard x402 envelope returned when the escrow ATA is underfunded.
      properties:
        x402Version:
          type: integer
          description: x402 protocol version.
          example: 1
        error:
          type: string
          description: Error message.
          example: 'payment required: escrow ATA underfunded'
        accepts:
          type: array
          description: Accepted payment options.
          items:
            $ref: '#/components/schemas/PaymentOption'
    ApiConfigRequest:
      type: object
      description: Off-chain HTTP API configuration hashed into the feed identity.
      required:
        - url
        - responseParser
      properties:
        url:
          type: string
          description: Target API URL. Must use `http` or `https`.
          example: https://api.example.com/v1/price
        method:
          type: string
          description: HTTP method.
          default: GET
          example: GET
        headers:
          type: object
          description: >-
            Request headers. Use `{{secret.name}}` placeholders with
            `encKeyBundle` for private APIs.
          additionalProperties:
            type: string
          example: {}
        responseParser:
          type: string
          description: JSONPath expression to extract the value from the API response.
          example: $.data.price
        valueTransform:
          type: string
          description: Optional post-parse transform (e.g. `multiply:1e6`).
          example: multiply:1e6
    EncKeyBundleRequest:
      type: object
      description: >-
        End-to-end encryption envelope for private API configs. Omit for
        plaintext configs.
      properties:
        ephemeralPub:
          type: string
          description: Ephemeral X25519 public key used to encrypt the config.
        nonceSym:
          type: string
          description: Symmetric encryption nonce.
        ciphertext:
          type: string
          description: Encrypted API configuration payload.
        envelopes:
          type: object
          description: Per-node encrypted key envelopes, keyed by node index.
          additionalProperties:
            type: string
    DataUpdate:
      type: object
      description: Threshold-signed oracle result included in successful round responses.
      properties:
        feedId:
          type: string
          description: Derived feed identity (hex).
          example: 0xabc123...
        value:
          type: string
          description: Human-readable decoded value.
          example: '42150125000000'
        valuePacked:
          type: string
          description: 32-byte packed value (hex).
        timestamp:
          type: integer
          description: Canonical round timestamp (seconds).
          example: 1700100000
        registryVersion:
          type: integer
          description: Registry version active when the round was signed.
          example: 42
        signaturesRequired:
          type: integer
          description: Quorum required for this feed.
          example: 3
        configHash:
          type: string
          description: Hash of the committed API configuration.
        signersBitmap:
          type: string
          description: 32-byte big-endian bitmap of participating signers (hex).
        s:
          type: string
          description: 32-byte Schnorr scalar `s` (hex).
        rx:
          type: string
          description: Schnorr commitment x-coordinate (hex).
        ryParity:
          type: integer
          description: Schnorr commitment y parity (`0` or `1`).
        commitmentAddr:
          type: string
          description: 20-byte commitment address (hex).
        fresh:
          type: boolean
          description: Always `true` for live gateway rounds.
          example: true
    PaymentOption:
      type: object
      properties:
        scheme:
          type: string
          description: Payment scheme (e.g. `exact`).
          example: exact
        network:
          type: string
          description: Solana network identifier.
          example: solana-devnet
        maxAmountRequired:
          type: string
          description: Minimum USDC to fund (atomic units, decimal string).
          example: '1030'
        payTo:
          type: string
          description: Escrow ATA address to fund.
        asset:
          type: string
          description: USDC mint address.
        resource:
          type: string
          description: Gateway resource path.
          example: /v1/agent/execute
        description:
          type: string
          description: Payment description shown to the agent.
        maxTimeoutSeconds:
          type: integer
          description: Suggested timeout for completing payment.
          example: 60
        extra:
          $ref: '#/components/schemas/PaymentExtra'
    PaymentExtra:
      type: object
      description: Fields required to sign `AgentRequestAuth` after a `402` response.
      properties:
        payer:
          type: string
          description: Payer pubkey.
        agent:
          type: string
          description: Escrow PDA — the `agent` field in `AgentRequestAuth`.
        gateway:
          type: string
          description: Settling gateway PDA bound into the signed auth.
        feedId:
          type: string
          description: >-
            Feed identity derived from `(payer, api_config_hash,
            signatures_required)`.
        canonicalTimestamp:
          type: integer
          description: Replay key — must match the retried request.
        amount:
          type: string
          description: Locked round price (atomic units, decimal string).
        currentAtaBalance:
          type: string
          description: Current escrow ATA balance before funding.
        committedAmount:
          type: string
          description: USDC already reserved by unsettled prior rounds.
        note:
          type: string
          description: Human-readable funding instructions.

````