Skip to main content
cURL
curl --request POST \
  --url https://api.grainfinance.co/v1/customers/{customerId}/dual-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",
  "customerToCurrencyAmount": 100000,
  "vendorToCurrencyAmount": 100000,
  "customerEndAt": "2024-02-23",
  "vendorEndAt": "2024-02-23",
  "rate": 20.616512,
  "externalTransactionId": "780231b3ae0d7e9e5097nd89",
  "extraFields": {
    "field_a": "value_a",
    "field_b": "value_b"
  }
}
'
{
  "id": "8173b9a7-ee61-413e-b9e3-7c04b2a067c5",
  "hedgeIds": [
    "4d78ac65-2c3f-47e2-8bf3-3f76124e9d27",
    "5e89bd76-3d4f-58e3-9cf4-4g87235e0e38"
  ],
  "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 to accept an offline quote for a dual hedge

The payload required to accept an offline quote for a dual 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 by your customer.

Example:

"MXN"

toCurrency
string
required

The currency you want to buy.

Example:

"USD"

customerToCurrencyAmount
number<double>
required

The amount to hedge in the toCurrency for the customer.

Example:

100000

vendorToCurrencyAmount
number<double>
required

The amount to hedge in the toCurrency for the vendor.

Example:

100000

customerEndAt
string
required

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

Example:

"2024-02-23"

vendorEndAt
string
required

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

Example:

"2024-02-23"

rate
number<double>
required

Represents the offline hedge rate determined by a two-dimensional lookup based on the vendor and customer tenors.

Calculating Tenors:

Tenors are calculated from the calendar-day difference between the tenorCalculationDate and the vendor/customer end dates, then mapped into the nearest supported tenor bucket:

  • 0 and ≤ 7 calendar days → 7-day tenor

  • 7 and ≤ 14 calendar days → 14-day tenor

  • 14 and ≤ 30 calendar days → 30-day tenor

  • 30 and ≤ 60 calendar days → 60-day tenor

  • 60 and ≤ 90 calendar days → 90-day tenor

  • … continues in similar ranges up to 720 days

Note: All calendar days count — weekends and holidays included.

Rate Lookup Example:

The rate is retrieved from a two-dimensional map using both tenors:

"USDMXN": {
"7": { "7": 1.1 },
"14": { "7": 1.2, "14": 1.3 },
"30": { "7": 1.1, "14": 1.1, "30": 1.1 },
// ... and so on
}

In this example, if the vendor tenor is 14 days and the customer tenor is 7 days, the rate would be 1.2.

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
required

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

Dual Hedge Accepted

The response of accepting an offline rate for a dual hedge.

id
string<uuid>
required

The id of the dual hedge 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:

"8173b9a7-ee61-413e-b9e3-7c04b2a067c5"

hedgeIds
string<uuid>[]
required

The ids of the individual hedges created as part of this dual hedge.

Stringified UUIDv4. See RFC 4112

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",
"5e89bd76-3d4f-58e3-9cf4-4g87235e0e38"
]
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"