Documentation Index
Fetch the complete documentation index at: https://coinvoyage-3c99945b.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
ApiClient is the server-side interface to the CoinVoyage API. Import it from @coin-voyage/paykit/server and use it in your API routes, server actions, or backend services to create pay orders, retrieve quotes, manage webhooks, and more. Every method returns an APIResponse<T> wrapper that provides consistent, type-safe error handling without throwing exceptions.
Initialization
Your organization’s API key from the CoinVoyage dashboard.
Environment to connect to:
"production" or "development".Optional session identifier attached to every request for tracking purposes.
Optional client version string sent as the
X-Client-Version request header.APIResponse<T>
EveryApiClient method returns a Promise<APIResponse<T>>. The response is always an object with either a data field (on success) or an error field (on failure) — never both.
Handling responses
The typed response payload. Present when the request succeeds.
Error details. Present when the request fails.
Methods
createDepositPayOrder
Creates a pay order with modeDEPOSIT for a direct on-chain deposit to a specified address.
params (PayOrderParams), opts? (Opts)
Returns: Promise<APIResponse<PayOrder>>
createSalePayOrder
Creates a pay order with modeSALE for a merchant sale. Requires your API secret for authorization.
If you omit intent.asset, CoinVoyage settles the payment to the settlement currency configured in your dashboard. If you provide intent.asset, the pay order settles to that specific asset and chain.
The authorization signature is generated internally. You only need to pass the raw
apiSecret string.- Dashboard settlement currency
- Specific settlement asset
intent.asset | Settlement behavior |
|---|---|
| Omitted | Settles to your dashboard settlement currency (must be configured) |
| Provided | Settles to the specified asset and chain for this pay order |
params (PayOrderParams), apiSecret (string), opts? (Opts)
Returns: Promise<APIResponse<PayOrder>>
createRefundPayOrder
Creates a pay order with modeREFUND against an existing pay order. Supports full and partial refunds.
payOrderId (string), params (PayOrderParams), apiSecret (string), opts? (Opts)
Returns: Promise<APIResponse<PayOrder>>
getPayOrder
Fetches a pay order by its ID.payOrderId (string), opts? (Opts)
Returns: Promise<APIResponse<PayOrder>>
payOrderQuote
Generates a quote for a pay order given a user’s wallet and chain information. Returns available payment tokens with balances.payOrderId (string), params (PayOrderQuoteParams), opts? (Opts)
Returns: Promise<APIResponse<RouteQuote[]>>
payOrderPaymentDetails
Retrieves the information needed to complete a payment — destination address, amount, and per-step payment instructions.The unique identifier of the pay order.
Payment rail to use. Defaults to
CRYPTO.Source currency to use for the payment details request, with
chain_id and address.Quote identifier from a previously selected route quote.
Address to which funds are returned if the payment fails.
Promise<APIResponse<PaymentDetails>>
getPayOrderPaymentMethods
Fetches the available payment methods (rails, tokens, availability) for a pay order.payOrderId (string), opts? (Opts)
Returns: Promise<APIResponse<PaymentMethodsResponse>>
generateAuthorizationSignature
Generates an HMAC-SHA256 authorization signature required forSALE and REFUND pay order creation.
apiSecret (string), method (string), path (string)
Returns: string
subscribeOrderStatus
Opens a WebSocket connection for real-time pay order status events. The client authenticates automatically using your API key.OrderStatusSocket
The OrderStatusSocket exposes the following methods:
Subscribe to status events for a specific pay order.
Subscribe to all pay order events for your organization.
Unsubscribe from a specific pay order, or from all subscriptions if
orderId is omitted.Unsubscribe from organization-wide events.
Attach a listener for parsed server messages.
Attach a listener for the WebSocket open event.
Attach a listener for the WebSocket close event.
Attach a listener for WebSocket errors.
Close the WebSocket connection.
Webhook methods
listWebhooks
listWebhooks
Lists all webhooks configured for your organization.Parameters:
apiSecret (string), opts? (Opts)Returns: Promise<APIResponse<WebhookResponse[]>>createWebhook
createWebhook
Creates a new webhook subscription for your organization.Parameters:
params (CreateWebhookRequest), apiSecret (string), opts? (Opts)Returns: Promise<APIResponse<WebhookResponse>>updateWebhook
updateWebhook
Updates an existing webhook subscription.Parameters:
webhookId (string), params (UpdateWebhookRequest), apiSecret (string), opts? (Opts)Returns: Promise<APIResponse<WebhookResponse>>deleteWebhook
deleteWebhook
Deletes a webhook subscription.Parameters:
webhookId (string), apiSecret (string), opts? (Opts)Returns: Promise<APIResponse<void>>Fee methods
getFeeBalances
getFeeBalances
Retrieves claimable fee balances for your organization.Parameters:
apiSecret (string), opts? (Opts)Returns: Promise<APIResponse<GetFeeBalancesResponse>>claimFees
claimFees
Claims accrued fees for your organization.Parameters:
params (ClaimFeesRequest), apiSecret (string), opts? (Opts)Returns: Promise<APIResponse<ClaimFeesResponse>>Swap methods
swapQuote
swapQuote
Gets a quote for swapping between two currencies.Parameters:
params (SwapQuoteRequest), opts? (Opts)Returns: Promise<APIResponse<SwapQuoteResponse>>swapData
swapData
Gets the transaction data needed to execute a swap.Parameters:
params (SwapDataRequest), opts? (Opts)Returns: Promise<APIResponse<SwapDataResponse>>createPayOrder (low-level)
A lower-level helper that creates a pay order with an explicitmode. In most integrations you should use the mode-specific helpers above (createDepositPayOrder, createSalePayOrder, createRefundPayOrder). Use createPayOrder only when you need direct control over the mode and authorization signature.
params (PayOrderParams), mode (PayOrderMode), signature? (string), opts? (Opts)
Returns: Promise<APIResponse<PayOrder>>
ApiClient does not expose a processPayOrder() method — pay order processing begins automatically once funds are detected on-chain. There is also no listPayOrders() helper; use the GET /pay-orders HTTP endpoint directly if you need it.TypeScript types
The SDK exports the following TypeScript types for use in your application.PayOrder
The main pay order object returned by API methods.PayOrderMode
| Value | Description |
|---|---|
SALE | Merchant sale. Settles to the dashboard settlement currency unless intent.asset is provided. |
DEPOSIT | Direct deposit to a specified address on a target chain. |
REFUND | Full or partial refund of a previous pay order. |
PayOrderStatus
| Status | Description |
|---|---|
PENDING | Created but not yet ready for payment. |
AWAITING_PAYMENT | Ready and waiting for the user to send payment. |
AWAITING_CONFIRMATION | Payment transaction detected; waiting for blockchain confirmation. |
OPTIMISTIC_CONFIRMED | Optimistically confirmed; execution can begin. |
EXECUTING_ORDER | Payment is being routed to the destination. |
COMPLETED | Completed successfully. |
FAILED | Failed during processing. |
EXPIRED | Expired before payment was received. |
REFUNDED | Refunded to the configured refund address. |
PARTIAL_PAYMENT | Received an insufficient amount; reached a terminal partial-payment state. |
PayOrderMetadata
PayOrderParams
PayOrderIntent
IntentAmount
Provide eithertoken_amount or fiat — not both.
FulfillmentData
PaymentData
CurrencyAmount
Human-readable amount (e.g.,
1.5 for 1.5 ETH).Formatted display string suitable for rendering in UI.
Raw amount as a string to prevent BigInt precision loss.
USD equivalent value of the amount.
WebhookEventType
| Event | Payload type | Description |
|---|---|---|
ORDER_CREATED | payorder_created | A new pay order was created. |
ORDER_AWAITING_PAYMENT | payorder_started | The pay order is ready for payment. |
ORDER_CONFIRMING | payorder_confirming | Payment detected and confirming on-chain. |
ORDER_EXECUTING | payorder_executing | Payment execution has begun. |
ORDER_COMPLETED | payorder_completed | The pay order completed successfully. |
ORDER_ERROR | payorder_error | An error occurred during processing. |
ORDER_REFUNDED | payorder_refunded | A refund was processed. |
ORDER_EXPIRED | payorder_expired | The pay order expired before payment was received. |