Two kinds of trades
Both share the same setup.
Common setup
1
Authenticate
Get an access token with the OAuth2 Client Credentials flow using your
client_id and client_secret, and send it as a Bearer token on every subsequent call. Trading needs the read and write scopes.→ Get Access Token2
Create the end user
Register each of your users with an
external_ref: your own identifier for them. It must be unique within your account and can only contain letters, digits, _ and -.Every later call refers to the user by this external_ref — it is the end_user_id in paths and bodies.→ Create End User3
Verify the user's identity
Submit the user’s KYC data. What happens next depends on your company — see Identity verification (KYC). An end user whose KYC is pending or rejected cannot trade: the execution answers
20030.4
Pick a pair
List the pairs enabled for your account and pass the pair’s
name (e.g. BTC_USD) when you create a quote. To show indicative prices before quoting, use the market rates.→ Get Account Pairs · Get Last Market RatesMarket rates are indicative and change with the amount. The only price you can execute at is the one held by a quote.
Buy and sell
1
Create a reusable quote
Send the
pair and an external_ref. The quote holds both a buy_rate and a sell_rate (fees included) and is valid for 30 seconds (expires_at). It is not tied to an end user or an amount, so you can execute it for several users while it is valid.→ Create Reusable Quote2
Execute it for an end user
Send the The response is the executed trade:
end_user_id, the op_type (BUY or SELL), an external_ref for this trade, and exactly one of:base_amount— the amount of crypto (e.g. buy 0.01 BTC), orquote_amount— the amount of fiat (e.g. buy BTC for 100 USD).
Request
→ Execute Reusable Quote
Tax withholding on sales (Argentina)
When your account is set up to withhold the SIRCUPA gross income tax on a pair (for exampleBTC_ARS), Ripio withholds it from the pesos of every SELL of that pair made by an end user with a CVU (an ARS fiat account in Ripio) and pays it to the tax authorities. End users without a CVU are not withheld. The withholding is calculated on the pesos of the sale after the fee, which is always the trade’s quote_amount, wherever the fee was charged: when you send base_amount, the fee is taken from the pesos; when you send quote_amount, it is taken from the crypto (more crypto is sold) and the user gets exactly the pesos you asked for. The end user is credited quote_amount minus the withholding. Buys are not withheld.
You don’t send the user’s CUIT: Ripio uses the CUIT/CUIL the user’s CVU was opened with.
1
Check the rates for the user (optional)
Send the user’s
end_user_id to get the registry rates that apply to them for the current month. If withholdings_enabled is true, apply each rate to the quote_amount the trade will have (the pesos after the fee) to show the user how much will be withheld before they confirm.Response
withholdings_enabled is false when the user has no CVU or their CUIT is not in the registry. The registry changes every month: query it when you need it instead of storing it.→ Get Withholding Rates2
Execute the sale
Execute it as any other sale: nothing extra is needed in the request.
Request
3
Read the withholding in the trade
The executed trade carries In this example the 1% fee (
withholding_amount (the total withheld), net_quote_amount (what was credited to the user) and the withholdings per jurisdiction. Each one’s base_amount is the trade’s quote_amount, the pesos after the fee. When the user has no CVU or their CUIT is not in the registry, withholding_amount is 0, net_quote_amount equals quote_amount and withholdings is empty.Response
charged_fee: 10,101 ARS) was taken from the crypto, because the sale was sent with quote_amount: 0.00673401 BTC were sold and the user got exactly 1,000,000 ARS after the fee. The withholding (6%) is calculated on those 1,000,000 ARS, so the user is credited 940,000 ARS.The same fields come in the trade of List Transactions and Retrieve Transaction. Each jurisdiction is a code: see Jurisdiction codes.To test every case in sandbox, see Tax withholding in sandbox.A sale that has to be withheld is never executed without its withholding. If the user has a CVU but Ripio has no valid CUIT/CUIL on file for them, the request fails with
400 (20000): contact Ripio support. If the withholding registry cannot be read, the request fails with 503 (50003): retry later.Jurisdiction codes
A sale can be withheld by several jurisdictions at once:0 is Convenio Multilateral and 901 to 924 are each province.
Swap
1
Create a swap reusable quote
Send a swap
pair (e.g. USDT_ETH) and an external_ref. The quote holds a swap_rate and is valid for 30 seconds.→ Create Swap Reusable Quote2
Execute it for an end user
Send the
end_user_id, an external_ref and the base_amount to swap. There is no op_type: the swap debits the base asset and credits the quote asset.→ Execute Swap Reusable QuoteFollowing up
- Transaction status: every execution creates a transaction. Retrieve it with the
txn_idfrom the response, or list them filtered byend_user,op_typeor date. → Retrieve Transaction · List Transactions - Balances: → Get Balances for End User
- Limits: per-transaction minimums and maximums for your account, and the daily, monthly and yearly limits consumed by each user. → Get Transaction Limits · Get Limits for End User
Common errors
Limit errors (frequency, amount, minimums and maximums) and the full list are in Error handling.
Testing in sandbox
Use the sandbox base URL (https://sandbox-b2b.ripio.com) with your sandbox credentials: the flow and the endpoints are the same as in production. To give an end user balance to sell or swap, fund them first — see Deposits & withdrawals or, for fiat, Banking as a Service.
Tax withholding in sandbox (Argentina)
In sandbox the withholding registry is simulated: the scenario depends only on the CUIT of the end user who sells. To test a case, create an end user, send one of these CUITs ascuit in their KYC, give them a CVU and make a SELL on a pair your account withholds.
How to read them: when the middle number starts with
99999 it simulates the error with that HTTP status; otherwise it is the total rate in hundredths of a percent (600 is 6%). They can be sent with or without dashes, and several end users can share the same one. Get Withholding Rates answers the same scenario for the end user.
These cases don’t depend on the CUIT:
- An end user without a CVU is not withheld, whatever their CUIT.
- A BUY is not withheld.
- Retrying a SELL with the same
external_refreturns the same trade with the same withholding.