curl --request POST \
--url https://api.grainfinance.co/v1/customers/{customerId}/hedges/accept-quote \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--header 'X-Customer-IP: <x-customer-ip>' \
--data '
{
"hedgeProposalId": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"externalTransactionId": "780231b3ae0d7e9e5097nd89",
"extraFields": {
"field_a": "value_a",
"field_b": "value_b"
}
}
'import requests
url = "https://api.grainfinance.co/v1/customers/{customerId}/hedges/accept-quote"
payload = {
"hedgeProposalId": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"externalTransactionId": "780231b3ae0d7e9e5097nd89",
"extraFields": {
"field_a": "value_a",
"field_b": "value_b"
}
}
headers = {
"X-Customer-IP": "<x-customer-ip>",
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Customer-IP': '<x-customer-ip>',
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
hedgeProposalId: '497f6eca-6276-4993-bfeb-53cbbbba6f08',
externalTransactionId: '780231b3ae0d7e9e5097nd89',
extraFields: {field_a: 'value_a', field_b: 'value_b'}
})
};
fetch('https://api.grainfinance.co/v1/customers/{customerId}/hedges/accept-quote', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.grainfinance.co/v1/customers/{customerId}/hedges/accept-quote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'hedgeProposalId' => '497f6eca-6276-4993-bfeb-53cbbbba6f08',
'externalTransactionId' => '780231b3ae0d7e9e5097nd89',
'extraFields' => [
'field_a' => 'value_a',
'field_b' => 'value_b'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json",
"X-Customer-IP: <x-customer-ip>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.grainfinance.co/v1/customers/{customerId}/hedges/accept-quote"
payload := strings.NewReader("{\n \"hedgeProposalId\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\",\n \"externalTransactionId\": \"780231b3ae0d7e9e5097nd89\",\n \"extraFields\": {\n \"field_a\": \"value_a\",\n \"field_b\": \"value_b\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Customer-IP", "<x-customer-ip>")
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.grainfinance.co/v1/customers/{customerId}/hedges/accept-quote")
.header("X-Customer-IP", "<x-customer-ip>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"hedgeProposalId\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\",\n \"externalTransactionId\": \"780231b3ae0d7e9e5097nd89\",\n \"extraFields\": {\n \"field_a\": \"value_a\",\n \"field_b\": \"value_b\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.grainfinance.co/v1/customers/{customerId}/hedges/accept-quote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Customer-IP"] = '<x-customer-ip>'
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"hedgeProposalId\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\",\n \"externalTransactionId\": \"780231b3ae0d7e9e5097nd89\",\n \"extraFields\": {\n \"field_a\": \"value_a\",\n \"field_b\": \"value_b\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "8173b9a7-ee61-413e-b9e3-7c04b2a067c5",
"customerId": "1b0ada1e-fa1b-4cfe-a553-01b340c5650e",
"status": "Active",
"fixedSide": "toCurrencyAmount",
"transactionId": "4d78ac65-2c3f-47e2-8bf3-3f76124e9d27",
"externalTransactionId": "780231b3ae0d7e9e5097nd89",
"externalCustomerId": "630231b3ae0d7e9e5097ad35",
"fromCurrency": "MXN",
"toCurrency": "USD",
"settlementType": "full",
"initialCollateralAmount": 1608.09,
"quote": 20.6165,
"externalMarkupPct": 1,
"issuedAt": "2023-01-18",
"acceptedAtTs": 1674057600,
"fromCurrencyAmount": 32161.8,
"toCurrencyAmount": 1560,
"endAt": "2023-02-23",
"settlementAt": "2023-02-23",
"updatedAt": "2023-01-18",
"cancelledAt": null,
"initialCollateralReceivedAt": null,
"fundsReceivedAt": null,
"completedAt": null,
"completedAtTs": null,
"overdueAt": "2023-02-28",
"adjustedMtmChangePct": 1.25,
"adjustedMtmChangeTs": 1674144000
}Accept
Accepts a previously generated real-time rate proposal and creates the hedge transaction.
curl --request POST \
--url https://api.grainfinance.co/v1/customers/{customerId}/hedges/accept-quote \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--header 'X-Customer-IP: <x-customer-ip>' \
--data '
{
"hedgeProposalId": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"externalTransactionId": "780231b3ae0d7e9e5097nd89",
"extraFields": {
"field_a": "value_a",
"field_b": "value_b"
}
}
'import requests
url = "https://api.grainfinance.co/v1/customers/{customerId}/hedges/accept-quote"
payload = {
"hedgeProposalId": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"externalTransactionId": "780231b3ae0d7e9e5097nd89",
"extraFields": {
"field_a": "value_a",
"field_b": "value_b"
}
}
headers = {
"X-Customer-IP": "<x-customer-ip>",
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Customer-IP': '<x-customer-ip>',
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
hedgeProposalId: '497f6eca-6276-4993-bfeb-53cbbbba6f08',
externalTransactionId: '780231b3ae0d7e9e5097nd89',
extraFields: {field_a: 'value_a', field_b: 'value_b'}
})
};
fetch('https://api.grainfinance.co/v1/customers/{customerId}/hedges/accept-quote', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.grainfinance.co/v1/customers/{customerId}/hedges/accept-quote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'hedgeProposalId' => '497f6eca-6276-4993-bfeb-53cbbbba6f08',
'externalTransactionId' => '780231b3ae0d7e9e5097nd89',
'extraFields' => [
'field_a' => 'value_a',
'field_b' => 'value_b'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json",
"X-Customer-IP: <x-customer-ip>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.grainfinance.co/v1/customers/{customerId}/hedges/accept-quote"
payload := strings.NewReader("{\n \"hedgeProposalId\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\",\n \"externalTransactionId\": \"780231b3ae0d7e9e5097nd89\",\n \"extraFields\": {\n \"field_a\": \"value_a\",\n \"field_b\": \"value_b\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Customer-IP", "<x-customer-ip>")
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.grainfinance.co/v1/customers/{customerId}/hedges/accept-quote")
.header("X-Customer-IP", "<x-customer-ip>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"hedgeProposalId\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\",\n \"externalTransactionId\": \"780231b3ae0d7e9e5097nd89\",\n \"extraFields\": {\n \"field_a\": \"value_a\",\n \"field_b\": \"value_b\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.grainfinance.co/v1/customers/{customerId}/hedges/accept-quote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Customer-IP"] = '<x-customer-ip>'
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"hedgeProposalId\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\",\n \"externalTransactionId\": \"780231b3ae0d7e9e5097nd89\",\n \"extraFields\": {\n \"field_a\": \"value_a\",\n \"field_b\": \"value_b\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "8173b9a7-ee61-413e-b9e3-7c04b2a067c5",
"customerId": "1b0ada1e-fa1b-4cfe-a553-01b340c5650e",
"status": "Active",
"fixedSide": "toCurrencyAmount",
"transactionId": "4d78ac65-2c3f-47e2-8bf3-3f76124e9d27",
"externalTransactionId": "780231b3ae0d7e9e5097nd89",
"externalCustomerId": "630231b3ae0d7e9e5097ad35",
"fromCurrency": "MXN",
"toCurrency": "USD",
"settlementType": "full",
"initialCollateralAmount": 1608.09,
"quote": 20.6165,
"externalMarkupPct": 1,
"issuedAt": "2023-01-18",
"acceptedAtTs": 1674057600,
"fromCurrencyAmount": 32161.8,
"toCurrencyAmount": 1560,
"endAt": "2023-02-23",
"settlementAt": "2023-02-23",
"updatedAt": "2023-01-18",
"cancelledAt": null,
"initialCollateralReceivedAt": null,
"fundsReceivedAt": null,
"completedAt": null,
"completedAtTs": null,
"overdueAt": "2023-02-28",
"adjustedMtmChangePct": 1.25,
"adjustedMtmChangeTs": 1674144000
}Authorizations
Basic authentication using the partner API keys from https://console.grainfinance.co/keys
Headers
Path Parameters
Body
The payload required in order to accept a hedge proposal and create the hedge.
Specifies the amount to hedge in the toCurrency. This field may be provided on Accept only if the amount was not specified on the Quote call. When provided, this sets fixedSide to toCurrencyAmount, and the fromCurrencyAmount is calculated as: fromCurrencyAmount = toCurrencyAmount × quote. Only one of toCurrencyAmount or fromCurrencyAmount should be provided.
Specifies the amount to hedge in the fromCurrency. This field may be provided on Accept only if the amount was not specified on the Quote call. When provided, this sets fixedSide to fromCurrencyAmount, and the toCurrencyAmount is calculated as: toCurrencyAmount = fromCurrencyAmount / quote. Only one of toCurrencyAmount or fromCurrencyAmount should be provided.
Response
Hedge Accepted
- Option 1
- Option 2
Hedge objects represent transactions which are currently hedged.
Indicates which currency amount was fixed (specified) when creating the hedge.
When fixedSide is toCurrencyAmount, the toCurrencyAmount was specified and fromCurrencyAmount was calculated.
When fixedSide is fromCurrencyAmount, the fromCurrencyAmount was specified and toCurrencyAmount was calculated.
toCurrencyAmount, fromCurrencyAmount "toCurrencyAmount"