Skip to Content
Docs
Exchange rates

Calculate exchange rates

POST/exchange_rates/calculate

Calculates an exchange quote for an amount. Send exactly one of transaction_amount or settlement_amount. Returns 400 "Exchange rates not configured" when no foreign exchange is set up for your account.

Headers

AuthorizationstringRequired
HTTP Basic auth: your API key as the password, with an empty username. See Authentication.
idempotency-keystring

A unique key, such as a UUID, that makes a POST or DELETE request safe to retry. Pay.com keeps each key for 24 hours, separately for each workspace.

  • A retry with the same key, endpoint and body gets the first request's stored status and body, without running the request again.
  • If the first request is still being processed, a retry gets 409 idempotency_error (request_in_progress).
  • The same key on another endpoint, or with another body, gets 400 idempotency_error (invalid_parameters).
  • GET, PUT and PATCH requests ignore the key.

The response repeats the key in its Idempotency-Key header.

Parameters

typestringRequired

Type of the transaction. One of charge, refund, or payout.

One of charge, refund or payout.

transaction_amountinteger

Transaction amount, in the smallest currency unit. Exactly one of transaction_amount or settlement_amount is required.

settlement_amountinteger

Settlement amount, in the smallest currency unit. Exactly one of transaction_amount or settlement_amount is required.

transaction_currencystringRequired

Three-letter ISO currency code of the transaction, in lowercase.

settlement_currencystring

Three-letter ISO currency code of the settlement, in lowercase. Defaults to your account's settlement currency.

markupinteger

Markup to apply when calculating the exchange from a settlement amount. Only allowed together with settlement_amount.

networkstring

Card network. One of visa, mastercard, amex, discover, or jcb. Required when your foreign exchange provider prices by network; otherwise visa is used.

One of visa, mastercard, amex, discover or jcb.

Returns

Returns the calculated exchange rate object.

idstringRequired

Unique identifier for the exchange quote.

resourcestringRequired

String representing the object's type.

typestringRequired

Type of the transaction. One of charge, refund, or payout.

One of charge, refund or payout.

transaction_amountintegerRequired

Transaction amount, in the smallest currency unit.

transaction_amount_human_readablestringRequired

Transaction amount in human-readable format.

transaction_currencystringRequired

Three-letter ISO currency code of the transaction, in lowercase.

settlement_amountintegerRequired

Settlement amount, in the smallest currency unit.

settlement_amount_human_readablestringRequired

Settlement amount in human-readable format.

settlement_currencystringRequired

Three-letter ISO currency code of the settlement, in lowercase.

exchange_ratestringRequired

Exchange rate applied to convert the transaction amount.

valid_untilstringRequired

Time until which the exchange rate is valid, as a Unix timestamp in milliseconds.

markupinteger

Markup applied to the exchange rate, if one was provided in the request.

Errors

400
Invalid request parameters, exchange rates not configured for your account or currency pair, or network missing when your foreign exchange provider requires it.
401
The API key or access token is missing, unknown or no longer works (invalid_key, invalid_token, legacy_keys_ended, legacy_keys_off or permission_denied).
403
The request was refused: the API key may not make it (for example resource_not_allowed, key_disabled, network_not_allowed, pci_required or merchant_required), or this resource isn't enabled for your account (permission_denied). code says why.
409
Another request with the same idempotency-key is still being processed (request_in_progress). Wait, then retry with the same key.
500
Internal server error.
503
Service unavailable. Retry after the number of seconds in Retry-After, or after a few seconds when there's none.
Was this page helpful?