> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rio.trade/llms.txt
> Use this file to discover all available pages before exploring further.

# Sell stablecoins

### Requirements to start the flow.

> [card] API key
>
> Have an API key ([Tutorial here](https://docs.rio.trade/quickstart.md#api-key-generation)).

### &#x20;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](https://docs.rio.trade/api-reference/bank-accounts/create-a-bank-account.md)

**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](https://docs.rio.trade/api-reference/quotes/create-quote.md)

> [card] [Learn more about how quotes work](https://docs.rio.trade/quotes.md)

**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](https://docs.rio.trade/api-reference/orders/create-order.md)

**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](https://docs.rio.trade/api-reference/orders/get-order.md)

**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](https://docs.rio.trade/api-reference/crypto-payments/check-crypto-payment.md)

**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`.

#### &#x20;Poll order status or subscribe to webhooks

> [card] [Go to check order status](https://docs.rio.trade/api-reference/orders/get-order.md)

> [card] [Go to register a webhook](https://docs.rio.trade/workflows/register-webhook.md)
>
> 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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.