Prerequisites
To follow this tutorial, you need a c-mass account. If you don’t have one yet, you can sign up for a free account.
Steps to Get Started
1. Generate Your API Key
Before making any requests, you’ll need an API key to authenticate with the c-mass API. Follow these steps:
- Log in to your c-mass account.
- Go to the Devs tab.
- Click Create test API key to generate a test key, or Set up API to create a live key (a payment method is required for live mode).
Store your API key securely, as it will only be displayed once. If needed, you can rotate your API key. The previous key will remain valid for 24 hours.
2. Placing an Order
Once you have your API key, you can submit an order for carbon credits. Replace <C-MASS_API_KEY>
with the API key you obtained in Step 1, and specify the amount of carbon credits (in kilograms of CO₂e) you want to purchase.
curl --request POST \
--url https://carbon-engine.onrender.com/v1/orders \
--header 'Authorization: Bearer <C-MASS_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"amount_kg": 123,
"description": "<string>",
"customer": "<string>",
"portfolioId": "<string>",
}'
You’ll receive a response like this:
javascript
{
{
"_id": "1728559515925",
"orderNumber": "<string>",
"description": "<string>",
"price_sar_halalas": 123,
"amount_kg": 123,
"kg_price": 123,
"callbackUrl": "<string>",
"certificateUrl": "<string>",
"state": "<string>",
"portfolio": "<string>",
"projectRecords": [
{
"project_id": "<string>",
"project_category_id": "<string>",
"credit_batch_id": "<string>",
"delta": 123,
"recorded_on": "2023-11-07T05:31:56Z"
}
],
"invoice": {
"amountDueSarHalalas": 123,
"balanceAppliedSarHalalas": 123,
"receiptUrl": "<string>"
}
}
}
The _id (in this case 1728559515925) will allow you to retrieve your order.