# Get Order By Id

`GET https://api.cnaught.com/v1/orders/{id}`

Returns information about an order

## Authorization

Requires an `Authorization: Bearer <token>` header, where `<token>` is your CNaught API key.

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | ID of order to return |

## Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `X-Subaccount-Id` | string | no | If present, will only retrieve the order if it belongs to the subaccount with given id. |

## Responses

### 200 — Order Details

- `id` (string) — Identifier that can be used to retrieve the order details
- `order_number` (string) — Hex representation derived from the order id that will be shown on the certificate
- `created_on` (string) — Timestamp of when the order was created (in UTC)
- `metadata` (string | null) — Optional metadata that was provided with the order
- `description` (string | null) — Optional public description for the order that will be shown on the certificate, as provided when order was placed
- `amount_kg` (number) — Amount of credits purchased, in kg of CO₂e
- `state` (enum<string>) — The current state of the order. * `placed` - the order has been placed, and is waiting to be matched against available credits in our system. * `fulfilled` - the order has been fulfilled by matching it against available credits in our system, which have been retired. * `canceled` - the order has been canceled
- `price_usd_cents` (number) — Amount charged for the credits purchased, in USD cents
- `callback_url` (string) — Callback URL to invoke when status of the order changes, if specified in the order
- `certificate_public_url` (string | null) — URL for the publicly accessible page showing order details and the certificate. This will be null if the order state is cancelled
- `certificate_download_public_url` (string | null) — URL for downloading the certificate PDF. This will be null if the order state is cancelled
- `project_allocations` (ProjectAllocation[]) — For fulfilled orders, a list of the projects that were used to fulfill the order
  - `project` (Project) — Details of the project for this allocation
    - `id` (string) — Identifier that can be used to retrieve the project details
    - `name` (string) — Name of the project
    - `summary` (string | null) — A short summary of the project
    - `description` (string | null) — A longer description of the project
    - `type` (string) — Type of project, eg Afforrestation, Renewable Energy, etc
    - `activity_types` (string[]) — List of activity types for the project
    - `developer` (string | null) — The name of the company or organization sponsoring the project
    - `registry_name` (string | null) — The name of the registry on which the project's credits are registered
    - `registry_id` (string | null) — The id of the project within the registry
    - `registry_url` (string | null) — The full url to the project's documentation on the registry website
    - `location_name` (string | null) — Location of the project
    - `location_latitude` (number | null) — Latitude for the location of the project
    - `location_longitude` (number | null) — Longitude for the location of the project
    - `primary_image_url` (string | null) — URL for the primary image of the project
    - `un_sdg_goals` (number[]) — list of UN Sustainable Development Goals supported by this project; see https://sdgs.un.org/goals
    - `methodology` (string | null) — The methodology used for the project
    - `verifier` (string | null) — The verifier of the project
    - `permanence` (string | null) — Information about the permanence of the carbon removal
    - `lifetime` (object) — The lifetime of the project
      - `start_year` (integer | null) — The start year of the project
      - `end_year` (integer | null) — The end year of the project
    - `impact_type` (string | null) — The type of impact the project has (avoided emissions, removal, or mix of both)
    - `due_diligence` (string | null) — Information about the due diligence performed on the project
    - `beyond_carbon` (string | null) — Information about benefits beyond carbon reduction
    - `risk_of_reversal` (string | null) — Information about the risk of carbon reversal
    - `third_party_labels` (string[] | null) — List of third-party labels or certifications
    - `notable_buyers` (object[] | null) — List of notable buyers of credits from this project
      - `name` (string) — Name of the buyer
      - `logo_url` (string) — URL to the buyer's logo
      - `logo_alt_text` (string | null) — Alt text for the buyer's logo
    - `due_diligence_figure` (object | null) — Figure illustrating due diligence information
      - `description` (string) — Description of the due diligence figure
      - `image_url` (string) — URL to the due diligence figure image
      - `image_alt_text` (string | null) — Alt text for the due diligence figure image
    - `news_articles` (object[] | null) — List of news articles related to the project
      - `title` (string) — Title of the news article
      - `url` (string) — URL to the news article
      - `author` (string) — Author of the news article
      - `published_on` (string<date-time>) — Publication date of the news article
      - `cnaught_take` (string | null) — CNaught's perspective on the news article
  - `amount_kg` (number) — Amount (in kg CO₂e) of the order fulfilled from this project
  - `retirements` (Retirement[]) — List of retirement records for this project allocation
    - `serial_number_range` (string | null) — The serial number range of the retired tranche block(s) from which an order's project allocation is taken. The format differs depending on the registry
    - `url` (string | null) — The url to the retired tranche block(s) record on the project's registry
- `checkout_session_id` (string | null) — Id of the checkout session whose completion resulted in the creation of this order. Null if the order did not originate from a checkout session.

```json
{
  "id": "Gre28Fc35bt3",
  "order_number": "47726-53238-46633-33562-7433",
  "created_on": "2022-08-01T18:00:00.000000Z",
  "metadata": "Customer metadata",
  "description": "On behalf of Jane Smith",
  "amount_kg": 10.5,
  "state": "placed",
  "price_usd_cents": 2350
}
```

### 401 — Request Unauthorized

- `title` (string) — Short, human-readable summary of the problem type
- `status` (integer) — HTTP status code of the error

```json
{
  "title": "Authorization has been denied for this request",
  "status": 401
}
```

### 404 — Order Not Found

- `title` (string) — Short, human-readable summary of the problem
- `details` (string) — Longer, human-readable description of the problem
- `type` (string) — URI that identifies the problem type
- `status` (integer) — HTTP status code of the error

```json
{
  "type": "https://api.cnaught.com/v1/errors/not-found",
  "title": "Could not find order",
  "status": 404
}
```

## Code samples

### cURL

```bash
curl --request GET \
  --url https://api.cnaught.com/v1/orders/<id> \
  --header 'Authorization: Bearer <token>'
```

### Python

```python
import requests

url = "https://api.cnaught.com/v1/orders/<id>"
headers = {
    "Authorization": "Bearer <token>"
}

response = requests.get(url, headers=headers)

print(response.json())
```

### Node

```javascript
const response = await fetch('https://api.cnaught.com/v1/orders/<id>', {
    method: 'GET',
    headers: {
        Authorization: 'Bearer <token>'
    }
});

const data = await response.json();
console.log(data);
```
