> ## Documentation Index
> Fetch the complete documentation index at: https://exchanger-api.iexexchanger.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Prompts for Exchanger API

> Copy prompts for Codex, Claude Code, and Cursor to connect to the API, integrate exchanges, receive webhooks, and diagnose errors.

Choose a task and copy the prompt into Codex, Claude Code, Cursor, or another coding assistant. Each prompt includes contract links, expected deliverables, and verification steps.

Open your project in the assistant and replace the bracketed values. For example, use `PHP 8.5` for `[STACK]`. Remove customer data from any error responses you share. Keep API tokens, HMAC secrets, and payment details out of the chat.

Connect the [documentation MCP server](https://exchanger-api.iexexchanger.com/en/guides/ai/overview.md) so the assistant can look up operations and guidance. The prompt links also work without MCP.

## Connect to the API

> [accordion] Make the first request
>
> Public and signed pings with response checks.
>
> ```text theme={null}
> Prepare the first Exchanger API v3 request for my project.
> My stack is [STACK]. If it is unspecified, use the existing server stack
> or Node.js 24 for a standalone example.
>
> Verify the URL, signing headers and response format against these guides.
> https://exchanger-api.iexexchanger.com/en/start/quickstart
> https://exchanger-api.iexexchanger.com/en/start/authentication
>
> Provide two modes. GET /api/v3/ping checks the API address without credentials.
> GET /api/v3/private/ping checks the token and HMAC v2 without another scope.
> Read EXCHANGER_API_ORIGIN, EXCHANGER_API_TOKEN and EXCHANGER_API_HMAC_SECRET
> from the environment. Use https://your-exchange in examples.
> Add a timeout and check the HTTP status, state and result.status. On an error,
> report only the HTTP status, error.code and meta.request_id when available.
>
> Provide runnable code, commands and expected output.
> Verify the HMAC test vector and the 200 and 401 cases locally.
> Use fixtures and a local HTTP mock. Leave requests to a live exchanger to the
> operator and keep real tokens and secrets out of the conversation.
> ```
>
> [Quickstart](https://exchanger-api.iexexchanger.com/en/start/quickstart.md)

> [accordion] Verify an HMAC v2 signer
>
> Canonical query and body, a test vector, and signature checks.
>
> ```text theme={null}
> Implement and test an Exchanger API v3 signing client in [STACK]. Read the current signing contract and retry rules first.
>
> Signing: https://exchanger-api.iexexchanger.com/en/start/authentication
> First request: https://exchanger-api.iexexchanger.com/en/start/quickstart
> Retries: https://exchanger-api.iexexchanger.com/en/guides/reliability/idempotency
>
> Join eight fields with LF in this order: v2, the uppercase method, the path including /api/v3 without the origin or query, the canonical query, the SHA-256 body digest in hex, the timestamp, the nonce, and Idempotency-Key trimmed at both ends. Preserve empty fields. Encode and sort query pairs according to the contract's RFC 3986 rules and preserve list indexes. Calculate HMAC-SHA256 over the UTF-8 canonical string with the HMAC secret as issued. Send X-Api-Signature-Version: v2, X-Api-Timestamp, X-Api-Nonce, and X-Api-Signature as sha256=<hex>. Read the Bearer token from client configuration and send it separately in Authorization.
>
> Hash the same bytes the transport sends. Serialize JSON once. For multipart, hash the contents of the single file field instead of the multipart body. Generate a fresh timestamp and nonce for each attempt. Reuse the Idempotency-Key and original input when retrying the same write.
>
> Verify the published test vector offline. Test empty query and body, a changed JSON byte, query sorting, list order, file hashing, and a changed Idempotency-Key. Use mocked responses to test signature_required, invalid_signature, signature_expired, and signature_replay. Use synthetic data and a mock transport. Return the code, tests, and their actual results.
> ```
>
> [HMAC v2 signatures](https://exchanger-api.iexexchanger.com/en/start/authentication.md)

> [accordion] Set up API access and key scopes
>
> A minimum-scope map and setup steps for the operator.
>
> ```text theme={null}
> Find the minimum scopes for one Exchanger API key to perform these operations: [OPERATIONS]. If the input describes a task, identify its methods in the reference. Verify each HTTP method, path, and x-required-scopes against the documentation.
>
> API reference: https://exchanger-api.iexexchanger.com/en/api
> Admin settings: https://exchanger-api.iexexchanger.com/en/guides/admin/api-keys
> Create a key: https://exchanger-api.iexexchanger.com/en/start/access
> Diagnostics: https://exchanger-api.iexexchanger.com/en/guides/reliability/errors
>
> Return a table with the operation, HTTP method and path, accepted scopes, and the selected scope with its reason. Also provide the minimum combined set. When a method accepts multiple scopes, any one is sufficient. Flag scopes that grant write access. Link to the reference for each method. If the mapping is ambiguous, identify the missing details.
>
> Separate manual actions for the administrator and the client: enable the exchanger API, grant account access, create a key in the account, and configure the active key's scopes. Explain how to distinguish a token or signature failure from an account, IP, or scope restriction. For scope_denied, compare error.details.required_scopes with the scope map.
>
> Validate the map against the documentation. Propose a test plan that starts with public ping and signed private ping on a test installation. Private ping has no separate scope and verifies credentials and signing only. To verify scopes, plan a safe read using the requested scope if one exists. For a write-only scope, verify it in the reference and describe a mock test. Return analysis and manual steps. Leave settings and keys unchanged, and send no requests to the admin panel or production API.
> ```
>
> [API access and keys](https://exchanger-api.iexexchanger.com/en/guides/admin/api-keys.md)

## Exchange workflows

> [accordion] Quote and validate an order
>
> Quote snapshots and preflight decisions.
>
> ```text theme={null}
> Implement a server-side quote → order preflight workflow for Exchanger API v3 in [STACK]. The inputs are the selected route, amount, and completed form. Show the user the quoted amount and whether the form is ready to submit.
>
> Check the contract against the documentation:
> - https://exchanger-api.iexexchanger.com/en/guides/exchange/catalog
> - https://exchanger-api.iexexchanger.com/en/guides/exchange/quote-and-preflight
> - https://exchanger-api.iexexchanger.com/en/start/authentication
> - https://exchanger-api.iexexchanger.com/en/guides/reliability/errors
>
> 1. Use signed HTTP on the server. Verify HMAC v2 against the documented example, set a timeout, and read configuration from the environment. Run tests against local mocks with synthetic values. Do not request real credentials or send requests to a live exchanger.
> 2. Call POST /api/v3/private/exchange/quotes with public-api:exchange:quotes:read. Send route_id, the amount as a decimal string, and only the options relevant to the selected route. Read amounts from result.quote.amounts and keep result.snapshot intact.
> 3. Add the snapshot and form fields to the quote input and call POST /api/v3/private/exchange/orders/preflight. Preflight accepts either public-api:exchange:preflight:read or public-api:exchange:quotes:read. Enable the next step only when result.preflight.can_create_order is true. When it is false, display missing_fields and validation_issues. checks.external: deferred means that external checks run during creation.
> 4. Request a fresh quote when the amount, route, or quote options change. On HTTP 422, inspect validation errors for the snapshot field. If the snapshot has expired, quote again and rerun preflight with the intact new object. Handle HTTP errors separately from a validation result delivered in HTTP 200. Return the validated form with result.preflight.snapshot to the caller on success. End the workflow at preflight without creating an order.
>
> Add local tests for a successful quote, decimal strings, unchanged snapshot forwarding, HTTP 200 with can_create_order: false, and a snapshot field error. Report the changed files and the command to run the tests.
> ```
>
> [Quotes and preflight](https://exchanger-api.iexexchanger.com/en/guides/exchange/quote-and-preflight.md)

> [accordion] Create an order and track payment
>
> Order creation, payment instructions, order status, and confirmed receipt.
>
> ```text theme={null}
> Implement a server-side order creation and payment reconciliation workflow for Exchanger API v3 in [STACK]. The inputs are form data that passed preflight and the customer's explicit confirmation. Display order status, payment instructions, and confirmed receipt as separate values.
>
> Check the contract against the documentation:
> - https://exchanger-api.iexexchanger.com/en/guides/exchange/create-order
> - https://exchanger-api.iexexchanger.com/en/guides/exchange/payment-and-status
> - https://exchanger-api.iexexchanger.com/en/start/authentication
> - https://exchanger-api.iexexchanger.com/en/guides/reliability/idempotency
> - https://exchanger-api.iexexchanger.com/en/guides/reliability/webhooks
>
> 1. Sign HTTP requests with HMAC v2. Set a timeout and read configuration from the environment. Develop and test with local mocks and synthetic responses. Do not request real secrets or create orders, subscriptions, or payments on a live exchanger.
> 2. Before POST /api/v3/private/exchange/orders, save the exact body and the Idempotency-Key for the operation. Creation requires public-api:exchange:orders:create. After 201, save tracking_id or public_id as a string from result.order. After a timeout, retry with the same body and key and a fresh signature. On idempotency_conflict, surface the error and reconcile the original operation.
> 3. Read payment-instructions and payment-status with public-api:exchange:payment-instructions:read. If preparation is needed, check prepare_payment through GET /api/v3/private/exchange/orders/{order}/actions. That request accepts any of public-api:exchange:orders:actions:read, public-api:orders:detail:read, or public-api:orders:read. Call POST payment-instructions only when allowed and authorized and with public-api:exchange:payment-instructions:write. Display payment details from GET when status is ready. Keep a customer's paid declaration separate from confirmed receipt.
> 4. Read status-summary with public-api:orders:detail:read or public-api:orders:read. Treat result.status.key: completed as a completed exchange. Read confirmed receipt separately in result.payment.provider_confirmed and provider_confirmed_at. On 403 check the scope, and on 404 check that the order belongs to the key owner. If a webhook is connected, verify its v2 signature over the original bytes with the subscription secret, deduplicate by event ID, and reread state after order.status_changed or order.payment_received.
>
> Add local tests for a lost create response and replay, a key conflict, payment instructions that are not ready, and the difference between a paid order status and provider confirmation. If you add webhooks, test duplicate deliveries and a tampered signature. Report the command to run the tests.
> ```
>
> [Payment instructions and status](https://exchanger-api.iexexchanger.com/en/guides/exchange/payment-and-status.md)

> [accordion] Test the integration on a staging exchanger
>
> Fixtures, simulations, and form error cases.
>
> ```text theme={null}
> Prepare acceptance tests for my exchange flow in [STACK].
> Use [TEST_SCENARIO], or choose one route and use synthetic data.
>
> Check the supported steps and response fields.
> https://exchanger-api.iexexchanger.com/en/api-reference/sandbox/post-private-sandbox-exchange-orders-simulate
> https://exchanger-api.iexexchanger.com/en/guides/exchange/quote-and-preflight
> https://exchanger-api.iexexchanger.com/en/guides/reliability/webhook-deliveries
>
> Cover a valid form, amount = "0" and one missing required field in local tests.
> Distinguish HTTP 422 validation_failed from HTTP 200 with
> preflight.can_create_order = false. On a successful simulation, assert
> will_create_order = false, created_task_id = null and the presence of event_id.
> Link the api.sandbox.simulated event to that event_id.
>
> Return a table of inputs, expected responses and acceptance checks.
> Show how to run locally without API credentials and how an operator can run
> the simulation on a separate installation with public-api:sandbox:run.
> List order creation, retries and payment reconciliation as separate tests
> for that installation. Keep live requests and real payment data out of the tests.
> ```
>
> [Order simulation](https://exchanger-api.iexexchanger.com/en/api-reference/sandbox/post-private-sandbox-exchange-orders-simulate.md)

> [accordion] Build a partner report
>
> Read-only reporting for statistics, referrals, and payouts.
>
> ```text theme={null}
> Implement a read-only Exchanger API v3 partner report in [STACK]. Include the referral link, balance, and earnings and payout history with separate totals per currency.
>
> Check fields and scopes against the documentation:
> - https://exchanger-api.iexexchanger.com/en/guides/account/partner
> - https://exchanger-api.iexexchanger.com/en/start/authentication
> - https://exchanger-api.iexexchanger.com/en/start/protocol
> - https://exchanger-api.iexexchanger.com/en/guides/reliability/errors
>
> 1. Send signed GET requests on the server with HMAC v2, a timeout, and configuration from the environment. The report covers the key owner's data. Test against a local mock with synthetic responses. Use no real tokens or secrets. Keep all writes, payout previews, and payout creation permissions out of the report.
> 2. Request only the data you need under /api/v3/private/partner. The profile uses public-api:partner:read, /statistics uses public-api:partner:statistics:read, /referrals uses public-api:partner:referrals:read, /exchanges uses public-api:partner:exchanges:read, and /payouts uses public-api:partner:payouts:read. Display result.referral_link.url when a link exists.
> 3. Start history requests with pagination=cursor and send meta.pagination.next_cursor as cursor with the same filters and sort until the list ends. Read the available balance from result.balance.available. For account-wide totals, use result.statistics.exchanges.by_currency and result.statistics.payouts.by_currency. For filtered earnings, use meta.summary.by_currency once and display pending entries and reversals separately from the history. For filtered payouts, use meta.summary for counts once and sum result[].amount.requested across pages by status and currency.code. Preserve decimal precision and keep a separate bucket for unknown currency.
> 4. On 403 scope_denied, show the scopes in error.details.required_scopes. For other 403 responses, use the actual error.code. Distinguish rate_limit_exceeded from quota_exceeded on 429. Observe Retry-After for rate limits and the quota reset time for exhausted quotas.
>
> Add local tests for repeated summaries on multiple pages, a payout status filter, mixed and unknown currencies, reversals, a missing referral link, and access errors. Verify that the report sends only GET requests and counts amounts once. Report the test command and briefly list the fields in the resulting report.
> ```
>
> [Partner program](https://exchanger-api.iexexchanger.com/en/guides/account/partner.md)

## Reliability and launch

> [accordion] Implement a webhook receiver
>
> Signature verification, deduplication, and reconciliation.
>
> ```text theme={null}
> Implement an Exchanger API webhook receiver in [STACK]. Inspect the project's HTTP routing, storage and tests. Use direct HTTP and a local fixture secret.
>
> Capture the original POST bytes before parsing JSON. Verify HMAC v2 with the subscription secret and the documented test vector. Match the signed event ID and type to the body. Persist verified events in a durable inbox with a unique key for source, receiver and event ID. Return 2xx after commit. A verified duplicate should return 2xx without a second insert. Handle api.test separately. Fetch the resource for the current payment state because deliveries can arrive out of order.
>
> Test a valid delivery, a retry with the same ID and a fresh signature, a changed byte, an expired signature and a storage outage. Finish when the first two requests create one record, the other cases receive no successful acknowledgment, and all tests run without contacting an exchange. Show the changes and test results.
>
> Documentation
> https://exchanger-api.iexexchanger.com/en/guides/reliability/webhooks
> https://exchanger-api.iexexchanger.com/en/guides/reliability/webhook-deliveries
> ```
>
> [Receive and verify a webhook](https://exchanger-api.iexexchanger.com/en/guides/reliability/webhooks.md)

> [accordion] Recover a write after a timeout
>
> Recover an unknown write outcome and retry within the API contract.
>
> ```text theme={null}
> Add recovery for an Exchanger API timeout on [METHOD_AND_PATH] in a [STACK] client. Check the operation reference for Idempotency-Key support, whether the header is required, and how long the result is retained. Use direct HTTP. If safe replay is unconfirmed, implement reconciliation or an operator handoff.
>
> Persist the operation key and original request before the first send. Treat a lost response as an unknown outcome. Read the resource when its ID is available. For supported retries preserve the method, path, parameters, body and key. Sign each attempt with a current timestamp and fresh nonce. Wait on idempotency_in_progress and stop on idempotency_conflict. Bound the retry count. After an ordinary receipt expires, the same key can start a new operation.
>
> Use a local HTTP fixture and test secret. Simulate the server committing a write and losing its first response. Show that the test observes one business operation, the same key on replay, different nonces and valid signatures. Include a conflicting request and an expired receipt with an unknown outcome. Run the checks without production credentials or live operations.
>
> Documentation
> https://exchanger-api.iexexchanger.com/en/guides/reliability/idempotency
> https://exchanger-api.iexexchanger.com/en/start/authentication
> https://exchanger-api.iexexchanger.com/en/guides/reliability/errors
> ```
>
> [Idempotency and retries](https://exchanger-api.iexexchanger.com/en/guides/reliability/idempotency.md)

> [accordion] Diagnose an API error
>
> The likely cause, a safe next action, and details for the operator.
>
> ```text theme={null}
> Diagnose an Exchanger API v3 error and give me a safe next action.
> I have [METHOD_AND_PATH], [HTTP_STATUS] and [REDACTED_RESPONSE].
> If I received no response, treat the request outcome as unknown.
>
> Check the relevant operation and the retry rules.
> https://exchanger-api.iexexchanger.com/en/api
> https://exchanger-api.iexexchanger.com/en/guides/reliability/errors
> https://exchanger-api.iexexchanger.com/en/guides/reliability/idempotency
>
> Use the HTTP status, error.code, redacted error.details and any rate limit
> or quota headers. For 429, distinguish rate_limit_exceeded from quota_exceeded.
> If a proxy returned a response without JSON, state what the response supports.
> When uncertain, give a check that would distinguish the likely causes.
>
> Report the likely cause, first diagnostic check, reference links and retry decision.
> After a write times out, verify the operation before retrying. Reuse the original
> idempotency key with a fresh signature only when the method supports it.
> List what to send the operator, including request_id and correlation_id.
> Analyze the supplied evidence without making requests or asking for credentials
> or payment details.
> ```
>
> [API error reference](https://exchanger-api.iexexchanger.com/en/guides/reliability/errors.md)

> [accordion] Review production readiness
>
> Access, failure recovery, payments, and monitoring checks before launch.
>
> ```text theme={null}
> Review a [STACK] Exchanger API integration before launch. Inspect the repository, configuration names and existing tests. Limit the review to operations the client actually calls over HTTP. Keep credentials out of the review output and do not send requests to a production exchange.
>
> Check each route's scopes, server-side secret storage, signing input, monetary precision and error handling against the contract. For writes, inspect timeout recovery and operation keys. If the client receives webhooks, check v2 verification, durable storage before 2xx and duplicate handling. Distinguish per-minute rate limits from exhausted quotas. Confirm diagnostic reports preserve request IDs and redact secrets and personal data.
>
> Run the published signature vector and local fixture tests for 401, 429 and a timeout using synthetic data. For each finding identify the affected route, code location, observed consequence and a verification step. Finish with the scenarios that passed, the unverified scenarios and why, and the remaining checks that require a test installation.
>
> Documentation
> https://exchanger-api.iexexchanger.com/en/guides/reliability/production
> https://exchanger-api.iexexchanger.com/en/guides/reliability/errors
> https://exchanger-api.iexexchanger.com/en/start/authentication
> ```
>
> [Production readiness](https://exchanger-api.iexexchanger.com/en/guides/reliability/production.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.