Skip to main content

Pay REST API Reference

This document describes Coinbase Pay APIs.

Buy Config

The Buy Config API returns the list of countries supported by Coinbase Pay, and the payment methods available in each country. Clients can call this API periodically and cache the response so that they know which users to present the Coinbase Pay Onramp option to.

Method

GET

URL

https://pay.coinbase.com/api/v1/buy/config

Request Parameters

The Buy Config API has no request parameters.

Response Fields

The Buy Config API returns a JSON response including the following fields.

NameDescription
countriesA list of supported countries, represented by their ISO 3166-1 two digit country code. Each country contains a list of payment method types available in that country; for the US it also contains a list of supported states.

Example Request/Response

curl https://pay.coinbase.com/api/v1/buy/config /
-X GET \
-H 'CBPAY-VERSION: XXXX-XX-XX' \
-H 'CBPAY-APP-ID: XXXXXXXXXXXXXXXXXXXXXXXXX' \
-H 'CBPAY-API-KEY: XXXXXXXXXXXXXXXXXXXXXXXXX'

Buy Options

The Buy Options API provides clients with a way to discover the available options for buying Crypto with CBPay. It returns the supported fiat currencies and available crypto assets that can be passed into the Buy Quote API.

Method

GET

URL

https://pay.coinbase.com/api/v1/buy/options

Request Parameters

NameReqDescription
countryYISO 3166-1 two-digit country code string representing the purchasing user’s country of residence, e.g., US.
subdivisionNISO 3166-2 two-digit country subdivision code representing the purchasing user’s subdivision of residence within their country, e.g. NY. Required if the country=“US” because certain states (e.g., NY) have state specific asset restrictions.

Response Fields

The Buy Options API returns a JSON response including the following fields.

NameDescription
payment_currenciesList of supported fiat currencies that can be exchanged for crypto on CBPay in the given location. Each currency contains a list of available payment methods, with min and max transaction limits for that currency.
purchase_currenciesList of available crypto assets that can be bought on CBPay in the given location.

Example Request/Response

curl https://pay.coinbase.com/api/v1/buy/options?country=US&subdivision=NY /
-X GET \
-H 'CBPAY-VERSION: XXXX-XX-XX' \
-H 'CBPAY-APP-ID: XXXXXXXXXXXXXXXXXXXXXXXXX' \
-H 'CBPAY-API-KEY: XXXXXXXXXXXXXXXXXXXXXXXXX'

Buy Quote

The Buy Quote API provides clients with a quote based on the asset the user would like to purchase, the network they plan to purchase it on, the dollar amount of the payment, the payment currency, the payment method, and country of the user.

Limitations

The quote provided by this API is an estimate only. It does not guarantee that the user will be able to complete their purchase using the returned quote. Depending on fluctuations in network fees and exchange rates, and whether or not the user chooses the logged in or guest checkout experience, the actual fees charged may be different.

Method

POST

URL

https://pay.coinbase.com/api/v1/buy/quote

Request Parameters

The Buy Quote API is an RPC endpoint that accepts parameters as JSON in the request body.

NameTypeReqDescription
purchase_currencyYID of the crypto asset the user wants to purchase. Retrieved from the options API.
purchase_networkNName of the network that the purchase currency should be purchased on. Retrieved from the options API. If omitted, the default network for the crypto currency is used.
payment_amountStringYFiat amount the user wants to spend to purchase the crypto currency, inclusive of fees with two decimals of precision, e.g., 100.00.
payment_currencyStringYFiat currency of the payment amount, e.g., USD.
payment_methodYID of payment method used to complete the purchase. Retrieved from the options API.
countryYISO 3166-1 two-digit country code string representing the purchasing user’s country of residence, e.g., US.
subdivisionNISO 3166-2 two-digit country subdivision code representing the purchasing user’s subdivision of residence within their country, e.g. NY. Required if the country=“US” because certain states (e.g., NY) have state specific asset restrictions.

Response Fields

The Buy Options API returns a JSON response including the following fields.

NameDescription
payment_totalObject with amount and currency of the total fiat payment required to complete the purchase, inclusive of any fees. The currency will match the payment_currency in the request if it is supported, otherwise it falls back to USD.
payment_subtotalObject with amount and currency of the fiat cost of the crypto asset to be purchased, exclusive of any fees. The currency will match the payment_total currency.
purchase_amountObject with amount and currency of the crypto that to be purchased. The currency will match the purchase_currency in the request. The number of decimals will be based on the crypto asset.
coinbase_feeObject with amount and currency of the fee changed by the Coinbase exchange to complete the transaction. The currency will match the payment_total currency.
network_feeObject with amount and currency of the network fee required to send the purchased crypto to the user’s wallet. The currency will match the payment_total currency.
quote_idReference to the quote that should be passed into the initialization parameters when launching the Coinbase Pay widget via the SDK or URL generator.

Example Request/Response

curl https://pay.coinbase.com/api/v1/buy/quote /
-X POST \
-H 'Content-Type: application/json' \
-H 'CBPAY-VERSION: XXXX-XX-XX' \
-H 'CBPAY-APP-ID: XXXXXXXXXXXXXXXXXXXXXXXXX' \
-H 'CBPAY-API-KEY: XXXXXXXXXXXXXXXXXXXXXXXXX' \
-d '{"purchase_currency": "BTC", "payment_amount": "100.00", "payment_currency": "USD", "payment_method": "CARD", "country": "US", "subdivision": "NY"}'

Onramp Session Token

The Onramp Session Token API provides a secure way for the client to initialize the Pay SDK. For clients that are integrated with this API, the standard way of initializing the Pay SDK, by passing in an App ID and Destination Wallets as parameters, does not work.

Clients must first call the Onramp Session Token API to obtain a token, and pass that token into the Pay SDK as the sessionToken query string parameter when generating the URL manually. The token will expire after a short period of time, and can only be used once. A new token must be obtained for every new session.

Method

POST

URL

https://pay.coinbase.com/api/v1/onramp/token

Request Parameters

The Onramp Session Token API is an RPC endpoint that accepts parameters as JSON in the request body.

NameTypeReqDescription
destination_walletsDestinationWallet[]YArray of destination wallet addresses that the purchased crypto should be sent to. Each entry in this array is an object containing an address and an optional list of blockchains or asset IDs that the address supports.

Response Fields

The Onramp Session Token API returns a JSON response including the following fields.

NameDescription
tokenA unique string that can be passed into the Pay SDK as the sessionToken parameter when manually generating a URL to initialize the onramp widget (the resulting URL will look like https://pay.coinbase.com/buy/select-asset?sessionToken=<token>&<other params>). This token is associated with the Destination Wallets and App ID header provided in the request. This token can only be used once per session.
channel_idNot yet functional. Upcoming implementation: A socket.io channel ID that can be used to receive events from the Pay SDK while the customer goes through the transaction flow.

Example Request/Response

curl https://pay.coinbase.com/api/v1/onramp/token /
-X POST \
-H 'Content-Type: application/json' \
-H 'CBPAY-VERSION: XXXX-XX-XX' \
-H 'CBPAY-APP-ID: XXXXXXXXXXXXXXXXXXXXXXXXX' \
-H 'CBPAY-API-KEY: XXXXXXXXXXXXXXXXXXXXXXXXX' \
-d '{"destination_wallets": [{"address":"bc1qrdvlkt8rqsyj229thqzhm0q39edwdj2k7yps6x", "blockchains": ["bitcoin"]}]}'

Transaction Status

The Transaction Status API provides clients with a list of user CBPay transactions. You can poll the real time status of transactions and show users a view of their Coinbase Pay transactions made within the client app.

To link all transactions created during the session, clients must provide the (optional) field partnerUserId as a query parameter when initializing Coinbase Pay.

Transaction Status returns a paginated list of all transactions from newest to oldest. If the client app doesn’t have a concept of a user, clients can pass a random partnerUserId to reference a one-off session.

Method

GET

URL

https://pay.coinbase.com/api/v1/buy/user/{partner_user_id}/transactions?page_key={next_page_key}&page_size={page_size}

Request Parameters

The Transaction Status API is an RPC endpoint that accepts an argument as part of its URL path.

NameTypeReqDescription
partner_user_idStringYID referring to user CBPay transactions in client app.
page_keyStringNReference to next page of transactions. Returned in previous page’s response.
page_sizeNumberNNumber of transactions to return per page. Default is 1.

Response Fields

The Transaction Status API returns a JSON response including the following fields.

NameDescription
transactionsList of OnrampTransactions in reverse chronological order.
next_page_keyA reference to the next page of transactions.
total_countThe total number of transactions made by the user.

OnrampTransaction Schema

NameDescriptionValue
statusCurrent status of the CBPay transaction.ONRAMP_TRANSACTION_STATUS_CREATED
ONRAMP_TRANSACTION_STATUS_IN_PROGRESS
ONRAMP_TRANSACTION_STATUS_SUCCESS
ONRAMP_TRANSACTION_STATUS_FAILED
purchase_currencyCrypto currency being purchased.String
purchase_networkNetwork used to deliver crypto to the user’s wallet.String
purchase_amountAmount of crypto currency being purchased.String
payment_totalTotal amount of fiat the user will pay.String
payment_subtotalAmount of fiat the user will pay, exclusive of feesString
coinbase_feeAmount of fiat charged to cover brokerage fees.String
network_feeAmount of fiat charged to cover network fees.String
exchange_rateUnit price of the crypto currency being purchased.String
countryCountry the user resides in.String
user_idUnique identifier representing the user.String
payment_methodType of payment method the user is paying with.CARD
ACH_BANK_ACCOUNT
APPLE_PAY
FIAT_WALLET
CRYPTO_WALLET
tx_hashThe block hash of the onchain send.String

Example Request/Response

curl https://pay.coinbase.com/api/v1/buy/user/{partner_user_id}/transactions?page_key={next_page_key}&page_size={page_size} \
-H 'Content-Type: application/json' \
-H 'CBPAY-VERSION: XXXX-XX-XX' \
-H 'CBPAY-APP-ID: XXXXXXXXXXXXXXXXXXXXXXXXX' \
-H 'CBPAY-API-KEY: XXXXXXXXXXXXXXXXXXXXXXXXX'

Transactions

The Transactions API provides clients with a list of CBPay transactions between two dates. The Transactions API is indented for analytics purposes, if you need real time information about a specific transaction, use the Transaction Status API.

Transactions returns a paginated list of all transactions from newest to oldest.

Method

GET

URL

https://pay.coinbase.com/api/v1/buy/transactions?page_key={next_page_key}&page_size={page_size}&start_date={start_date}&end_date={end_date}

Request Parameters

NameTypeReqDescription
page_keyStringNReference to next page of transactions. Returned in previous page’s response.
page_sizeNumberNNumber of transactions to return per page. Default is 1000.
start_dateStringNThe start date (inclusive) of the range of transactions to return. YYYY-MM-DD format. Default is one month before end_date.
end_dateStringNThe end date (exclusive) of the range of transactions to return. YYYY-MM-DD format. Default is tomorrow.

Response Fields

The Transaction Status API returns a JSON response including the following fields.

NameDescription
transactionsList of OnrampTransactions in reverse chronological order.
next_page_keyA reference to the next page of transactions.

OnrampTransaction Schema

NameDescriptionValue
statusCurrent status of the CBPay transaction.ONRAMP_TRANSACTION_STATUS_CREATED
ONRAMP_TRANSACTION_STATUS_IN_PROGRESS
ONRAMP_TRANSACTION_STATUS_SUCCESS
ONRAMP_TRANSACTION_STATUS_FAILED
purchase_currencyCrypto currency being purchased.String
purchase_networkNetwork used to deliver crypto to the user’s wallet.String
purchase_amountAmount of crypto currency being purchased.String
payment_totalTotal amount of fiat the user will pay.String
payment_subtotalAmount of fiat the user will pay, exclusive of feesString
coinbase_feeAmount of fiat charged to cover brokerage fees.String
network_feeAmount of fiat charged to cover network fees.String
exchange_rateUnit price of the crypto currency being purchased.String
countryCountry the user resides in.String
user_idUnique identifier representing the user.String
payment_methodType of payment method the user is paying with.CARD
ACH_BANK_ACCOUNT
APPLE_PAY
FIAT_WALLET
CRYPTO_WALLET
tx_hashThe block hash of the onchain send.String
wallet_addressThe address of the wallet the transaction was sent to.String

Example Request/Response

curl https://pay.coinbase.com/api/v1/buy/user/transactions?page_key={next_page_key}&page_size={page_size}&start_date={start_date}&end_date={end_date} \
-H 'Content-Type: application/json' \
-H 'CBPAY-VERSION: XXXX-XX-XX' \
-H 'CBPAY-APP-ID: XXXXXXXXXXXXXXXXXXXXXXXXX' \
-H 'CBPAY-API-KEY: XXXXXXXXXXXXXXXXXXXXXXXXX'

Was this helpful?