Skip to main content
cURL
curl --request POST \
  --url https://api.grainfinance.co/v1/customers/{customerId}/hedges/accept-offline-quote \
  --header 'Authorization: Basic <encoded-value>' \
  --header 'Content-Type: application/json' \
  --header 'X-Customer-IP: <x-customer-ip>' \
  --data '
{
  "revision": 156,
  "fromCurrency": "MXN",
  "toCurrency": "USD",
  "toCurrencyAmount": 100000,
  "endAt": "2024-02-23",
  "rate": 20.616512,
  "externalTransactionId": "780231b3ae0d7e9e5097nd89",
  "extraFields": {
    "field_a": "value_a",
    "field_b": "value_b"
  }
}
'
{
  "id": "1b0ada1e-fa1b-4cfe-a553-01b340c5650e",
  "transactionId": "4d78ac65-2c3f-47e2-8bf3-3f76124e9d27"
}

Documentation Index

Fetch the complete documentation index at: https://docs.grainfinance.co/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

Basic authentication using the partner API keys from https://console.grainfinance.co/api-keys

Headers

X-Customer-IP
string<IPv4>
required

The IPv4 address of the browser from which the customer contacts your platform.
example: 192.158.1.38

Pattern: ((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}

Path Parameters

customerId
string
required

The id of the customer within the Grain platform.

Body

application/json

The payload required in order to accept an offline quote hedge

The payload required in order to accept an offline quote hedge

revision
number<double>
required

The id of the revision that defines the accepted rate for the currency-pair and tenor.

Example:

156

fromCurrency
string
required

The currency in which the transaction should be paid at by your customer.

Example:

"MXN"

toCurrency
string
required

the currency you want to buy.

Example:

"USD"

toCurrencyAmount
number<double>
required

The amount to hedge in the toCurrency.

Example:

100000

endAt
string<YYYY-MM-DD>
required

The date in which the hedge will be settled, denoted in YYYY-MM-DD format.

Pattern: \d{4}-\d{2}-\d{2}
Example:

"2024-02-23"

rate
number<double>
required

Represents the exchange rate according to the offline map of currency pairs to tenor object.

The calculation of the tenor is based on the difference in calendar days between the 'tenorCalculationDate' and the 'endAt' date:

  • If the number of calendar days from 'tenorCalculationDate' to endAt is less than or equal to 7, the tenor is 7 days.
  • If the number of calendar days from 'tenorCalculationDate' to endAt is greater than 7 and less than or equal to 14, the tenor is 14 days.
  • If the number of calendar days from 'tenorCalculationDate' to endAt is greater than 14 and less than or equal to 30, the tenor is 30 days.
  • If the number of calendar days from 'tenorCalculationDate' to endAt is greater than 30 and less than or equal to 60, the tenor is 60 days.
  • ...
  • If the number of calendar days from 'tenorCalculationDate' to endAt is greater than 330 and less than or equal to 360, the tenor is 360 days.

When counting the difference in calendar days, every day is counted as one regardless of the duration of the day. This means that the calculation includes all days: weekends, holidays, and weekdays alike.

For example, if the 'endAt' date is 2023-12-16 and the 'tenorCalculationDate' is 2024-12-15, the result is 1 calendar day.

To calculate the difference in calendar days accurately, we recommend using a date manipulation library, such as date-fns and its differenceInCalendarDays function, or a similar feature provided by other date libraries.

Example:

20.616512

externalTransactionId
string

Optional The transaction id, as identified within your system.

Example:

"780231b3ae0d7e9e5097nd89"

extraFields
object

Additional fields that provide further details about the transaction. These fields should be specified as a valid JSON object.

Example:
{
"field_a": "value_a",
"field_b": "value_b"
}

Response

Hedge Accepted

The response of accepting an offline rate for a hedge.

id
string<uuid>
required

The id of the created object.

Pattern: [0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}
Example:

"1b0ada1e-fa1b-4cfe-a553-01b340c5650e"

transactionId
string<uuid>

The id of the transaction within the Grain platform.

Pattern: [0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}
Example:

"4d78ac65-2c3f-47e2-8bf3-3f76124e9d27"