Buy Crypto
Buying cryptocurrency is a key feature of the Coba API, allowing you to programmatically initiate and manage payments. On this page, you’ll find everything you need to buy any cryptocurrency through our API using MXN or USD.
In a nutshell, the process involves:
- Creating a User: First, you need to create a user in the Coba through the API.
- Creating an Address: Next, create an address for the user's wallet where the cryptocurrency payment will be sent.
- Request a Quote: Obtain a quote for the crypto payment to understand the fees and exchange rates involved.
- Create an Order for the Quote: This step involves creating an order based on the quote.
- Fund the Order: Finally, fund the order using the selected currency (MXN or USD) to complete the MXN payment.
1. Create a user
Refer to the Users section to create a user.
2. Create an address
Refer to the Addresses section to create an address.
3. Request a quote
This endpoint allows you to request a quote for sending MXN payments.
Required attributes
- Name
user_id- Type
- string
- Description
The unique identifier of the user who owns the bank account.
- Name
crypto- Type
- string
- Description
The cryptocurrency you want to buy (e.g., USDC).
One of:
USDC,USDC_POLYGON_NXTB,SOL_USDC_PTHX,USDT_POLYGON,USDT_ERC20,TRX_USDT_S2UZ
- Name
fiat- Type
- string
- Description
The currency you will use to fund the payment.
One of:
MXN,USD
- Name
country- Type
- string
- Description
Country where you want to make the quotation
One of:
MX,US
- Name
amount_crypto- Type
- number
- Description
The amount in cryptocurrency you want to buy.
- Name
side- Type
- string
- Description
The side of the transaction, in this case
buy
Request
curl -X POST https://sandbox.api.coba.ai/metal/crypto/quotes \
-H "Authorization: Bearer {token}" \
-H "X-Coba-Metal-API-Key: {client_api_key}" \
-d '{
"quote": {
"crypto": "USDC_POLYGON_NXTB",
"fiat": "MXN",
"side": "buy",
"country": "MX",
"user_id": "210hre129n1209n12",
"amount_crypto": 4.5
}
}'
Successful Response
{
"id": "893nr89nf8932fnnifn2if",
"user_id": "210hre129n1209n12",
"crypto": "USDC_POLYGON_NXTB",
"fiat": "MXN",
"country": "MX",
"side": "buy",
"amount_fiat": 100,
"amount_crypto": 4.5
}
4. Create an order for the quote
This endpoint allows you to create an order based on a previously obtained quote.
The quote expires after 10 seconds. This means to create an order, you must have a valid quote within that time frame.
Required attributes
- Name
quote_id- Type
- string
- Description
The unique identifier of the previously generated quote.
- Name
user_address_id- Type
- string
- Description
The unique identifier of the address where the crypto payment will be sent.
- Name
notes- Type
- string
- Description
Optional notes for the order. This is optional
Request
curl -X POST https://sandbox.api.coba.ai/metal/crypto/orders\
-H "Authorization: Bearer {token}" \
-H "X-Coba-Metal-API-Key: {client_api_key}" \
-d '{
"order": {
"quote_id": "893nr89nf8932fnnifn2if",
"user_address_id": "68c0592bc5e913h092nc92be",
"notes": "testing"
}
}'
{
"id": "893nr89nf8932fnnifn2if",
}
5. Fund the order
This endpoint return an order object with instructions to fund the order.
The status of the order should be awaitingPayment for instructions to be included in the response.
You can use the instructions to fund the order using USDC.
Request
curl -X GET https://sandbox.api.coba.ai/metal/crypto/orders/:id\
-H "Authorization: Bearer {token}" \
-H "X-Coba-Metal-API-Key: {client_api_key}"
Successful Response
{
"quote_id": "893nr89nf8932fnnifn2if",
"user_id": "210hre129n1209n12",
"status": "awaitingPayment",
"crypto": "USDC_POLYGON_NXTB",
"destination_of_funds": {
"blockchainAddress": "0xaBCb3E5H28B8678c017EFb11FB63ce98HEa83263"
},
"side": "buy",
"fiat": "MXN",
"country": "MX",
"amount_fiat": 100,
"amount_crypto": 4.5,
"payment_instructions": {
"dueDate": "2026-01-29T22:00:00.000Z",
"bankName": "Fondeadora",
"companyName": "Rampa Blockchain SAPI de CV",
"companyAddress": "Ave. Lázaro Cardenas 2400, Residencial San Agustin 1 Sector, San Pedro Garza Garcia, CP 66260, Mexico",
"reference": "9AEA4E84",
"CLABE": "699180600005533135",
"RFC": "RBL2206107N8"
}
}