# Authentication Source: https://docs.afkcrypto.com/api-reference/authentication API keys: creation, format, usage, limits, and security best practices ## API keys All v1 endpoints require an API key in the `x-api-key` header. ### Creating API keys 1. Sign in to the [AFKCrypto dashboard](https://app.afkcrypto.com) 2. Go to the [API Keys](https://app.afkcrypto.com/api-keys) section 3. Click "Generate API Key" 4. Give your key a descriptive name 5. Optional: set an expiration (7 days, 30 days, 90 days, 180 days, or 1 year) 6. Copy the key immediately — it will not be shown again ### Key format ```text theme={null} afk__ Example: afk_xY3z_Ab12cD34Ef56Gh78Ij90Kl12Mn34Op56 ``` * **Prefix**: 4-character identifier for quick lookup * **Random**: 32-character cryptographically secure random string ### Using API keys Include the key with every request in the `x-api-key` header: ```bash theme={null} curl -X GET https://api.afkcrypto.com/api/v1/wallets \ -H "x-api-key: afk_xY3z_Ab12cD34Ef56Gh78Ij90Kl12Mn34Op56" ``` ### Security best practices * **Never commit API keys to version control** — use environment variables * **Rotate keys regularly** — set expiration for temporary access * **Use separate keys per environment** — dev, staging, production * **Revoke unused keys immediately** — reduce attack surface * **Store securely** — use a secrets manager (for example, AWS Secrets Manager or HashiCorp Vault) ### Key expiration API keys can optionally expire after a specified period: * **Never expires** (default): works until revoked * **7 days**: short-term testing or demos * **30 days**: contractor access or trials * **90 days**: recommended for quarterly rotation * **180 days**: semi-annual rotation * **1 year**: annual rotation for stable integrations What happens when a key expires? * Requests with that key return HTTP 401 `UNAUTHORIZED` * The key remains visible in the dashboard for audit history * Create a new key to replace it as needed Monitoring expiration: * Dashboard labels keys as "Expired" or "Expiring soon" (≤ 7 days) * Configure alerts to avoid interruptions ### Key limits * **Maximum active keys**: 10 per user * **Rate limits** apply; see [Rate limiting](/api-reference/introduction/#rate-limiting) * Revoke unused keys to stay under the limit ### Revoking API keys Revoke a key immediately in the dashboard: 1. Open [API Keys](https://app.afkcrypto.com/api-keys) 2. Find the key to revoke 3. Click "Revoke Key" 4. Confirm the action Note: Revocation is permanent and takes effect immediately. ## Related # Contracts Send (EVM) Source: https://docs.afkcrypto.com/api-reference/endpoint/contracts-send POST /contracts/send Send a generic EVM contract transaction with data and optional value. EVM only. Requires `Idempotency-Key` header. ```json 200 theme={null} { "id": "tx_...", "status": "SUBMITTED", "hash": "0x...", "explorerUrl": "https://basescan.org/tx/0x...", "chainName": "Base" } ``` # Send Asset (EVM + Solana) Source: https://docs.afkcrypto.com/api-reference/endpoint/send POST /send Send native assets and tokens on EVM and Solana with idempotent POST requests. Requires `Idempotency-Key` header. ERC20 calls `transfer()`; SPL may create ATA if needed. ```json 200 theme={null} { "id": "tx_...", "status": "SUBMITTED", "hash": "0x...", "explorerUrl": "https://basescan.org/tx/0x...", "chainName": "Base" } ``` # Approve Token (EVM) Source: https://docs.afkcrypto.com/api-reference/endpoint/token-approve POST /token/approve Approve ERC20 allowance for a spender on EVM chains via POST request. EVM only. Requires `Idempotency-Key` header. ```json 200 theme={null} { "id": "tx_...", "status": "SUBMITTED", "hash": "0x...", "explorerUrl": "https://basescan.org/tx/0x...", "chainName": "Base" } ``` # Trade Quote (EVM + Solana) Source: https://docs.afkcrypto.com/api-reference/endpoint/trade-quote POST /trade/quote Get swap quotes on EVM and Solana for a token pair and amount. Use `NATIVE` keyword for `fromToken`/`toToken` to trade native assets (ETH, SOL, etc.). Rate-limited (15/min per user). Solana mainnet only (devnet/testnet not supported). If `from` provided with ERC20, returns `approvalNeeded` and `spender`. ```json 200 theme={null} { "quote": { "srcAmount": "1000000000000000000", "dstAmount": "998700000000000000", "fromToken": "0xSrc", "toToken": "0xDst", "approvalNeeded": true, "spender": "0xRouter", "allowanceTarget": "0xRouter", "raw": { "...": "..." } } } ``` # Trade Swap (EVM + Solana) Source: https://docs.afkcrypto.com/api-reference/endpoint/trade-swap POST /trade/swap Execute a token swap using a prior quote or inline build on EVM or Solana. Use `NATIVE` keyword for `fromToken`/`toToken` to swap native assets (ETH, SOL, etc.). Requires `Idempotency-Key` header. Solana mainnet only. For EVM, approve token first if swap fails with allowance error. ```json 200 theme={null} { "id": "tx_...", "status": "SUBMITTED", "hash": "0x...", "explorerUrl": "https://solscan.io/tx/...", "chainName": "Solana" } ``` # Get Transaction Source: https://docs.afkcrypto.com/api-reference/endpoint/tx GET /tx/{id} Look up a transaction created by AFK and retrieve status and hash. Returns 404 if transaction does not exist for authenticated user. ```json 200 theme={null} { "id":"tx_cuid_here", "status":"CONFIRMED", "hash": "0xec04909efc1a39fb777f649d3c1f556cdc529c824b557e172899bd15077c4c01", "explorerUrl": "https://basescan.org/tx/0xec04909efc1a39fb777f649d3c1f556cdc529c824b557e172899bd15077c4c01", "chainName":"Base", "chainType":"ethereum", "chainId":8453, "to":"0xrecipient...", "value":"1000000000000000", "error": null, "createdAt":"2025-08-25T08:00:00.000Z", "updatedAt":"2025-08-25T08:00:05.000Z" } ``` # List Wallets Source: https://docs.afkcrypto.com/api-reference/endpoint/wallets GET /wallets List your wallets across supported chains and identify defaults and automation. `isDefault` and `automationEnabled` are derived from linked accounts. ```json 200 theme={null} { "wallets": [ { "address": "0xabc...", "chainType": "ethereum", "isDefault": true, "automationEnabled": true, "providerType": "embedded", "clientType": "privy" } ] } ``` # Get Wallet Balances Source: https://docs.afkcrypto.com/api-reference/endpoint/wallets-balances GET /wallets/balances Native and token balances for the caller's wallet on a given chain. Native balances cached \~15s; tokens \~45s. `tokens` limited to 50 per request. If `address` provided, must be owned wallet. ```json 200 theme={null} { "balances": [ {"chainType":"ethereum","chainId":8453,"address":"0xabc","asset":"native","token":null,"raw":"1000000000000000000","decimals":18,"symbol":"ETH","updatedAt":"2025-09-08T00:00:00.000Z"}, {"chainType":"ethereum","chainId":8453,"address":"0xabc","asset":"erc20","token":"0xUSDC","raw":"1000000","decimals":6,"symbol":"USDC","updatedAt":"2025-09-08T00:00:00.000Z"} ] } ``` # AFK API v1 Source: https://docs.afkcrypto.com/api-reference/introduction Overview and conventions for AFK Crypto API v1 ## Overview * Base path: `/api/v1` * Authentication: API key via `x-api-key` header * Idempotency: write operations require `Idempotency-Key` header (UUID format) * Response format: all responses include `x-request-id` header for tracking ### Endpoints * `GET /api/v1/wallets` – List user wallets * `GET /api/v1/wallets/balances` – Get balances for caller's wallet (by chain; defaults to default wallet) * `GET /api/v1/wallets/:address/balances` – Get balances for a specific owned wallet * `GET /api/v1/tx/:id` – Get transaction details * `POST /api/v1/send` – Send native assets and tokens (EVM + Solana) * `POST /api/v1/token/approve` – ERC20 token approval (EVM only) * `POST /api/v1/contracts/send` – Generic contract interaction (EVM only) * `POST /api/v1/trade/quote` – Get swap quotes (EVM + Solana) * `POST /api/v1/trade/swap` – Execute swaps (EVM + Solana) ## Chains See the full list in [Supported chains](/api-reference/supported-chains/). Use the `chain` slug (for example, `base`, `solana-devnet`). ## Rate limiting * **Writes** (including `POST /api/v1/trade/quote`): 15 requests per minute per user * **Reads**: 60 requests per minute per user * Response: HTTP 429 when exceeded * Headers: `Retry-After` (seconds until next window) ## Idempotency (writes) * All mutating endpoints require `Idempotency-Key`. * Reusing a key with the exact same request body returns the original 200 response. * Reusing a key with a different body returns HTTP 409 with `code: IDEMPOTENT_BODY_MISMATCH`. * Reusing a key with no stored success response returns HTTP 409 with `code: IDEMPOTENT_REPLAY`. * Keys are scoped to the authenticated user; the endpoint path is recorded for traceability. * Applies to: `POST /api/v1/send`, `POST /api/v1/token/approve`, `POST /api/v1/contracts/send`, `POST /api/v1/trade/swap`. ## Error handling ### Error response format ```json theme={null} { "error": "Human-readable error message", "code": "ERROR_CODE", "requestId": "unique-request-id" } ``` ### Error codes * `UNAUTHORIZED` – Missing/invalid auth or API key (HTTP 401) * `FORBIDDEN` – Authenticated but not allowed to perform the action (HTTP 403) * `NOT_FOUND` – Resource not found (HTTP 404) * `RATE_LIMITED` – Rate limit exceeded (HTTP 429) * `INVALID_INPUT` – Invalid request parameters (HTTP 400) * `WALLET_NOT_FOUND` – Specified wallet not found * `USER_NOT_LINKED` – User not linked to Privy * `WALLET_NOT_DELEGATED` – Wallet not delegated to server signer * `WALLET_ID_REQUIRED` – Missing Privy wallet ID * `CHAIN_UNKNOWN` – Unknown or unsupported chain * `INSUFFICIENT_FUNDS` – Sender lacks funds for value/fee * `IDEMPOTENT_BODY_MISMATCH` – Different request body with same idempotency key (HTTP 409) * `IDEMPOTENT_REPLAY` – Idempotency key already used (HTTP 409) * `PRIVY_RPC_ERROR` – Error from Privy RPC service * `SEND_FAILED` – Transaction submission failed * `SERVICE_UNAVAILABLE` – Required service not configured * `QUOTE_FAILED` – Quote service error (HTTP 400) * `INTERNAL_ERROR` – Server error **QUOTE\_FAILED specifics:** * **Solana/Jupiter**: Some Solana mints are not tradable on Jupiter (curated allowlist). In those cases, this API returns HTTP 400 with `code: QUOTE_FAILED` and an error message like: "Token not tradable on Jupiter". * **EVM/1inch**: If a token is not supported by 1inch, the API returns HTTP 400 with `code: QUOTE_FAILED` and a message like: "Token not tradable on 1inch". * This is expected when the requested output token/mint is marked non-tradable by the upstream provider, even if pools exist elsewhere. ## Validation ### Address formats * EVM: must match `/^0x[a-fA-F0-9]{40}$/` * Solana: must be a valid base58 public key ### Common parameters * **Amounts (EVM)**: Integer strings only (decimal or 0x-hex). Must be non-negative. For ERC20 and `value`, must fit uint256. * **Amounts (Solana)**: Integer strings in base units. SPL amounts must fit unsigned 64-bit range. * **Sender (`from`)**: Optional. If omitted, the user's default wallet for the specified chain is used. * **Idempotency**: All write endpoints require `Idempotency-Key` header. Repeats with the same body return the original response. ### Native token keyword Trade endpoints (`/api/v1/trade/quote`, `/api/v1/trade/swap`) accept the case-insensitive keyword `NATIVE` for `fromToken`/`toToken`: * **EVM**: `NATIVE` resolves to `0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE` * **Solana**: `NATIVE` resolves to wrapped SOL mint `So11111111111111111111111111111111111111112` * Responses return resolved addresses (not `NATIVE`) * Send endpoint uses `asset: "native"` instead of token addresses for native transfers ## Conventions * Chain selection: use the `chain` slug (for example, `base`, `base-sepolia`, `solana-devnet`). * Solana `Transaction.chainId` sentinel mapping: `0` = mainnet, `-2` = testnet, `-3` = devnet. * Idempotency: unique per user and key; repeats return the original response; mismatched bodies → 409. ## Related # Policies & Security Source: https://docs.afkcrypto.com/api-reference/policies-security Non-custodial model, automation, idempotency, and rate limits ## Non-custodial model Enabling Automation allows AFK to sign transactions on your behalf using session-based, non-custodial signing. Keys are never shared with AFK. You can revoke Automation at any time from the Wallets page. ## Idempotency * Send a unique `idempotency-key` per user and operation * Replays with the same key return the original response (or an error if the body differs) ## Rate limits * See [Rate limiting](/api-reference/introduction/#rate-limiting) for current limits * Exceeding returns HTTP 429 with `Retry-After` (seconds) ## Error tracing Every response includes `x-request-id` for support and debugging. # Supported chains Source: https://docs.afkcrypto.com/api-reference/supported-chains Chain slugs and identifiers for EVM and Solana ## EVM chains | Slug | Network | chainId | | ------------ | -------------------- | ------: | | ethereum | Ethereum Mainnet | 1 | | bsc | BNB Smart Chain | 56 | | polygon | Polygon | 137 | | arbitrum | Arbitrum One | 42161 | | base | Base | 8453 | | base-sepolia | Base Sepolia Testnet | 84532 | | avalanche | Avalanche C-Chain | 43114 | ## Solana chains | Slug | Network | | -------------- | -------------- | | solana | Solana Mainnet | | solana-testnet | Solana Testnet | | solana-devnet | Solana Devnet | Use the slug values above (for example, `base`, `solana-devnet`) in the `chain` field of requests. If a chain is missing, contact support and we can evaluate adding it. ### Solana chainId values in Transaction For Solana transactions in the `Transaction` response, `chainId` uses sentinel values: * `0` = Solana Mainnet * `-2` = Solana Testnet * `-3` = Solana Devnet # AFK Crypto Source: https://docs.afkcrypto.com/index Non-custodial wallet automation for EVM and Solana ## What is AFK Crypto? Automate non-custodial wallet actions across EVM and Solana. Use simple REST APIs to send assets, approve tokens, interact with contracts, and trade via aggregators. No custodial risk. Create an account, get your EVM & Solana addresses, and enable automation. ## API overview The core endpoints to automate wallet operations. List caller wallets across chains. Retrieve transaction status by id. Transfer native and token assets. Request quotes and execute swaps on EVM and Solana. Call EVM contracts with data and value. Approve ERC20 allowances. ## What’s next? Explore endpoints and schemas. # Quickstart Source: https://docs.afkcrypto.com/quickstart Your first AFK Crypto API call ## Get started in 4 steps Create an account, enable automation, create an API key, and make your first request. ### Step 1: Sign in Sign in at app.afkcrypto.com. ### Step 2: Enable automation (Wallets) In the Wallets page, toggle on Automation for your address. This enables AFK to sign transactions for automated workflows using session-based, non-custodial signing. You can revoke at any time. ### Step 3: Create API key (wallet automation) In the dashboard's API Keys page, create an API key for wallet automation. * Header: `x-api-key: afk__` * Keep this secret; rotate if compromised See Authentication for details. ### Step 4: Make API calls Set your API key in an environment variable for reuse: ```bash theme={null} export AFK_API_KEY="afk_abcd_xxx" ``` ```bash theme={null} curl -s -H "x-api-key: $AFK_API_KEY" \ "https://api.afkcrypto.com/v1/wallets?chain=ethereum" ``` ```json theme={null} { "wallets": [ { "address": "0xabc...", "chainType": "ethereum", "isDefault": true, "automationEnabled": true, "providerType": "embedded", "clientType": "privy" } ] } ``` Provide `Idempotency-Key: ` on all write endpoints. ```bash theme={null} curl -s -X POST https://api.afkcrypto.com/v1/send \ -H "x-api-key: $AFK_API_KEY" -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "chain":"base-sepolia", "asset":"erc20", "token":"0xToken", "to":"0xRecipient", "amount":"1000000000000000000" }' ``` ```json theme={null} { "id": "tx_...", "status": "SUBMITTED", "hash": "0x...", "explorerUrl": "https://basescan.org/tx/0x...", "chainName": "Base" } ``` ```bash theme={null} curl -s -X POST https://api.afkcrypto.com/v1/contracts/send \ -H "x-api-key: $AFK_API_KEY" -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "chain":"base-sepolia", "to":"0xContract", "data":"0xabcdef...", "value":"0" }' ``` ```bash theme={null} curl -s -X POST https://api.afkcrypto.com/v1/send \ -H "x-api-key: $AFK_API_KEY" -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "chain":"solana-devnet", "asset":"spl", "token":"MintAddress", "to":"RecipientOwnerAddress", "amount":"1000000" }' ``` ```bash theme={null} curl -s -H "x-api-key: $AFK_API_KEY" \ "https://api.afkcrypto.com/v1/tx/tx_cuid_here" ``` ```json theme={null} { "id":"tx_cuid_here", "status":"PENDING", "hash": null, "explorerUrl": null, "chainName":"Base", "chainType":"ethereum", "chainId":8453, "to":"0xrecipient...", "value":"1000000000000000", "error": null, "createdAt":"2025-08-25T08:00:00.000Z", "updatedAt":"2025-08-25T08:00:00.000Z" } ``` ## Next steps Explore the core endpoints next: Transfer native and token assets. Approve ERC20 allowances. Request quotes and execute swaps. Explore endpoints and conventions. **Need help?** Email [hello@afkcrypto.com](mailto:hello@afkcrypto.com) or reach out on Twitter.