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

# CPI Route Accounts

> POST /api/v1/cpi/route-accounts — Build the route instruction for another program to call via CPI, signed by its PDA.



## OpenAPI

````yaml POST /api/v1/cpi/route-accounts
openapi: 3.1.0
info:
  title: Vulcx API
  description: >-
    Swap aggregator API on Fogo. Get quotes, build swap transactions, and
    retrieve raw instructions for multi-hop token swaps across Vortex, Fluxbeam,
    Fogo.fun, and Moonit.
  version: 1.0.0
  contact:
    name: Vulcx
    url: https://vulcx.finance
servers:
  - url: https://api.vulcx.xyz
    description: Production
security:
  - ApiKeyHeader: []
  - ApiKeyQuery: []
paths:
  /api/v1/cpi/route-accounts:
    post:
      tags:
        - CPI
      summary: Get CPI account list for calling route from another program
      description: >-
        Builds the Vulcx `route` instruction shaped for a Cross-Program
        Invocation (CPI): the supplied program PDA is wired in as the swap
        authority (signer, and writable when a Moonit hop is involved). Forward
        `routeInstruction.accounts` into your program's `route` CPI and sign
        with your PDA seeds (`invoke_signed`). No ATA-create or SOL wrap/unwrap
        instructions are emitted — the returned `requiredTokenAccounts` are ATAs
        your PDA must own and fund before the CPI runs. Split routes are not yet
        supported and return 400. See the on-chain CPI guide for the full flow.
      operationId: buildRouteCpiAccounts
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CPIRouteAccountsRequest'
      responses:
        '200':
          description: Route CPI account list built successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: '#/components/schemas/RouteCPIAccountsResponse'
        '400':
          description: >-
            Invalid request parameters, or a split route that CPI does not yet
            support.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: No route found between the tokens.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Failed to build the account list.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    CPIRouteAccountsRequest:
      type: object
      description: >-
        Parameters for building the `route` instruction as a CPI target. Like
        InstructionsRequest, but the signer is a calling program's PDA (the
        on-chain authority that will `invoke_signed` into `route`) rather than a
        wallet.
      properties:
        authority:
          type: string
          description: >-
            The calling program's PDA authority — owns the token accounts and
            signs the swap via invoke_signed inside the integrating program.
          example: EJxE7RDaP5pmoVzzHRb4fufCNq3wsCgdUbJ8PCXHZNUP
        inputMint:
          type: string
          example: So11111111111111111111111111111111111111112
        outputMint:
          type: string
          example: uSd2czE61Evaf76RNbq4KPpXnkiL3irdzgLFUMe3NoG
        amount:
          type: string
          description: Amount in the smallest token units.
          example: '1000000000'
        swapMode:
          type: string
          enum:
            - ExactIn
            - ExactOut
          example: ExactIn
        slippageBps:
          type: integer
          default: 50
          example: 50
      required:
        - authority
        - inputMint
        - outputMint
        - amount
        - swapMode
    RouteCPIAccountsResponse:
      type: object
      description: >-
        The `route` instruction shaped for a CPI caller. Forward
        `routeInstruction.accounts` into your program's `route` CPI and sign
        with the PDA seeds. `requiredTokenAccounts` are the ATAs the authority
        PDA must own and fund before the CPI runs — this builder emits no
        ATA-create or wrap/unwrap instructions.
      properties:
        authority:
          type: string
          description: >-
            The calling program's PDA that owns the token accounts and signs the
            swap. Echoed back for clarity.
          example: EJxE7RDaP5pmoVzzHRb4fufCNq3wsCgdUbJ8PCXHZNUP
        amountIn:
          type: string
          example: '1000000000'
        amountOut:
          type: string
          example: '145320000'
        otherAmountThreshold:
          type: string
          description: >-
            Slippage-adjusted threshold. ExactIn: minimum output. ExactOut:
            maximum input.
          example: '144593400'
        feeAmount:
          type: string
          example: '100005'
        platformFeeBps:
          type: integer
          example: 0
        platformFeeAmount:
          type: string
          example: '0'
        route:
          type: array
          items:
            type: string
          description: Token path from input to output.
        hopCount:
          type: integer
          example: 1
        pools:
          type: array
          items:
            type: string
          description: Pool addresses used in the route.
        routeInstruction:
          $ref: '#/components/schemas/RawInstruction'
          description: >-
            The Vulcx `route` instruction to CPI into. Its account list is the
            ordered set the calling program must forward (authority is marked
            signer, and writable when any hop is Moonit).
        requiredTokenAccounts:
          type: array
          items:
            type: string
          description: >-
            ATAs owned by the authority PDA that must exist and hold the input
            funds before the CPI runs. Ordered [inputMint, ...intermediates,
            outputMint].
        addressLookupTableAddresses:
          type: array
          items:
            type: string
          description: >-
            Address Lookup Table addresses that compress accounts in
            routeInstruction.
      required:
        - authority
        - amountIn
        - amountOut
        - otherAmountThreshold
        - feeAmount
        - platformFeeBps
        - platformFeeAmount
        - route
        - hopCount
        - pools
        - routeInstruction
        - requiredTokenAccounts
        - addressLookupTableAddresses
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
          example: no route found
      required:
        - success
        - error
    RawInstruction:
      type: object
      description: A single instruction.
      properties:
        programId:
          type: string
          description: Base58-encoded program ID.
        data:
          type: string
          description: Base64-encoded instruction data.
        accounts:
          type: array
          items:
            $ref: '#/components/schemas/RawAccountMeta'
      required:
        - programId
        - data
        - accounts
    RawAccountMeta:
      type: object
      properties:
        publicKey:
          type: string
          description: Base58-encoded account public key.
        isSigner:
          type: boolean
        isWritable:
          type: boolean
      required:
        - publicKey
        - isSigner
        - isWritable
  securitySchemes:
    ApiKeyHeader:
      type: http
      scheme: bearer
      description: >-
        API key sent as `Authorization: Bearer vulcx_...`. Required on every
        endpoint except `GET /health` and `GET /api/v1/tokens`.
    ApiKeyQuery:
      type: apiKey
      in: query
      name: key
      description: >-
        API key as a `?key=vulcx_...` query parameter — the only option for the
        WebSocket stream (`GET /api/v1/stream`), since browsers can't set custom
        headers on a WS handshake. Also accepted on REST endpoints as a fallback
        to the `Authorization` header.

````

## Related topics

- [CPI Route Accounts](/api-reference/cpi-route-accounts/index.md)
- [Composing Swaps On-Chain (CPI)](/guides/onchain-cpi.md)
- [Vulcx architecture — how swaps are routed on Fogo](/get-started/architecture.md)
- [Swap Overview](/docs/swap/overview.md)
- [Get Instructions](/api-reference/instructions/index.md)
