> For the complete documentation index, see [llms.txt](https://moneymie.gitbook.io/toga-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://moneymie.gitbook.io/toga-api/api-reference/rate/generate-a-rate.md).

# Generate a rate

Generate a rate for an intended payout

This endpoint will help you to generate a rate, wallet address and rate id. Every transaction must have a rate id and be funded to create a payout on Toga.&#x20;

## Generate a rate for a payout

<mark style="color:green;">`POST`</mark> `https://sandbox.moneymie.com/api/v1/payout/rates`

Here's an example of a call 👇

{{baseURL}}/v1/transactions/rate?country=NG\&currency=USD\&token=USDC\&local=num

To call this API, you must specify the token and then country and currency in ISO format (ISO 3166-2 and ISO 4217 respectively). For now, we only accept USDC as *token*. Any other cryptocurrency will not be accepted.&#x20;

Once the rate is generated, you'll need to send the crypto total to the wallet address generated. Please note that we will not honour payouts initiated without first sending funds to the wallet address. The rate id will need to be added when making a request to create a payout.&#x20;

#### Query Parameters

| Name                                       | Type   | Description                                    |
| ------------------------------------------ | ------ | ---------------------------------------------- |
| country<mark style="color:red;">\*</mark>  | String | The destination country (e.g. NG, GH)          |
| local<mark style="color:red;">\*</mark>    | Number | The amount in the local currency (e.g. 400)    |
| currency<mark style="color:red;">\*</mark> | String | The destination currency (e.g. NGN, GHS)       |
| token<mark style="color:red;">\*</mark>    | String | The token you will convert to fiat (e.g. USDC) |

{% tabs %}
{% tab title="201: Created Successful request" %}

```json
{
    "message": "SUCCESS",
    "data": {
        "tokenSize": 1.35,
        "feeSize": {
            "crypto": 1.0810810810810811,
            "fiat": 800.0
        },
        "total": {
            "crypto": 2.43,
            "fiat": 1800.0
        },
        "countryCode": "NG",
        "currencyCode": "NGN",
        "address": "0x6dCB49873231cD3F83048fFAF33D0EbF9684B912",
        "token": "USDC",
        "paymentMethods": [
            "BANK_TRANSFER"
        ],
        "executed": false,
        "createdAt": "2022-11-18T17:37:11.987+0000",
        "updatedAt": "2022-11-18T17:37:11.987+0000",
        "rateId": "6377c2c71e50dc44ee9aed75",
        "amount": 1000.0
    }
}
//The crypto total is the amount you will send to the USDC address
//The fiat total is the amount we will send to your user
```

{% endtab %}

{% tab title="401: Unauthorized Invalid credentials" %}

```javascript
{
  "message": "Invalid credentials"
}
```

{% endtab %}

{% tab title="400: Bad Request Client error" %}

```json
{
  "code": "XXXX",
  "message": "Invalid rate"
}
```

{% endtab %}
{% endtabs %}
