Skip to main content

Welcome to the Trails API

The Trails API enables seamless cross-chain token swaps, deposits, payments, and smart contract executions in a simplified interface with the Trails protocol.

Authentication

All API requests require an API key passed in the X-Access-Key header.
Get an API key: Sign up and create an API key on the Trails Dashboard

Core Workflow

Every interaction through Trails follows this flow:
1

Get Wallet Balance

Before requesting a quote, fetch the user’s token balances using a multichain Indexer to display total available tokens and amounts for the user to select:
2

Get a Quote

Request a quote to see rates, fees, and routing options for your transaction.
Key Parameters:
  • ownerAddress: User’s wallet address
  • originChainId & destinationChainId: Source and destination chains
  • originTokenAddress & destinationTokenAddress: Token contracts
  • originTokenAmount: Amount to swap (in token’s smallest unit)
  • tradeType: EXACT_INPUT (specify input) or EXACT_OUTPUT (specify output)
Use EXACT_INPUT when you know how much you want to spend, and EXACT_OUTPUT when you know exactly how much you need to receive.
3

(Legacy) Commit the Intent

CommitIntent is deprecated for new integrations. New integrations skip this step and call ExecuteIntent directly on the quoted intent — ExecuteIntent accepts QUOTED intents and folds in the same validation CommitIntent used to perform. Existing callers may still commit before executing.
The intent object contains everything needed to execute the intent and the server rejects mutated payloads, so pass it back unchanged.
Quotes expire 15 minutes after being issued. Call ExecuteIntent (or ExecuteIntentEdge for Solana/Tron origins) within this window, or request a new quote. Committing first does not extend the window; legacy callers still share the same 15-minute quote expiry.
4

Execute the Transaction

Execute the intent using one of two mutually exclusive methods - either a normal transfer to the intent address or a permit operation if a user wants to pay in a non-native gas token:
Send tokens to the intent deposit address, then call ExecuteIntent with the transaction hash:
5

Monitor Completion

Wait for the transaction to complete using the streaming endpoint:
Now you have an end to end API integration with Trails for seamless chain abstraction flows! You can continue this initial integration for specific use cases such as:
  • x402 Payments
  • AI Agents
  • Server-side currency conversion & settlement
  • Fund, Swap, Earn, or Pay for any application
  • Pass in optional calldata to call any smart contract function

Error Handling

The API returns errors in a consistent JSON format:

Error Codes

Handling Errors

Quote Expiration

Quotes have strict time limits:
Always check quote expiration before executing. The intent.expiresAt timestamp is the single deadline for calling ExecuteIntent (or ExecuteIntentEdge), whether or not you committed first.

Rate Limiting

The API uses rate limiting to ensure service reliability. If you exceed limits, you’ll receive HTTP 429 responses. Best practices:
  • Cache GetChains, GetTokenList responses (they change infrequently)
  • Batch balance checks where possible
  • Implement exponential backoff on 429 responses

Next Steps

Explore additional endpoints to enhance your integration:

Transaction Management

  • GetIntent - Retrieve full intent details including quote, fees, and status
  • GetIntentReceipt - Poll for transaction status and get receipt with transaction hashes
  • WaitIntentReceipt - Stream intent updates with automatic polling until completion
  • GetIntentHistory - Get complete transaction history with receipts for a user’s wallet address

Earn

Support

Need help? Join our community: