# Create a new crypto address Source: https://docs.rio.trade/api-reference/address/create-address api-reference/address-docs.json POST /api/addresses ### Requirements to consume the endpoint. > [card] Create and modify role > > The user must have the role to create and modify. # Delete address Source: https://docs.rio.trade/api-reference/address/delete-address api-reference/address-docs.json DELETE /api/addresses/{id} ### Requirements to consume the endpoint. > [card] Create and modify role > > The user must have the role to create and modify. # Get address Source: https://docs.rio.trade/api-reference/address/get-address api-reference/address-docs.json GET /api/addresses/{id} # Get addresses Source: https://docs.rio.trade/api-reference/address/get-addresses api-reference/address-docs.json GET /api/addresses # Create a bank account Source: https://docs.rio.trade/api-reference/bank-accounts/create-a-bank-account api-reference/bank-accounts-docs.json post /api/bank/accounts ### Requirements to consume the endpoint. > [card] Create and modify role > > The user must have the role to create and modify. > [card] User approved > > The user must be approved in at least one country. > [!NOTE] > > **Disclaimer**: The bank account being created must belong to the user. By creating a bank account through this endpoint, you confirm that the user is the owner of the bank account. Bank accounts that do not belong to the user may be marked as not approved during verification. # Delete a bank account Source: https://docs.rio.trade/api-reference/bank-accounts/delete-a-bank-account api-reference/bank-accounts-docs.json delete /api/bank/accounts/{id} ### Requirements to consume the endpoint. > [card] Create and modify role > > The user must have the role to create and modify. > [card] User approved > > The user must be approved in at least one country. # Get a bank account Source: https://docs.rio.trade/api-reference/bank-accounts/get-a-bank-account api-reference/bank-accounts-docs.json get /api/bank/accounts/{id} ### Requirements to consume the endpoint. > [card] User approved > > The user must be approved in at least one country. # Get bank accounts Source: https://docs.rio.trade/api-reference/bank-accounts/get-bank-accounts api-reference/bank-accounts-docs.json get /api/bank/accounts ### Requirements to consume the endpoint. > [card] User approved > > The user must be approved in at least one country. # Cancel bulk bank payment Source: https://docs.rio.trade/api-reference/bank-payments/cancel-bulk-bank-payment api-reference/bank-payments-docs.json post /api/payments/bank/bulk/{id}/cancel ### Requirements to consume the endpoint. > [card] User approved > > The user must be approved in at least one country. # Confirm bank payment Source: https://docs.rio.trade/api-reference/bank-payments/check-bank-payment api-reference/bank-payments-docs.json post /api/payments/bank/check > [!NOTE] > > In our sandbox environment, this endpoint is used to simulate a successful fiat payment.\ > In our production environment, this endpoint only needs to be called when making a USD payment in Mexico or a COP payment in Colombia. All other payments are processed automatically. ### Requirements to consume the endpoint. > [card] Create and modify role > > The user must have the role to create and modify. > [card] User approved > > The user must be approved in at least one country. # Create bulk bank payment Source: https://docs.rio.trade/api-reference/bank-payments/create-bulk-bank-payment api-reference/bank-payments-docs.json post /api/payments/bank/bulk ### Requirements to consume the endpoint. > [card] Create and modify role > > The user must have the role to create and modify. > [card] User approved > > The user must be approved in at least one country. # Get bulk bank payment Source: https://docs.rio.trade/api-reference/bank-payments/get-bulk-bank-payment api-reference/bank-payments-docs.json get /api/payments/bank/bulk/{id} ### Requirements to consume the endpoint. > [card] User approved > > The user must be approved in at least one country. # Cancel bulk crypto payment Source: https://docs.rio.trade/api-reference/crypto-payments/cancel-bulk-crypto-payment api-reference/crypto-payments-docs.json post /api/payments/crypto/bulk/{id}/cancel ### Requirements to consume the endpoint. > [card] User approved > > The user must be approved in at least one country. # Confirm crypto payment Source: https://docs.rio.trade/api-reference/crypto-payments/check-crypto-payment api-reference/crypto-payments-docs.json post /api/payments/crypto/check > [!NOTE] > > This endpoint is only meant to be called in our sandbox environment to simulate a successful crypto payment. Crypto payments are processed automatically in our production environment. ### Requirements to consume the endpoint. > [card] Create and modify role > > The user must have the role to create and modify. > [card] User approved > > The user must be approved in at least one country. # Create bulk crypto payment Source: https://docs.rio.trade/api-reference/crypto-payments/create-bulk-crypto-payment api-reference/crypto-payments-docs.json post /api/payments/crypto/bulk ### Requirements to consume the endpoint. > [card] Create and modify role > > The user must have the role to create and modify. > [card] User approved > > The user must be approved in at least one country. # Get bulk crypto payment Source: https://docs.rio.trade/api-reference/crypto-payments/get-bulk-crypto-payment api-reference/crypto-payments-docs.json get /api/payments/crypto/bulk/{id} ### Requirements to consume the endpoint. > [card] User approved > > The user must be approved in at least one country. # Introduction Source: https://docs.rio.trade/api-reference/introduction ## Setting up Here are some important things to keep in mind when integrating with our APIs. We currently use OpenAPI 3.0 specification to specify and document our APIs, so it will be easy for you to make requests and observe the responses. The first steps to start the integration process are defined below. ### User account creation > [!NOTE] > > **Disclaimer**: Sandbox environment is intended for testing purposes only. > When creating user accounts or inputting data, feel free to use fake or dummy > information to complete onboarding faster. No real user data is required or > recommended in this environment. * Visit our test environment: [https://app.sandbox.rio.trade/en/register](https://app.sandbox.rio.trade/en/register) * Create an account by entering a phone number, including the country code (Example: +520000000000). * Set your password and security question. * Once your registration is complete, log in to the platform using your registered credentials. ### API key generation After completing the registration process at [https://app.sandbox.rio.trade/en/register](https://app.sandbox.rio.trade/en/register), you must enter the application through [https://app.sandbox.rio.trade/en/login](https://app.sandbox.rio.trade/en/login) with the username and password assigned. Once on the platform, open your **user settings** and go to the **API keys** tab to generate the respective key. This is an example of the request: ``` curl -X 'GET' \ 'https://app.sandbox.rio.trade/api/users' \ -H 'accept: */*' \ -H 'x-api-key: test' ``` > [!NOTE] > > Remember to use the API key generated in the request headers by adding the > x-api-key. ### User approval The user approval process is carried out by the system administrators. Therefore, when creating a user, the approval request must be made to the administrators through `Slack or email`. # Cancel order Source: https://docs.rio.trade/api-reference/orders/cancel-order api-reference/orders-docs.json post /api/orders/{id}/cancel ### Requirements to consume the endpoint. > [card] Create and modify role > > The user must have the role to create and modify. > [card] User approved > > The user must be approved in at least one country. # Create order Source: https://docs.rio.trade/api-reference/orders/create-order api-reference/orders-docs.json post /api/orders Books a quote into an order. Give the account Rio pays out to under `settlement.payout`: `addressId` when you receive stablecoins, `bankAccountId` when you receive fiat. Payment details for the leg you pay are returned under `settlement.payment.instructions` once the order is awaiting payment. ### Requirements to consume the endpoint. > [card] Create and modify role > > The user must have the role to create and modify. > [card] User approved > > The user must be approved in at least one country. # Get order Source: https://docs.rio.trade/api-reference/orders/get-order api-reference/orders-docs.json get /api/orders/{id} ### Requirements to consume the endpoint. > [card] User approved > > The user must be approved in at least one country. # Get orders Source: https://docs.rio.trade/api-reference/orders/get-orders api-reference/orders-docs.json get /api/orders ### Requirements to consume the endpoint. > [card] User approved > > The user must be approved in at least one country. ### Retrieving several orders at once Use the `ids` parameter to fetch up to 50 specific orders in a single request instead of calling `GET /api/orders/{id}` once per order. Separate the ids with commas. ```bash theme={null} curl -G https://app.sandbox.rio.trade/api/orders \ -H "x-api-key: $RIO_API_KEY" \ --data-urlencode "ids=b49f4084b96e4fb76f5a496e,765f4084b96e4fb76f5a4fb0" ``` If you are polling order statuses, prefer this over one request per order. It is faster for you and it keeps response times stable for everyone. > [!NOTE] > > When `ids` is present and `limit` is not, the limit defaults to the number of ids you sent, so a single page returns all of them. If you also pass `limit`, that value wins and the results are paginated as usual. Ids you are not authorized to see are simply not returned, so a response may contain fewer orders than the number of ids you sent. The same applies to ids that do not exist or that fall outside the other filters you sent in the request. Invalid ids, or more than 50 of them, are rejected with a validation error. # Create Quote Source: https://docs.rio.trade/api-reference/quotes/create-quote api-reference/quotes-docs.json post /api/quotes Prices a conversion. Set `origin` to what you pay and `destination` to what you receive, with `amount` on exactly one of them. A fiat origin and stablecoin destination is a buy, the reverse is a sell, and two stablecoins is a swap. ### Requirements to consume the endpoint. > [card] Create and modify role > > The user must have the role to create and modify. > [card] User approved > > The user must be approved in at least one country. # Get Quote by ID Source: https://docs.rio.trade/api-reference/quotes/get-quote-by-id api-reference/quotes-docs.json get /api/quotes/{id} > [!NOTE] > > **Note**: Quotes that have not been used in the settlement of an order are > deleted after 7 days. # Accept terms and conditions for a user Source: https://docs.rio.trade/api-reference/users/accept-terms-and-conditions api-reference/users-docs.json POST /api/users/{id}/terms/accept This endpoint should only be called for users in Mexico, Peru, and Colombia. # Add additional information to a user Source: https://docs.rio.trade/api-reference/users/add-additional-user-information api-reference/users-docs.json POST /api/users/{id}/additional-information # Create a new user Source: https://docs.rio.trade/api-reference/users/create-user api-reference/users-docs.json POST /api/users # Create a new user by link Source: https://docs.rio.trade/api-reference/users/create-user-by-link api-reference/users-docs.json POST /api/users/link # Get user Source: https://docs.rio.trade/api-reference/users/get-user api-reference/users-docs.json GET /api/users/{id} # Get user onboarding links Source: https://docs.rio.trade/api-reference/users/get-user-onboarding-links api-reference/users-docs.json GET /api/users/{id}/link Retrieves onboarding verification links for a user. # Get all users Source: https://docs.rio.trade/api-reference/users/get-users api-reference/users-docs.json GET /api/users ### Additional information. > [!NOTE] > > If no value is entered for any filter, the current user information is returned. > > > [accordion] Click here to see the schema > > > > ```json theme={null} > > { > > "platformFeeRanges": { > > "MX": { > > "buy": [], > > "sell": [] > > }, > > "PE": { > > "buy": [], > > "sell": [] > > }, > > "CO": { > > "buy": [], > > "sell": [] > > } > > }, > > "invoicing": { > > "MX": { > > "fiscalRegimenCode": 605 > > } > > }, > > "individualData": { > > "firstName": "Name", > > "middleName": "Middle", > > "lastName": "Last", > > "birthday": "1988-06-06T00:00:00.000Z" > > }, > > "createdAt": "2024-05-28T19:08:48.590Z", > > "type": "individual", > > "phoneNumber": "+526589562354", > > "email": "testing@rio.trade", > > "address": { > > "street1": "Street", > > "street2": "Street", > > "city": "City", > > "state": "State", > > "country": "MX", > > "postalCode": "12345" > > }, > > "onboarding": { > > "country": "MX", > > "status": "approved", > > "hasAcceptedTerms": true > > }, > > "id": "66562bc04fe8bf83c577c178" > > } > > ``` # Delete Webhook Source: https://docs.rio.trade/api-reference/webhooks/delete-apiwebhooks api-reference/webhooks-docs.json delete /api/webhooks/{id} # Get Webhook by id Source: https://docs.rio.trade/api-reference/webhooks/get-apiwebhooks api-reference/webhooks-docs.json get /api/webhooks/{id} # Get Webhooks Source: https://docs.rio.trade/api-reference/webhooks/get-apiwebhooks-1 api-reference/webhooks-docs.json get /api/webhooks # Register a Webhook Source: https://docs.rio.trade/api-reference/webhooks/post-apiwebhooks api-reference/webhooks-docs.json post /api/webhooks/{type} # Supported currencies for stablecoin conversions Source: https://docs.rio.trade/currencies The fiat currencies and stablecoins supported by the platform, and how to name them in the APIs. > [!NOTE] > > **Disclaimer**: The currencies referenced in this guide refer exclusively to > the coins or cryptocurrencies that may be used for payments or transactions on > this platform. It does not imply that the platform supports or facilitates any > currency exchange operations. ### How currencies are named Every currency is identified by an `asset` code. Stablecoins exist on several blockchains, so a stablecoin is always paired with the `network` it is held on. Fiat currencies have no network. ```json theme={null} { "asset": "MXN" } { "asset": "USDC", "network": "solana" } ``` Quotes and orders describe a conversion as an `origin` leg (what you pay) and a `destination` leg (what you receive), each named this way. Addresses, bulk payments and payouts carry the same two fields. ### Fiat currencies | Fiat | Description | `asset` | `country` | | - | - | - | - | | MXN | Mexican Peso | MXN | MX | | USD | United States Dollar (Mexico) | USD | MX | | PEN | Peruvian Sol | PEN | PE | | USD | United States Dollar (Peru) | USD | PE | | COP | Colombian Peso | COP | CO | ### Stablecoins | Stablecoin | `asset` | `network` | Contract | | :- | :- | :- | :- | | USDC | USDC | ethereum | [Etherscan](https://etherscan.io/token/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48) | | USDC Polygon | USDC | polygon | [Polygonscan](https://polygonscan.com/token/0x3c499c542cef5e3811e1192ce70d8cc03d5c3359) | | USDC Solana | USDC | solana | [Solscan](https://solscan.io/token/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v) | | USDC Stellar | USDC | stellar | [Stellar.expert](https://stellar.expert/explorer/public/asset/USDC-GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN-1) | | USDC Base | USDC | base | [Basescan](https://basescan.org/token/0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913) | | USDC Arc | USDC | arc_chain | [Arc Explorer](https://explorer.arc.io/address/0x3600000000000000000000000000000000000000) | | USDC.e Tempo | USDCe | tempo | [Tempo Explorer](https://explore.tempo.xyz) | | EURC | EURC | ethereum | [Etherscan](https://etherscan.io/token/0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c) | | EURC Solana | EURC | solana | [Solscan](https://solscan.io/token/HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr) | | EURC Base | EURC | base | [Basescan](https://basescan.org/token/0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42) | | USDT | USDT | ethereum | [Etherscan](https://etherscan.io/token/0xdac17f958d2ee523a2206206994597c13d831ec7) | | USDT Polygon | USDT | polygon | [Polygonscan](https://polygonscan.com/token/0xc2132d05d31c914a87c6611c10748aeb04b58e8f) | | USDT Tron | USDT | tron | [Tronscan](https://tronscan.org/#/token20/TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t) | | USDT BSC | USDT | bsc | [Bscscan](https://bscscan.com/token/0x55d398326f99059fF775485246999027B3197955) | | USDT Solana | USDT | solana | [Solscan](https://solscan.io/token/Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB) | | OUSD | OUSD | ethereum | [Etherscan](https://etherscan.io/token/0x9f6F3991D525015a6F8CaF062C83b62fD3AC4436) | | OUSD Tempo | OUSD | tempo | [Tempo Explorer](https://explore.tempo.xyz/token/0x20c0000000000000000000006a37da5c996874be) | > [!NOTE] > > If your Stellar wallet requires a memo for deposits, register it in the `memo` > field when you create the address. Payouts to that address then carry the memo > as `blockchainMemo`. > [!NOTE] > > **Disclaimer**: All technical documentation is subject to the terms and > conditions, which apply supplementarily and take precedence over the > documentation. # Introduction Source: https://docs.rio.trade/introduction Welcome to the comprehensive guide of the Rio platform. ## Setting up This site is your one-stop resource for understanding the various workflows of the Rio platform. It provides detailed information about each flow and the APIs involved in these processes. We use the OpenAPI 3.0 specification to define and document our APIs. This makes it straightforward for you to make requests and observe the responses. The OpenAPI specification, also known as Swagger, offers a set of tools for designing, building, and documenting RESTful APIs. Remember, successful integration with our APIs requires a good understanding of the overall platform flow and the specific APIs involved. So, take your time to explore the information provided here. Happy integrating! > [!NOTE] > > This documentation describes v2 of the API. If your integration was built > before the v2 update, read the [migration guide](/migration) or switch to > **v1 (legacy)** in the version selector above. > [!NOTE] > > It is important to take into account the requirements to start with the > different workflows, as well as the requirements to consume each endpoint, > which are specified in each of them. > [!NOTE] > > **Disclaimer**: All technical documentation is subject to the terms and > conditions, which apply supplementarily and take precedence over the > documentation. # Migrating to v2 Source: https://docs.rio.trade/migration How v1 fields map to v2. This page lists the fields that changed in the v2 update and how to move an existing integration. The v1 reference is available by switching to **v1 (legacy)** in the version selector. > [!NOTE] > > v2 fields are returned to everyone. v1 fields are only returned to accounts > where v1 has been enabled, which you can ask your account manager for while > you migrate. v1 request fields are still accepted, so you can migrate > responses first and requests second. ### Naming currencies `crypto` becomes `asset` plus `network`. Fiat codes are unchanged and are `asset` values without a network. The current list is in [supported currencies](/currencies). | v1 `crypto` | `asset` | `network` | | :- | :- | :- | | `USDC` | `USDC` | `ethereum` | | `USDC_POLYGON_NXTB` | `USDC` | `polygon` | | `SOL_USDC_PTHX` | `USDC` | `solana` | | `XLM_USDC_5F3T` | `USDC` | `stellar` | | `USDC_BASECHAIN_ETH_5I5C` | `USDC` | `base` | | `ARC` | `USDC` | `arc_chain` | | `USDCE_TEMPO_MXYR` | `USDCe` | `tempo` | | `EUROC_ETH_F5NG` | `EURC` | `ethereum` | | `EURC_SOL` | `EURC` | `solana` | | `EURC_B609K9QB_Y213` | `EURC` | `base` | | `USDT_ERC20` | `USDT` | `ethereum` | | `USDT_POLYGON` | `USDT` | `polygon` | | `TRX_USDT_S2UZ` | `USDT` | `tron` | | `USDT_BSC` | `USDT` | `bsc` | | `SOL_USDT_EWAY` | `USDT` | `solana` | | `OUSD_ETH_D6W3` | `OUSD` | `ethereum` | | `OUSD_TEMPO_8YSU` | `OUSD` | `tempo` | ### Creating a quote A buy becomes a quote whose `origin` is fiat and whose `destination` is a stablecoin. A sell is the reverse. The amount you want to fix goes on the matching leg, and exactly one leg carries an `amount`. Each leg carries its `country`. ```json v1 buy theme={null} { "side": "buy", "crypto": "SOL_USDC_PTHX", "fiat": "MXN", "country": "MX", "amountFiat": 1000000 } ``` ```json v2 buy theme={null} { "origin": { "asset": "MXN", "amount": 1000000, "country": "MX" }, "destination": { "asset": "USDC", "network": "solana", "country": "MX" } } ``` ```json v1 sell theme={null} { "side": "sell", "crypto": "SOL_USDC_PTHX", "fiat": "MXN", "country": "MX", "amountCrypto": 150000 } ``` ```json v2 sell theme={null} { "origin": { "asset": "USDC", "network": "solana", "amount": 150000, "country": "MX" }, "destination": { "asset": "MXN", "country": "MX" } } ``` Fiat legs must not carry a `network`. The settlement inputs move under a `settlement` object with the same paths the response uses: `twoWaySettlementType` becomes `settlement.timing` and `twoWaySettlementDateOffset` becomes `settlement.valueDateOffset`. Every other request field (`orderType`, `limitNetPrice`, `timeInForceStartsAt`, `timeInForceEndsAt`, `userId`) keeps its name. When creating an order, the account Rio pays out to is `settlement.payout.addressId` or `settlement.payout.bankAccountId` (v1: `userAddressId` and `payoutBankAccountId`). A stablecoin on both legs is a [swap](/workflows/swap-order), which has no v1 equivalent. ### Quote and order fields | v1 field | v2 field | | :- | :- | | `side` | `flow` (`fiatToCrypto`, `cryptoToFiat`, `cryptoToCrypto`) | | `crypto`, `fiat` | `origin.asset`, `destination.asset`, plus `settlement.payment.network` or `settlement.payout.network` for the stablecoin leg | | `country` | `origin.country`, `destination.country` | | `amountFiat`, `amountCrypto` | `origin.amount`, `destination.amount` | | `quoteInCrypto` | `fixedLeg` (`origin` or `destination`) | | `fees` | `pricingDetails.fees[]`, each with `type`, `amount`, `asset` and optional `tax` | | `twoWaySettlementType` | `settlement.timing` (`default` or `TPlusOffset`) | | `twoWaySettlementDateOffset` | `settlement.valueDateOffset` | | `effectiveTwoWaySettlementDateOffset` | `settlement.effectiveValueDateOffset` | | `twoWaySettlementDate` | `settlement.valueDate` | | `paymentDueDate`, `paymentInstructions.dueDate` | `settlement.payment.dueDate` | | `paymentInstructions` | `settlement.payment.instructions` | | `destinationOfFunds` | `settlement.payout.instructions` | | `cryptoAddress`, `depositAddress` | `settlement.payout.instructions.blockchainAddress` on a buy, `settlement.payment.instructions.blockchainAddress` on a sell | | `paymentMethod`, `payoutMethod` | `settlement.payment.rail`, `settlement.payout.rail` (`bankTransfer` or `blockchain`) | | `payoutAddressId`, `payoutBankAccountId` | `settlement.payout.addressId`, `settlement.payout.bankAccountId` | | `paymentAddressId` | `settlement.payment.addressId` | | `bulkBankPaymentId`, `bulkCryptoPaymentId` | `settlement.payment.bulkBankPaymentId`, `settlement.payment.bulkCryptoPaymentId` | | `paymentsReceived` | `settlement.payment.transactions[]` | | `payoutsSent` | `settlement.payout.transactions[]` | | `amountFiatReceived`, `amountCryptoReceived` | `settlement.payment.amountSettled`, `settlement.payout.amountSettled` | `id`, `status`, `quoteId`, `userId`, `expiresAt`, `marketPrice`, `netPrice`, `orderType`, `limitNetPrice`, `clientReferenceId`, `notes` and the `createdAt` and `updatedAt` timestamps are unchanged. Prices are expressed as units of the destination asset per unit of the origin asset, so `destination.amount = origin.amount * netPrice`. Pass `limitNetPrice` in the same orientation. ### Addresses, bulk payments and payouts Crypto addresses and bulk crypto payments are created with `asset` and `network` instead of `crypto`, and return both fields. Their responses still include `crypto`. The memo of a Stellar address is registered in the `memo` field. Bank accounts, bank payments and bank payouts are unchanged and keep using `fiat`, whose values are the same codes used as fiat `asset` values. ### Filtering orders The orders list accepts `asset`, an optional `network` and `flow` in addition to the `crypto`, `fiat` and `side` filters. ### Checklist **1. Read the new fields** Switch your parsing of quotes, orders and `orders` webhooks to `flow`, `origin`, `destination`, `pricingDetails` and `settlement` using the table above. You can compare both side by side while v1 fields are enabled on your account. **2. Send the new fields** Replace `side`, `crypto`, `fiat`, `amountFiat` and `amountCrypto` in quote requests with `origin` and `destination` legs, and replace `crypto` with `asset` and `network` when creating addresses and bulk crypto payments. **3. Drop the v1 fields** Once nothing reads them, ask your account manager to disable v1 fields on your account. > [!NOTE] > > **Disclaimer**: All technical documentation is subject to the terms and > conditions, which apply supplementarily and take precedence over the > documentation. # Minimum order sizes Source: https://docs.rio.trade/minimums This section details the minimum order sizes for all supported currencies on the Rio platform. Minimums on Rio are always in the currency you are receiving, that is the `destination` leg of the order. When you buy stablecoins the minimum applies to the stablecoin, when you sell them it applies to the fiat currency, and on a swap it applies to the stablecoin you receive. | Currency | `asset` | `network` | Minimum order size | | :- | :- | :- | :- | | USDC (Ethereum) | USDC | ethereum | \$1.00 USDC (Ethereum) | | USDC (Polygon) | USDC | polygon | \$1.00 USDC (Polygon) | | USDC (Solana) | USDC | solana | \$1.00 USDC (Solana) | | USDC (Stellar) | USDC | stellar | \$1.00 USDC (Stellar) | | USDC (Base) | USDC | base | \$1.00 USDC (Base) | | USDC (Arc) | USDC | arc_chain | \$1.00 USDC (Arc) | | USDC.e (Tempo) | USDCe | tempo | \$1.00 USDC.e (Tempo) | | EURC (Ethereum) | EURC | ethereum | €1.00 EURC (Ethereum) | | EURC (Solana) | EURC | solana | €1.00 EURC (Solana) | | EURC (Base) | EURC | base | €1.00 EURC (Base) | | USDT (Ethereum) | USDT | ethereum | \$1.00 USDT (Ethereum) | | USDT (Polygon) | USDT | polygon | \$1.00 USDT (Polygon) | | USDT (Tron) | USDT | tron | \$1.00 USDT (Tron) | | USDT (BSC) | USDT | bsc | \$1.00 USDT (BSC) | | USDT (Solana) | USDT | solana | \$1.00 USDT (Solana) | | OUSD (Ethereum) | OUSD | ethereum | \$1.00 OUSD (Ethereum) | | OUSD (Tempo) | OUSD | tempo | \$1.00 OUSD (Tempo) | | Mexican Peso | MXN | | \$20.00 MXN | | Peruvian Sol | PEN | | \$4.00 PEN | | Colombian Peso | COP | | \$6,000.00 COP | | US Dollar (Mexico and Peru) | USD | | \$10.00 USD | > [!NOTE] > > **Disclaimer**: All technical documentation is subject to the terms and > conditions, which apply supplementarily and take precedence over the > documentation. # Quickstart Source: https://docs.rio.trade/quickstart The first steps to start the integration process are defined below. ### User account creation > [!NOTE] > > **Disclaimer**: Sandbox environment is intended for testing purposes only. > When creating user accounts or inputting data, feel free to use fake or dummy > information to complete onboarding faster. No real user data is required or > recommended in this environment. * Visit our test environment: [https://app.sandbox.rio.trade/en/register](https://app.sandbox.rio.trade/en/register) * Create an account by entering a phone number, including the country code (Example: +520000000000). * Set your password and security question. * Once your registration is complete, log in to the platform using your registered credentials. ### User approval The user approval process is carried out by the system administrators. Therefore, when creating a user, the approval request must be made to the administrators through `Slack or email`. ### API key generation After completing the registration process at [https://app.sandbox.rio.trade/en/register](https://app.sandbox.rio.trade/en/register), you must enter the application through [https://app.sandbox.rio.trade/en/login](https://app.sandbox.rio.trade/en/login) with the username and password assigned. Once on the platform, open your **user settings** and go to the **API keys** tab to generate the respective key. This is an example of the request: ``` curl -X 'GET' \ 'https://app.sandbox.rio.trade/api/users' \ -H 'accept: */*' \ -H 'x-api-key: test' ``` > [!NOTE] > > Remember to use the API key generated in the request headers by adding the > x-api-key. ### Verification of bank accounts and crypto wallets When a new bank account or wallet is created, it can be optionally verified.\ In our production environment, the system sends random values to your wallet / bank account.\ In our sandbox environment, the values are always as follows: * Amount to verify bank account: `10` * Amount to verify wallet: `0.5` > [!NOTE] > > **Disclaimer**: All technical documentation is subject to the terms and > conditions, which apply supplementarily and take precedence over the > documentation. # How quotes work Source: https://docs.rio.trade/quotes This document explains how quotes work on Rio as well as the different configuration options available to users. Please note that this is relevant for quotes that have an expiration date. Some quotes, such as USD/USDC quotes, do not have an expiration date. > [!NOTE] > > The lifecycle of a quote can vary from `5 seconds to 10 minutes`. The default > value is 10 minutes, but this can be shortened upon request. The shorter a > quote is valid, the tighter the conversion rate. ### Anatomy of a quote Every quote describes a conversion between two legs. `origin` is what you pay and `destination` is what you receive, each with an `asset`, an `amount` and a `country`. The `flow` field tells you which kind of conversion it is (`fiatToCrypto`, `cryptoToFiat` or `cryptoToCrypto`) and `fixedLeg` tells you which of the two amounts you specified. Prices are always expressed as units of the destination asset per unit of the origin asset. `marketPrice` is the raw conversion rate, `pricingDetails.fees` lists every fee and tax applied, and `netPrice` is the all-in rate once fees are included, so `destination.amount = origin.amount * netPrice`. The `settlement` object describes how each leg moves. `settlement.payment` is the leg you fund and `settlement.payout` is the leg Rio sends to you. Each one tells you the `rail` (`bankTransfer` or `blockchain`), the `network` for blockchain legs and, once an order exists, the `instructions`, `dueDate`, `transactions` and `status` of that leg. ### What happens if you place an order and the quote expires? The resulting behavior depends on the account configuration. #### Default configuration (a new quote is issued for the order) By default, accounts are configured so that an order is re-quoted if its underlying quote expires. This process continues until Rio receives payment for the order, at which point the underlying quote is locked and no new quotes are issued for the order. #### Instant booking configuration (quotes are locked as soon as the order is created) When this configuration is activated for a user, quotes are locked as soon as the order is created. This means that no new quotes will be issued for the order, giving you the flexibility of having a locked conversion rate. The drawback of this option is that, unlike with the default configuration, placing an order means you commit to completing it. > [!NOTE] > > Regardless of account configuration, if the size of the payment Rio receives > for an order does not match the amount that was quoted, a new quote will be > issued for the updated amount and current market price. The order will then be > settled per usual. > [!NOTE] > > **Disclaimer**: All technical documentation is subject to the terms and > conditions, which apply supplementarily and take precedence over the > documentation. # Paying for orders using bulk payments Source: https://docs.rio.trade/workflows/bulk-payment-order Pay for multiple orders using a single transfer of funds ### Requirements to start the flow. > [card] API key > > Have an API key ([Tutorial here](/quickstart#api-key-generation)). ### Order flow Some customers, especially those with smaller transaction sizes, may need to settle multiple orders at once in order to mitigate the operational overhead of paying for each transaction independently. To support this use case, we have created a suite of endpoints that allow users to pay for more than one buy order with a single bank transfer and more than one sell order with a single blockchain transaction. This guide will walk you through how to use the bulk crypto payment system for off ramps. **1. Create bulk payment** Before you can start creating orders, you need to create a bulk payment that you will use to pay for multiple orders at once. This needs to be done each time you want to create a new set of orders that a single payment will cover. Assuming you want to sell USDC (Solana) in Mexico, then you would pass the following fields in the request body: ```javascript theme={null} { "asset": "USDC", "network": "solana", "country": "MX" } ``` Keep the `id` from the response, since every order you want this payment to cover has to reference it. The bulk payment starts out in `awaitingDepositAddress` and has no `depositAddress` yet, which is fine because you do not need it until you are ready to pay. > [card] [Create bulk crypto payment](/api-reference/crypto-payments/create-bulk-crypto-payment) **2. Create a quote** Create a quote for the order. Assuming you would like to sell USDC (Solana) for MXN, you would provide the following fields in the body: ```javascript theme={null} { "origin": { "asset": "USDC", "network": "solana", "country": "MX" }, "destination": { "asset": "MXN", "country": "MX" } } ``` Additionally, you need to specify the order size by putting an `amount` on exactly one of the two legs. You can either specify how much USDC (Solana) you would like to sell, like this (selling \$150,000 USDC (Solana)): ```javascript theme={null} "origin": { "asset": "USDC", "network": "solana", "amount": 150000 } ``` Or you can alternatively specify the amount of MXN you would like to receive, like this (receiving \$1,000,000 MXN): ```javascript theme={null} "destination": { "asset": "MXN", "amount": 1000000 } ``` The quote's `origin.asset` and `settlement.payment.network` must match the `asset` and `network` of the bulk payment, otherwise the order cannot be attached to it. Quotes expire. The `expiresAt` field is the date and time after which the quote can no longer be used to create an order, and the window is short, so create the order in the next step promptly. Quote each order right before you create it rather than quoting them all up front. > [card] [Go to create quote endpoint](/api-reference/quotes/create-quote) > [card] [Learn more about how quotes work](/quotes) **3. Create order** Once you are satisfied with a quote, you can create an order to book the trade. Assuming you would like to continue with the quote you created in the previous step to sell USDC (Solana) for MXN, then you would provide the following body: ```javascript theme={null} { "quoteId":"{{QUOTE_ID_FROM_PREVIOUS_RESPONSE}}", "settlement": { "payment": { "bulkCryptoPaymentId": "{{ID_FROM_RESPONSE_OF_STEP_1}}" }, "payout": { "bankAccountId": "{{ID_OF_MXN_BANK_ACCOUNT}}" } } } ``` The `settlement.payment.bulkCryptoPaymentId` is what attaches the order to the bulk payment. An order created without it gets its own individual deposit address and has to be paid for on its own. > [card] [Go to create order](/api-reference/orders/create-order) **4. Create more orders (optional)** Before settling this order, you can create other orders with the same `settlement.payment.bulkCryptoPaymentId`. By doing so, you will add them to the bulk crypto payment and thus will only need to make one payment to settle multiple orders. Each order you add increases the `amount` of the bulk crypto payment by its `settlement.payment.amount`, so only read that total once you have finished adding orders. **5. Wait for the order to be ready to accept payment** After creating an order, it will update its `status` field as it goes through its lifecycle. Once the `status` field is equal to `awaitingPayment`, the order is ready to receive payment. When all of the orders you added to the bulk crypto payment are in this status, you can get ready to send the payment. > [card] [Go to check order status](/api-reference/orders/get-order) **6. Get payment instructions** Retrieve payment amount and the deposit address specified by the bulk payment you created earlier. Get the bulk crypto payment by its `id` and read the `amount` field, which is the total across every order attached to it, and the `depositAddress` field. > [card] [Get crypto bulk payment](/api-reference/crypto-payments/get-bulk-crypto-payment) **7. Complete payment** Send the USDC (Solana) specified by the `amount` field of the bulk crypto payment to the address specified by the `depositAddress` field of the bulk crypto payment, in a single transfer. Make sure to send the exact amount to avoid delays. If the amount does not match, the bulk payment lands in `insufficientAmountReceived` or `excessAmountReceived` and needs to be sorted out with Rio before the orders can settle. **8. Order is complete** Once Rio confirms your payment, the orders attached to the bulk payment settle and Rio sends the fiat to the bank account you specified on each one. You will be able to view the details of the payout by inspecting the `settlement.payout.transactions` field of each order, and `settlement.payout.status` becomes `settled`. #### Poll order status or subscribe to webhooks > [card] [Go to check order status](/api-reference/orders/get-order) > [card] [Go to register a webhook](/workflows/register-webhook) > > Subscribe to `orders` webhooks to get order updates pushed to you instead of > polling. > [!NOTE] > > **Disclaimer**: All technical documentation is subject to the terms and > conditions, which apply supplementarily and take precedence over the > documentation. # Buy stablecoins Source: https://docs.rio.trade/workflows/buy-order ### Requirements to start the flow. > [card] API key > > Have an API key ([Tutorial here](/quickstart#api-key-generation)). ### Order flow The process of buying stablecoins on Rio is done through the following steps: **1. Register the deposit crypto address** Before creating an order, you need to register the crypto address that will receive the funds. This only needs to be done once per address-currency pair, so you can skip this step if the address is already registered. Send the wallet address in the `address` field and the stablecoin it holds as `asset` and `network`, for example `"asset": "USDC", "network": "polygon"`. Keep the `id` from the response, since that is what you pass as `settlement.payout.addressId` when creating the order. > [card] [Go to create a new crypto address](/api-reference/address/create-address) > [!WARNING] > > If you are registering a USDC (Stellar) address, check whether your wallet > requires a memo for deposits. If it does, send it in the `memo` > field. Failure to include the memo will result in the payout not being > credited to your wallet and your funds may be permanently lost. **2. Create a quote** You can create as many quotes as necessary before creating an order. A quote has two legs: `origin` is what you pay and `destination` is what you receive, and each leg carries its `country`. Name the fiat you pay in `origin.asset`, and the stablecoin you want in `destination.asset` and `destination.network`. Then set `amount` on the leg you want to fix: on `origin` if you know how much fiat you want to spend, or on `destination` if you know how much stablecoin you want to receive. For example, to spend \$1,000,000 MXN on USDC (Ethereum): ```json theme={null} { "origin": { "asset": "MXN", "amount": 1000000, "country": "MX" }, "destination": { "asset": "USDC", "network": "ethereum", "country": "MX" } } ``` The response tells you what you would get. Check `destination.amount` for the stablecoin you will receive, `pricingDetails.fees` for the fee breakdown and `netPrice` for the all-in price including taxes and fees. Keep the `id`, since that is the `quoteId` you pass when creating the order. Quotes expire. The `expiresAt` field is the date and time after which the quote can no longer be used to create an order, and the window is short, so read that field rather than assuming a fixed duration. > [card] [Go to create quote endpoint](/api-reference/quotes/create-quote) > [card] [Learn more about how quotes work](/quotes) **3. Create order** Once you are satisfied with a quote, you can create an order for the quoted amount. Pass the quote through the `quoteId` field and the crypto address that should receive the funds through the `settlement.payout.addressId` field. The quote must not have expired. > [card] [Go to create order](/api-reference/orders/create-order) **4. Wait for the order to be ready to accept payment.** Poll the order or subscribe to our webhooks. Wait for the order to have a status of `awaitingPayment`. Until then there is nothing for you to do, and the intermediate statuses do not require any action. > [card] [Go to check order status](/api-reference/orders/get-order) **5. Pay for the order (skip if placing the order in our sandbox environment)** Everything about the leg you pay lives under `settlement.payment` on the order. Send the amount in `settlement.payment.amount` to the bank account described in `settlement.payment.instructions`. Do not forget to send the reference. The payment instructions are part of the order itself, so there is no separate endpoint to call. Get the order and read `settlement.payment.instructions`, which holds `bankName`, `companyName`, `accountNumber`, the `reference` you must include with the transfer, and the country specific identifiers that apply, such as `CLABE` in Mexico or `CCI` in Peru. A transfer that arrives without the reference cannot be matched to your order. **6. Confirm payment (optional)** This final step is only necessary if the payment is made in USD in Mexico or COP in Colombia, or if the order was placed in our sandbox environment and you want to simulate a successful payment. Everywhere else Rio detects the incoming transfer on its own. > [card] [Go to confirm payment](/api-reference/bank-payments/check-bank-payment) **7. Wait for funds** Rio will send the funds to your wallet in the next few minutes. The order ends up in `complete`, `settlement.payout.status` becomes `settled`, and you can see the transaction hash in `settlement.payout.transactions`. #### Poll order status or subscribe to webhooks > [card] [Go to check order status](/api-reference/orders/get-order) > [card] [Go to register a webhook](/workflows/register-webhook) > > Subscribe to `orders` webhooks to get order updates pushed to you instead of > polling. > [!NOTE] > > **Disclaimer**: All technical documentation is subject to the terms and > conditions, which apply supplementarily and take precedence over the > documentation. # Decrypt webhook Source: https://docs.rio.trade/workflows/decrypt-webhook These are the requirements and steps for decrypting a webhook. Every webhook Rio sends has the same two fields. `data` is the encrypted payload as a hex string, and `iv` is the initialization vector used to encrypt it, also as a hex string. ```json Structure of the message that our webhooks send theme={null} { "data": "bea4343c5d815cba55c6e1bcb835bcbea43432abc014f7b48a63....", "iv": "1aa8ebae81e116621251993df3b155d4" } ``` > [!NOTE] > > Secret is used to decrypt the webhook payload. > [!NOTE] > > Standard decryption for aes-256-cbc using the data, the iv, and the secret > returned during the webhook registration. **1. Load the secret from the webhook registration** The secret you saved when you registered the webhook is base64 encoded, so decode it into a buffer before using it as the key. If you no longer have it, it cannot be recovered and you need to register the webhook again. > [card] [Go to register a webhook](/workflows/register-webhook) **2. Converts the hexadecimal IV to a byte buffer** * \[Recommendation] Check if the key length is 32 bytes, which is the required size for the AES-256 encryption algorithm. ```typescript TypeScript Example theme={null} const key = Buffer.from(WEBHOOK_SHARED_SECRET_ENCRYPTION_KEY, "base64"); if (key.length !== 32) { throw new Error("Encryption key must be 256 bits (32 bytes)"); } ``` * Converts the hexadecimal IV to a byte buffer. Use the `iv` exactly as it came in the request body, since a new one is generated for every message and the payload cannot be decrypted without the matching one. ```typescript TypeScript Example theme={null} const ivBuffer = Buffer.from(iv, "hex"); ``` **3. Decryption** * Creates a decryptor object using the AES-256 algorithm in CBC (Cipher Block Chaining) mode, the key and the IV. ```typescript TypeScript Example theme={null} const decipher = crypto.createDecipheriv("aes-256-cbc", key, ivBuffer); ``` * Start decrypting the data and store the result. ```typescript TypeScript Example theme={null} let decrypted = decipher.update(data, "hex", "utf8"); decrypted += decipher.final("utf8"); ``` **4. Read the event** The decrypted result is a JSON string, so parse it to get the event. For an orders webhook this is the order, which means you can read its `status` field to react to where the order is in its lifecycle without polling. ```typescript TypeScript Example theme={null} const event = JSON.parse(decrypted); ``` > [!NOTE] > > **Disclaimer**: All technical documentation is subject to the terms and > conditions, which apply supplementarily and take precedence over the > documentation. # Placing limit orders Source: https://docs.rio.trade/workflows/limit-order ### Requirements to start the flow. > [card] API key > > Have an API key ([Tutorial here](/quickstart#api-key-generation)). ### Limit order flow Limit orders on Rio allow you to specify a limit net price, which is the all-in price including all taxes and fees that you are targeting. In this walkthrough, we will go through the process of creating a limit buy order. **1. Register the deposit crypto address** Before creating a buy order, you need to register the crypto address that will receive the funds. This only needs to be done once per address-currency pair, so you can skip this step if the address is already registered. Send the wallet address in the `address` field and the stablecoin it holds as `asset` and `network`. Keep the `id` from the response, since that is what you pass as `settlement.payout.addressId` when creating the order. > [card] [Go to create a new crypto address](/api-reference/address/create-address) **2. Create a limit order quote** When creating a limit order quote, you need to specify an `orderType` of `limit`. You also need to specify the limit net price in the `limitNetPrice` field. Net prices are always expressed as units of the `destination` asset per unit of the `origin` asset, the same way `netPrice` is reported on every quote. For example, to buy USDC (Ethereum) with MXN, but only at an all-in price of 0.0540 USDC per MXN (about 18.52 MXN per USDC) or better: ```json theme={null} { "origin": { "asset": "MXN", "amount": 1000000, "country": "MX" }, "destination": { "asset": "USDC", "network": "ethereum", "country": "MX" }, "orderType": "limit", "limitNetPrice": 0.054 } ``` Unlike market order quotes, limit order quotes do not expire, so there is no time pressure between this step and the next one. > [card] [Go to create quote endpoint](/api-reference/quotes/create-quote) > [!NOTE] > > The quote response will include a `marketPrice` field. This is the mid market price that will trigger the order, calculated backwards from your specified `limitNetPrice` using your account's taxes and fees. **3. Place the limit order** No extra parameters are needed to create a limit order. Pass the quote through the `quoteId` field and the crypto address that should receive the funds through the `settlement.payout.addressId` field, the same as you would for a market order. > [card] [Go to create order endpoint](/api-reference/orders/create-order) **4. Order enters 'Waiting for target price' status** After placing the limit order, it will enter a status called `awaitingLimitPriceCondition`. The order will remain in this status until: * The market organically reaches your target mid market price, OR * The Rio ops team or one of Rio's trading algorithms decide to trigger your order early if they can stretch to that price You can monitor the order status by polling or subscribing to webhooks. There is nothing for you to do while the order waits, other than cancel it if you change your mind. > [card] [Go to check order status](/api-reference/orders/get-order) **5. Order execution and trigger** Once the target price is reached and the order is triggered, you'll receive an email notification and the order will continue with the normal order lifecycle. Wait for the order to have a status of `awaitingPayment`. **6. Pay for the order** Send the amount in `settlement.payment.amount` to the bank account described in `settlement.payment.instructions` on the order. Do not forget to include the reference number, since a transfer that arrives without it cannot be matched to your order. The payment instructions are part of the order itself, so get the order and read that field rather than looking for a separate endpoint. **7. Confirm payment (optional)** This final step is only necessary if the payment is made in USD in Mexico or COP in Colombia, or if the order was placed in our sandbox environment and you want to simulate a successful payment. Everywhere else Rio detects the incoming transfer on its own. > [card] [Go to confirm payment](/api-reference/bank-payments/check-bank-payment) **8. Wait for funds** Rio will send the funds to your wallet in the next few minutes. The order ends up in `complete`, `settlement.payout.status` becomes `settled`, and you can see the transaction hash in `settlement.payout.transactions`. ### Important notes about limit orders > [!NOTE] > > **Price protection**: You cannot specify a limit order at a price that is > worse than the current mid market price. If you attempt to do so, the system > will automatically adjust the limit net price to what it would be in a market > order. > [!NOTE] > > **Price rounding**: In limit order quotes, you may notice that the > `limitNetPrice` is not exactly the same as the `netPrice` (may differ by a few > decimals). This is due to rounding requirements for banking rails compliance - > for example, we cannot send nor receive $543.459 MXN, it would need to be > rounded to $543.46 MXN. Because of this, some net prices are mathematically > impossible. The system ensures the `limitNetPrice` and `netPrice` are as close > to identical as mathematically possible. > [!NOTE] > > **Scheduling orders**: You can specify a `timeInForceStartsAt` and > `timeInForceEndsAt` to schedule a limit order to be executed from a specific > time and/or to a specific time. An order waiting for its start time sits in > `awaitingTimeInForceToStart`, and one that reached its end time without > triggering ends up in `timeInForceEnded`. > [!NOTE] > > **Daily re-quoting for T+n orders**: For T+n orders, the system will re-quote > the order every day at 12:00 AM in the time zone of the corresponding order > country. This means you may see a new quoteId in the order document as well as > a new `marketPrice` field. The `limitNetPrice`, however, will remain > unchanged. This is to account for any changes in schedule. This does not > affect regular default settlement orders. > [!NOTE] > > **Order cancellation**: You can cancel a limit order while it's in > `awaitingLimitPriceCondition` status at any time. Doing so will permanently > cancel and delete the order, so it will no longer be returned when you list > your orders. > > > [card] [Go to cancel order](/api-reference/orders/cancel-order) > [!NOTE] > > **Early execution**: While limit orders are primarily triggered when the > market organically reaches your target price, the Rio ops team or one of Rio's > trading algorithms may decide to trigger your order early if they can achieve > your specified price. > [!NOTE] > > **Partial fills**: Limit orders can get partially filled. When this happens, > the order gets split into two. The original order gets updated with the new > amount that was filled and the new order has the remainder at the same limit > price. The new order also has a `parentOrderId` field that references the > original order. > [!WARNING] > > **Geographic restriction**: Limit orders cannot be placed in the United > States. > [!NOTE] > > **Disclaimer**: All technical documentation is subject to the terms and > conditions, which apply supplementarily and take precedence over the > documentation. # Register a webhook Source: https://docs.rio.trade/workflows/register-webhook These are the requirements and steps for registering a new webhook. ### Requirements to start the flow. > [card] API key > > Have an API key ([Tutorial here](/quickstart#api-key-generation)). ### Registration flow **1. Pick the type of webhook you need** The type goes in the URL path rather than the body, so you register one webhook per type. The available types are `orders`, for updates as an order moves through its lifecycle, `bank-accounts`, for changes to your registered bank accounts, and `users`, for changes to your users. **2. Register the endpoint** Send the address that should receive the events in the `url` field. Rio will send a POST request there every time an event of that type happens. ```json theme={null} { "url": "https://example.com/rio/webhooks/orders", "retryOnFailure": true } ``` Setting `retryOnFailure` to `true` makes Rio retry a failed delivery up to 5 times with exponential backoff. If you leave it out, a failed delivery is only attempted once, so turn it on unless you have another way of catching missed events. > [card] [Go to Register a new webhook](/api-reference/webhooks/post-apiwebhooks) > > Register a new webhook to receive notifications about events in your account. **3. Save the secret** The response contains the `id` of the registration and a `secret`. Store the secret somewhere safe right away, because it is only returned by this call and cannot be read back later. If you lose it you have to delete the registration and create a new one. The payloads Rio sends are encrypted, and this secret is the key you decrypt them with. > [card] [Go to decrypt a webhook](/workflows/decrypt-webhook) **4. Check or change the registration later** You can list your registrations to confirm the URL and type are what you expect. Updating lets you point an existing registration at a new `url` or change `retryOnFailure`, and it keeps the same secret. > [card] [Go to get all webhook registrations](/api-reference/webhooks/get-apiwebhooks-1) ### Webhook registration through the platform. To register the webhook, you must log in to the platform, navigate to the webhooks section in your account settings, and save the secret once registered. > [!NOTE] > > **Disclaimer**: All technical documentation is subject to the terms and > conditions, which apply supplementarily and take precedence over the > documentation. # Sell stablecoins Source: https://docs.rio.trade/workflows/sell-order ### Requirements to start the flow. > [card] API key > > Have an API key ([Tutorial here](/quickstart#api-key-generation)). ### Order flow The process of selling stablecoins is done through the following steps: **1. Register the receiving bank account** Before creating an order, you need to register the bank account that will receive the funds. This only needs to be done once per bank account-currency pair, so you can skip this step if the account is already registered. Send the `country` and `fiat` of the account along with its details, which are `bankName`, `accountHolderName` and `accountNumber`, plus the identifier your country uses, such as `CLABE` in Mexico or `CCI` in Peru. Keep the `id` from the response, since that is what you pass as `settlement.payout.bankAccountId` when creating the order. > [card] [Go to create a new bank account](/api-reference/bank-accounts/create-a-bank-account) **2. Create a quote** You can create as many quotes as necessary before creating an order. A quote has two legs: `origin` is what you pay and `destination` is what you receive, and each leg carries its `country`. Name the stablecoin you sell in `origin.asset` and `origin.network`, and the fiat you want in `destination.asset`. Then set `amount` on the leg you want to fix: on `origin` if you know how much stablecoin you want to sell, or on `destination` if you know how much fiat you want to receive. For example, to sell \$150,000 USDC (Solana) for MXN: ```json theme={null} { "origin": { "asset": "USDC", "network": "solana", "amount": 150000, "country": "MX" }, "destination": { "asset": "MXN", "country": "MX" } } ``` The response tells you what you would get. Check `destination.amount` for the fiat you will receive, `pricingDetails.fees` for the fee breakdown and `netPrice` for the all-in price including taxes and fees. Keep the `id`, since that is the `quoteId` you pass when creating the order. Quotes expire. The `expiresAt` field is the date and time after which the quote can no longer be used to create an order, and the window is short, so read that field rather than assuming a fixed duration. > [card] [Go to create quote endpoint](/api-reference/quotes/create-quote) > [card] [Learn more about how quotes work](/quotes) **3. Create order** Once you are satisfied with a quote, you can create an order for the quoted amount. Pass the quote through the `quoteId` field, and make sure to pass the ID for the bank account to which you would like to receive the funds through the `settlement.payout.bankAccountId` field. The quote must not have expired. > [card] [Go to create order](/api-reference/orders/create-order) **4. Wait for the order to be ready to accept your payment** Poll the order or subscribe to our webhooks. Wait for the order to have a status of `awaitingPayment`. Until then there is nothing for you to do, and the intermediate statuses do not require any action. Remember to add the `settlement.payout.bankAccountId` field when creating the order in the previous step. Otherwise, the resulting status will be `awaitingBankPayoutDetails`, which means Rio has nowhere to send the fiat. > [card] [Go to check order status](/api-reference/orders/get-order) **5. Pay for the order (skip if placing the order in our sandbox environment)** Everything about the leg you pay lives under `settlement.payment` on the order. Send the amount in `settlement.payment.amount`, on the network in `settlement.payment.network`, to the address in `settlement.payment.instructions.blockchainAddress`. The payment instructions are part of the order itself, so there is no separate endpoint to call. Get the order and read `settlement.payment.instructions`. Read the address from each order rather than reusing one you saved earlier, since the address you are given can differ between orders. > [!WARNING] > > If you are selling USDC (Stellar), you must include the memo specified in > `settlement.payment.instructions.blockchainMemo`. Failure to include the > memo will result in the payment not being credited to your order and your > funds may be permanently lost. **6. Confirm payment (optional)** This final step is only necessary to simulate a successful payment in our sandbox environment. In production Rio detects the incoming transfer on its own. > [card] [Go to confirm payment](/api-reference/crypto-payments/check-crypto-payment) **7. Wait for funds** Rio will send the funds to your bank account in the next few minutes. The order ends up in `complete`, `settlement.payout.status` becomes `settled`, and you can see the transfer details, such as the SPEI tracking number in Mexico, in `settlement.payout.transactions`. #### Poll order status or subscribe to webhooks > [card] [Go to check order status](/api-reference/orders/get-order) > [card] [Go to register a webhook](/workflows/register-webhook) > > Subscribe to `orders` webhooks to get order updates pushed to you instead of > polling. > [!NOTE] > > **Disclaimer**: All technical documentation is subject to the terms and > conditions, which apply supplementarily and take precedence over the > documentation. # Swap stablecoins Source: https://docs.rio.trade/workflows/swap-order Convert one stablecoin into another, including across networks ### Requirements to start the flow. > [card] API key > > Have an API key ([Tutorial here](/quickstart#api-key-generation)). ### Order flow A swap is a `cryptoToCrypto` order. You send one stablecoin to Rio and receive a different stablecoin, or the same stablecoin on a different network, at the address you registered. The process is done through the following steps: **1. Register the receiving crypto address** Before creating an order, you need to register the crypto address that will receive the funds. This only needs to be done once per address and stablecoin, so you can skip this step if the address is already registered. Send the wallet address in the `address` field and the stablecoin it will receive as `asset` and `network`. Keep the `id` from the response, since that is what you pass as `settlement.payout.addressId` when creating the order. > [card] [Go to create a new crypto address](/api-reference/address/create-address) **2. Create a quote** A quote has two legs: `origin` is what you pay and `destination` is what you receive. Both legs of a swap are stablecoins, so each one needs an `asset`, a `network` and a `country`. Set `amount` on the leg you want to fix: on `origin` if you know how much you want to send, or on `destination` if you know how much you want to receive. For example, to swap \$150,000 USDC (Ethereum) into USDC (Solana): ```json theme={null} { "origin": { "asset": "USDC", "network": "ethereum", "amount": 150000, "country": "MX" }, "destination": { "asset": "USDC", "network": "solana", "country": "MX" } } ``` Or to convert USDT (Tron) into exactly 100,000 USDC (Base): ```json theme={null} { "origin": { "asset": "USDT", "network": "tron", "country": "MX" }, "destination": { "asset": "USDC", "network": "base", "amount": 100000, "country": "MX" } } ``` Both stablecoins must be enabled for trading on their networks, see [supported currencies](/currencies). The response has `flow` set to `cryptoToCrypto`. Check `destination.amount` for the stablecoin you will receive, `pricingDetails.fees` for the fee breakdown and `netPrice` for the all-in rate. Keep the `id`, since that is the `quoteId` you pass when creating the order. Quotes expire. The `expiresAt` field is the date and time after which the quote can no longer be used to create an order, so read that field rather than assuming a fixed duration. > [!NOTE] > > Swap quotes do not accept `orderType`, `limitNetPrice`, the `timeInForce` > fields, `settlement.timing` or `settlement.valueDateOffset`. > [card] [Go to create quote endpoint](/api-reference/quotes/create-quote) > [card] [Learn more about how quotes work](/quotes) **3. Create order** Once you are satisfied with a quote, create an order for the quoted amount. Pass the quote through the `quoteId` field and the address that should receive the funds through the `settlement.payout.addressId` field. The address must hold the same `asset` and `network` as the quote's `destination`, and the quote must not have expired. Swap orders do not accept `settlement.payout.bankAccountId` or the bulk payment ids. > [card] [Go to create order](/api-reference/orders/create-order) **4. Wait for the order to be ready to accept your payment** Poll the order or subscribe to our webhooks. Wait for the order to have a status of `awaitingPayment`. Until then there is nothing for you to do. > [card] [Go to check order status](/api-reference/orders/get-order) **5. Pay for the order (skip if placing the order in our sandbox environment)** Everything about the leg you pay lives under `settlement.payment` on the order. Send the amount in `settlement.payment.amount`, on the network in `settlement.payment.network`, to the address in `settlement.payment.instructions.blockchainAddress`. Read the address from each order rather than reusing one you saved earlier, since the address you are given can differ between orders. > [!WARNING] > > If you are sending USDC (Stellar), you must include the memo specified in > `settlement.payment.instructions.blockchainMemo`. Failure to include the > memo will result in the payment not being credited to your order and your > funds may be permanently lost. **6. Confirm payment (optional)** This step is only necessary to simulate a successful payment in our sandbox environment. In production Rio detects the incoming transfer on its own. > [card] [Go to confirm payment](/api-reference/crypto-payments/check-crypto-payment) **7. Wait for funds** Rio will send the stablecoin to the address you registered in the next few minutes. The order ends up in `complete`, `settlement.payout.status` becomes `settled`, and you can see the transaction hash in `settlement.payout.transactions`. #### Poll order status or subscribe to webhooks > [card] [Go to check order status](/api-reference/orders/get-order) > [card] [Go to register a webhook](/workflows/register-webhook) > > Subscribe to `orders` webhooks to get order updates pushed to you instead of > polling. > [!NOTE] > > **Disclaimer**: All technical documentation is subject to the terms and > conditions, which apply supplementarily and take precedence over the > documentation. # Placing a T+n order Source: https://docs.rio.trade/workflows/t-plus-n-order ### Requirements to start the flow. > [card] API key > > Have an API key ([Tutorial here](/quickstart#api-key-generation)). ### Order flow The process of placing a T+n order is very similar to the process of placing a regular order, but with the addition of a few steps. In this guide, we will go through the process of placing a T+1 buy order. > [!NOTE] > > **Disclaimer**: Settlement does not imply custody or receipt of funds before > the order is executed on the date specified in the settlement details. **1. Register the deposit crypto address** Before creating an order, you need to register the crypto address that will receive the funds. This only needs to be done once per address-currency pair, so you can skip this step if the address is already registered. Send the wallet address in the `address` field and the stablecoin it holds as `asset` and `network`. Keep the `id` from the response, since that is what you pass as `settlement.payout.addressId` when creating the order. > [card] [Go to create a new crypto address](/api-reference/address/create-address) **2. Create a quote** When creating a T+n order, you need to specify the number of days until the order is settled. This is done with the `settlement` object of the request: set `settlement.timing` to `TPlusOffset` and `settlement.valueDateOffset` to the number of business days until the order is settled. For example, if you want to place a T+0 buy order, set `settlement.valueDateOffset` to 0. If you want to place a T+1 buy order, set it to 1, etc. A T+1 buy order of USDC (Ethereum) with MXN looks like this: ```json theme={null} { "origin": { "asset": "MXN", "amount": 1000000, "country": "MX" }, "destination": { "asset": "USDC", "network": "ethereum", "country": "MX" }, "settlement": { "timing": "TPlusOffset", "valueDateOffset": 1 } } ``` The quote echoes these under `settlement`, and `settlement.valueDate` is the date the order will settle on. Keep in mind that banking hours and holidays may cause the effective settlement date to be different than what you expected. Please always confirm the `settlement.valueDate` field of the quote and make sure it matches your expectation before creating an order. The `settlement.effectiveValueDateOffset` field tells you how many billable days that works out to, which can differ from the offset you asked for. Quotes expire. The `expiresAt` field is the date and time after which the quote can no longer be used to create an order, and the window is short, so read that field rather than assuming a fixed duration. > [card] [Go to create quote endpoint](/api-reference/quotes/create-quote) > [card] [Learn more about how quotes work](/quotes) **3. Create order** Once you are satisfied with a quote, you can create an order for the quoted amount. Pass the quote through the `quoteId` field and the crypto address that should receive the funds through the `settlement.payout.addressId` field. The quote must not have expired. > [card] [Go to create order](/api-reference/orders/create-order) **4. Wait for the order to be ready to accept payment.** Poll the order or subscribe to our webhooks. Wait for the order to have a status of `awaitingPayment`. After this, you have until the payment due date, specified in `settlement.payment.dueDate` on the order, to pay for the order. > [card] [Go to check order status](/api-reference/orders/get-order) **5. Pay for the order (skip if placing the order in our sandbox environment)** Please send the amount specified in `settlement.payment.amount` on the order to the bank account described in `settlement.payment.instructions`. Do not forget to send the reference. The payment instructions are part of the order itself, so there is no separate endpoint to call. Get the order and read its `settlement.payment.instructions` field, which holds `bankName`, `companyName`, `accountNumber`, the `reference` you must include with the transfer, and the country specific identifiers that apply, such as `CLABE` in Mexico or `CCI` in Peru. A transfer that arrives without the reference cannot be matched to your order. **6. Confirm payment (optional)** This final step is only necessary if the payment is made in USD in Mexico or COP in Colombia, or if the order was placed in our sandbox environment and you want to simulate a successful payment. Everywhere else Rio detects the incoming transfer on its own. > [card] [Go to confirm payment](/api-reference/bank-payments/check-bank-payment) **7. Wait for funds** Rio will send the funds to your wallet in the next few minutes. The order ends up in `complete`, `settlement.payout.status` becomes `settled`, and you can see the transaction hash in `settlement.payout.transactions`. #### Poll order status or subscribe to webhooks > [card] [Go to check order status](/api-reference/orders/get-order) > [card] [Go to register a webhook](/workflows/register-webhook) > > Subscribe to `orders` webhooks to get order updates pushed to you instead of > polling. > [!NOTE] > > **Settlement dates beyond T+4**: any offset up to T+4 is available by default. > Going further out is a separate permission, so please contact support to > enable it for your account or for your broker's account if you trade under > one. > [!WARNING] > > **Geographic restriction**: T+n orders cannot be placed in the United States. > [!NOTE] > > **Disclaimer**: All technical documentation is subject to the terms and > conditions, which apply supplementarily and take precedence over the > documentation.