Create your first customer
Before you create a hedge, you need to create its customer. Create your first customer using the create customer API:
- cURL
- JavaScript
- Python
- Java
- C#
curl --request POST \
--url https://api.grainfinance.co/v1/customers \
--header "Content-Type: application/json" \
--header 'Authorization: Basic CLIENT_ID:CLIENT_SECRET' \
--data '{
"contactEmail": "{contactEmail}",
"contactFullName": "{contactFullName}",
"contactPhoneNumber": "{contactPhoneNumber}",
"companyName": "{companyName}",
"companyAddress": "{companyAddress}",
"externalCustomerId": "{externalCustomerId}",
"companyCity": "{companyCity}"
}'
const url = 'https://api.grainfinance.co/v1/customers';
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic CLIENT_ID:CLIENT_SECRET'
},
body: JSON.stringify({
"contactEmail": "{contactEmail}",
"contactFullName": "{contactFullName}",
"contactPhoneNumber": "{contactPhoneNumber}",
"companyName": "{companyName}",
"companyAddress": "{companyAddress}",
"externalCustomerId": "{externalCustomerId}",
"companyCity": "{companyCity}"
})
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = 'https://api.grainfinance.co/v1/customers'
payload = {
"contactEmail": "{contactEmail}",
"contactFullName": "{contactFullName}",
"contactPhoneNumber": "{contactPhoneNumber}",
"companyName": "{companyName}",
"companyAddress": "{companyAddress}",
"externalCustomerId": "{externalCustomerId}",
"companyCity": "{companyCity}"
}
headers = {
'Content-Type': 'application/json'
}
response = requests.post(
url,
headers=headers,
json=payload
)
data = response.json()
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "https://api.grainfinance.co/v1/customers")
.setHeader("Content-Type", "application/json")
.setHeader("Authorization", "Basic CLIENT_ID:CLIENT_SECRET")
.setBody("{
"contactEmail": "{contactEmail}",
"contactFullName": "{contactFullName}",
"contactPhoneNumber": "{contactPhoneNumber}",
"companyName": "{companyName}",
"companyAddress": "{companyAddress}",
"externalCustomerId": "{externalCustomerId}",
"companyCity": "{companyCity}"
}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
using RestSharp;
var options = new RestClientOptions("https://api.grainfinance.co/v1/customers");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Basic CLIENT_ID:CLIENT_SECRET");request.AddParameter("data", "{
"contactEmail": "{contactEmail}",
"contactFullName": "{contactFullName}",
"contactPhoneNumber": "{contactPhoneNumber}",
"companyName": "{companyName}",
"companyAddress": "{companyAddress}",
"externalCustomerId": "{externalCustomerId}",
"companyCity": "{companyCity}"
}");
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
In the response, you will receive the id of the created customer.
{
"id": "{customerId}"
}