https://api.cnaught.com/v1
. All endpoints described in this documentation are relative to this base URL.
Authorization
header. If the API key is invalid, a 401
error code will be returned.
Use your sandbox API key to make sandbox requests and production API key for production requests.
X-Subaccount-Id
header in an API call. Doing so in the Place order
API call will associate the order with that subaccount, and doing so in the Get List of Orders API call will
only retrieve orders associated with that subaccount. All APIs which support specifying a subaccount will mention it in their
reference documentation.
support@cnaught.com
if you would like to use this feature.success_url
to redirect the user to once they complete checkout)checkout_url
of the session. This is essentially a hosted checkout page that will securely handle the purchase of carbon credits.success_url
.notification_config
parameter is provided, the API will make an HTTP POST request to the URL specified in that parameter with details in the request body when the order state changes - eg an order becomes fulfilled or is cancelled.
Here is an example of the POST request body sent after an order becomes fulfilled
notification_config.url
parameter. The request body will contain the order details.200
response code.200
response, CNaught will periodically retry the callback URL until either 24 hours have passed or a 200
response code is received.Idempotency-Key:<key>
header in the request.
The <key>
should be a unique identifier for the request with a maximum of 512 characters. If you don’t receive a response (for example, in case of a timeout), you can safely retry the request with the same header.
If CNaught has already processed the request, the response to the first attempt will be returned without duplication. This will be indicated by the inclusion of a X-Idempotent-Replay: true
header in the response.
How you create unique keys is up to you - one possibility is V4 UUIDs, or another random string with enough entropy to avoid collisions.
Idempotency keys are expected to be unique per user account. Submitting a request with the same idempotency key as a previous request but different payload (e.g. different URL or request body) will result in a 422
response status code a problem details response body with a type of https://api.cnaught.com/v1/errors/idempotency-changed-payload
.
This is done to prevent accidental mistakes due to client logic bugs.
If a request with an idempotency key is submitted while a previous request with the same idempotency key is still being processed, a 409
response status code and a problem details response body with a type of https://api.cnaught.com/v1/errors/idempotency-concurrent-requests
is returned.
In this case, your application should retry the request after a short delay.
Both success and error responses are eligible to be cached and returned without execution for an idempotent request. The few exceptions are
error responses corresponding to transient conditions: e.g. 409
conflict responses as described above, 429
responses due to rate limiting,
or any 5xx
responses due to temporary server errors.
Idempotency keys are scoped to your user account and expire after 24 hours.
4xx
and 5xx
HTTP status codes. 4xx
status codes indicate an error due to the request provided (for example, a required parameter was omitted). 5xx
error indicate an error with CNaught’s servers.
When an 4xx error occurs during invocation of a request, the API responds with a problem details HTTP response payload.
Some common errors returned by the API, and their meanings are:
Status Code | Error | Description |
---|---|---|
400 | Bad Request | The request contained some invalid parameters. The details are specific to the operation in question |
401 | Unauthorized | A request did not have a valid, active API key corresponding to an active user |
403 | Forbidden | A request could not be processed because the relevant order or user was not in a state where the requested operation is valid. The details are specific to the operation in question. |
409 | Conflict | A second request with same Idempotency Key as a previous one was submitted while the previous request was still processing. Retry the request after backoff. |
422 | Unprocessable Entity | A second request with same Idempotency Key as a previous one but with different payload was submitted. This likely indicates a logic error in the client code. |
429 | Too Many Requests | A rate limit was exceeded for an API request. Retry the request with expontential backoff. |
503 | Service Unavailable | The API is temporarily offline due to some infrastructure component (eg database) being unavailable. Retry the request with exponential backoff. |
Status Code | Error |
---|---|
409 | Conflict |
429 | Too Many Requests |
502 | Bad Gateway |
503 | Service Unavailable |
504 | Gateway Timeout |
429
status code, it is recommended that the maximum number of retries be limited to 5 attempts per request. The number of retries can be higher for 429
errors but if you notice consistent throttling, please contact the support team at support@cnaught.com.Property | Description |
---|---|
type | A URI representing the type for the error |
title | A short human readable description of type |
details | Additional details of the error |
status | HTTP status code of the error |