Create order with emissions
curl --request POST \
--url https://api.gocrex.com/api/customer-orders \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"customer_id": "<string>",
"order_date": "2023-12-25",
"order_id": "<string>",
"tenure_start_date": "2023-12-25",
"items": [
{
"config": {
"product_id": "<string>",
"serial_number": "<string>",
"tenure_months": 123,
"weight_kg": 123
}
}
]
}
'import requests
url = "https://api.gocrex.com/api/customer-orders"
payload = {
"customer_id": "<string>",
"order_date": "2023-12-25",
"order_id": "<string>",
"tenure_start_date": "2023-12-25",
"items": [{ "config": {
"product_id": "<string>",
"serial_number": "<string>",
"tenure_months": 123,
"weight_kg": 123
} }]
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customer_id: '<string>',
order_date: '2023-12-25',
order_id: '<string>',
tenure_start_date: '2023-12-25',
items: [
{
config: {
product_id: '<string>',
serial_number: '<string>',
tenure_months: 123,
weight_kg: 123
}
}
]
})
};
fetch('https://api.gocrex.com/api/customer-orders', 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.gocrex.com/api/customer-orders",
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([
'customer_id' => '<string>',
'order_date' => '2023-12-25',
'order_id' => '<string>',
'tenure_start_date' => '2023-12-25',
'items' => [
[
'config' => [
'product_id' => '<string>',
'serial_number' => '<string>',
'tenure_months' => 123,
'weight_kg' => 123
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.gocrex.com/api/customer-orders"
payload := strings.NewReader("{\n \"customer_id\": \"<string>\",\n \"order_date\": \"2023-12-25\",\n \"order_id\": \"<string>\",\n \"tenure_start_date\": \"2023-12-25\",\n \"items\": [\n {\n \"config\": {\n \"product_id\": \"<string>\",\n \"serial_number\": \"<string>\",\n \"tenure_months\": 123,\n \"weight_kg\": 123\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.gocrex.com/api/customer-orders")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"customer_id\": \"<string>\",\n \"order_date\": \"2023-12-25\",\n \"order_id\": \"<string>\",\n \"tenure_start_date\": \"2023-12-25\",\n \"items\": [\n {\n \"config\": {\n \"product_id\": \"<string>\",\n \"serial_number\": \"<string>\",\n \"tenure_months\": 123,\n \"weight_kg\": 123\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gocrex.com/api/customer-orders")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer_id\": \"<string>\",\n \"order_date\": \"2023-12-25\",\n \"order_id\": \"<string>\",\n \"tenure_start_date\": \"2023-12-25\",\n \"items\": [\n {\n \"config\": {\n \"product_id\": \"<string>\",\n \"serial_number\": \"<string>\",\n \"tenure_months\": 123,\n \"weight_kg\": 123\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"created_at": "2023-11-07T05:31:56Z",
"customer_id": "<string>",
"emission_unit": "kgCO2e",
"items": [
{
"device_id": "<string>",
"emission_breakdown": {
"packaging": {
"description": "<string>",
"emission": 123,
"emission_unit": "kgCO2e",
"ghg_category": "<string>",
"ghg_scope": "<string>",
"type": "<string>"
},
"product_embodied_emission": {
"description": "<string>",
"emission": 123,
"emission_unit": "kgCO2e",
"ghg_category": "<string>",
"ghg_scope": "<string>",
"type": "<string>"
},
"product_use": {
"description": "<string>",
"emission": 123,
"emission_unit": "kgCO2e",
"ghg_category": "<string>",
"ghg_scope": "<string>",
"type": "<string>"
},
"transportation": {
"description": "<string>",
"emission": 123,
"emission_unit": "kgCO2e",
"ghg_category": "<string>",
"ghg_scope": "<string>",
"type": "<string>"
}
},
"serial_number": "<string>",
"total_emission": 123,
"type": "product"
}
],
"order_date": "2023-12-25",
"order_id": "<string>",
"status": "created",
"tenure_start_date": "2023-12-25",
"total_emission": 123
}{
"error": "Invalid parameter"
}{
"code": "unauthorized",
"detail": "Invalid API key"
}Endpoints
Create order with emissions
Estimate emission given an order
Create order with emissions
curl --request POST \
--url https://api.gocrex.com/api/customer-orders \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"customer_id": "<string>",
"order_date": "2023-12-25",
"order_id": "<string>",
"tenure_start_date": "2023-12-25",
"items": [
{
"config": {
"product_id": "<string>",
"serial_number": "<string>",
"tenure_months": 123,
"weight_kg": 123
}
}
]
}
'import requests
url = "https://api.gocrex.com/api/customer-orders"
payload = {
"customer_id": "<string>",
"order_date": "2023-12-25",
"order_id": "<string>",
"tenure_start_date": "2023-12-25",
"items": [{ "config": {
"product_id": "<string>",
"serial_number": "<string>",
"tenure_months": 123,
"weight_kg": 123
} }]
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customer_id: '<string>',
order_date: '2023-12-25',
order_id: '<string>',
tenure_start_date: '2023-12-25',
items: [
{
config: {
product_id: '<string>',
serial_number: '<string>',
tenure_months: 123,
weight_kg: 123
}
}
]
})
};
fetch('https://api.gocrex.com/api/customer-orders', 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.gocrex.com/api/customer-orders",
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([
'customer_id' => '<string>',
'order_date' => '2023-12-25',
'order_id' => '<string>',
'tenure_start_date' => '2023-12-25',
'items' => [
[
'config' => [
'product_id' => '<string>',
'serial_number' => '<string>',
'tenure_months' => 123,
'weight_kg' => 123
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.gocrex.com/api/customer-orders"
payload := strings.NewReader("{\n \"customer_id\": \"<string>\",\n \"order_date\": \"2023-12-25\",\n \"order_id\": \"<string>\",\n \"tenure_start_date\": \"2023-12-25\",\n \"items\": [\n {\n \"config\": {\n \"product_id\": \"<string>\",\n \"serial_number\": \"<string>\",\n \"tenure_months\": 123,\n \"weight_kg\": 123\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.gocrex.com/api/customer-orders")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"customer_id\": \"<string>\",\n \"order_date\": \"2023-12-25\",\n \"order_id\": \"<string>\",\n \"tenure_start_date\": \"2023-12-25\",\n \"items\": [\n {\n \"config\": {\n \"product_id\": \"<string>\",\n \"serial_number\": \"<string>\",\n \"tenure_months\": 123,\n \"weight_kg\": 123\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gocrex.com/api/customer-orders")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer_id\": \"<string>\",\n \"order_date\": \"2023-12-25\",\n \"order_id\": \"<string>\",\n \"tenure_start_date\": \"2023-12-25\",\n \"items\": [\n {\n \"config\": {\n \"product_id\": \"<string>\",\n \"serial_number\": \"<string>\",\n \"tenure_months\": 123,\n \"weight_kg\": 123\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"created_at": "2023-11-07T05:31:56Z",
"customer_id": "<string>",
"emission_unit": "kgCO2e",
"items": [
{
"device_id": "<string>",
"emission_breakdown": {
"packaging": {
"description": "<string>",
"emission": 123,
"emission_unit": "kgCO2e",
"ghg_category": "<string>",
"ghg_scope": "<string>",
"type": "<string>"
},
"product_embodied_emission": {
"description": "<string>",
"emission": 123,
"emission_unit": "kgCO2e",
"ghg_category": "<string>",
"ghg_scope": "<string>",
"type": "<string>"
},
"product_use": {
"description": "<string>",
"emission": 123,
"emission_unit": "kgCO2e",
"ghg_category": "<string>",
"ghg_scope": "<string>",
"type": "<string>"
},
"transportation": {
"description": "<string>",
"emission": 123,
"emission_unit": "kgCO2e",
"ghg_category": "<string>",
"ghg_scope": "<string>",
"type": "<string>"
}
},
"serial_number": "<string>",
"total_emission": 123,
"type": "product"
}
],
"order_date": "2023-12-25",
"order_id": "<string>",
"status": "created",
"tenure_start_date": "2023-12-25",
"total_emission": 123
}{
"error": "Invalid parameter"
}{
"code": "unauthorized",
"detail": "Invalid API key"
}Authorizations
Body
application/json
OrderParams
Order Params
Your customer ID. This is used to identify the customer in your system.
The date of the Order (YYYY-MM-DD)
Your order ID. This is used to identify the order in your system.
The start date of the order (YYYY-MM-DD)
Show child attributes
Show child attributes
Response
OrderResponse
Order creation date
Customer ID
Unit of GHG emission
Example:
"kgCO2e"
List of items in the order
Show child attributes
Show child attributes
Order date
Order ID
Order status
Example:
"created"
Order's tenure start date
Total GHG emission of the order
⌘I