Skip to main content
GET
List Units
Retrieve the catalog of measurement units. Every endpoint that takes a unit (unit_id, non_currency_unit_id, …) expects the id of an entry of this catalog, so this is where you look it up.
Reference data. The catalog is global: the same ids apply to every organization, and the response is not filtered by the organization you authenticate with. Unit ids do not change, so fetch the catalog once, cache it, and look ids up locally.

Request

Headers

string
required
Your API key for authentication. Send it in this header: a key sent as Authorization: Bearer is read as a login token and rejected with 401.Format: Your API key string
string
required
UUID of the API key’s organization, or of one of its subsidiaries. Required even though the catalog itself is global: the key is checked against it.Format: UUID

Query Parameters

string
Optional shortcut to the units the Dcycle app offers in one form, instead of the whole catalog. Each value returns a fixed list of units, shown in What each type returns. It does not filter on the type field of the response, and it does not validate anything.Omit it to get the whole catalog. A value outside the table is rejected with 422. Send it as type: a parameter named type[] is ignored, so ?type[]=wastes returns the whole catalog.Example: wastes

What each type returns

Each value is the list of units that one form of the Dcycle app offers. The lists are fixed, not derived from the type field of the units they contain: type=wastes returns kilogram_(kg), whose type is solid. Forms for activity data Custom emission factors only These values are used by a single form: the one that creates a custom emission factor record, which offers these units for the record’s unit_id depending on its activity category.
type tells you what the app offers, not what an endpoint accepts. Some write endpoints accept only a fixed set of units and reject any other: the weight of a shipment, for example, must be one of the units type=transport returns. Others apply their own rules, like vehicle consumptions, which accept the units of the vehicle’s fuel (List Vehicle Fuels). Check the unit field on the page of the endpoint you write to.The type of each unit in the response is a different thing: a legacy classification (solid, mass, energy, fiat_currency, …) that is not a valid value for this parameter. In particular, no value of the parameter returns the currencies: to resolve one, request the whole catalog and match its name (see Resolve the currency of a purchase).

Response

array[object]
Array of unit objects, not paginated. Without type, and with type=transport, it is ordered by name; with any other type the order is not guaranteed. Do not rely on positions either way: pick a unit by id or by its exact name.

Example

Successful Response

Returns 200 OK with the unit array. For ?type=transport:

Common Errors

Errors on this endpoint use the {"code", "detail"} and {"detail": [...]} shapes below, not the problem details format of /v2/wastes.

401 Unauthorized

Cause: The API key does not exist or is not active.
Cause: The API key belongs to an organization that is neither the one in x-organization-id nor one of its parents.
Cause: The API key has no owner, which happens with old keys. Regenerate it.
Cause: No credentials at all: neither x-api-key nor a login token.
Cause: The API key was sent as Authorization: Bearer. That header is for login tokens, so the key is rejected before it is checked. Send it in x-api-key.

403 Forbidden

Cause: The user who created the API key is not an active member of the organization in x-organization-id.

404 Not Found

Cause: No organization has the id in x-organization-id. This is checked before the API key.

422 Unprocessable Entity

Cause: x-organization-id is missing. The catalog is global, but the header is still required. A value that is not a UUID fails the same way, with "msg": "value is not a valid uuid".
Cause: type is not one of the values in What each type returns. The type values you read in a response (solid, mass, fiat_currency, …) are not accepted here.

Use Cases

Resolve the currency of a purchase

A purchase takes unit_id as the currency of its amount, and non_currency_unit_id as the physical unit when you track quantity instead (the units of type=non_currency_purchases). No value of the type parameter returns the currencies: request the whole catalog and match the currency’s name, which ends with its ISO code in parentheses (euros_(eur), us_dollar_(usd), british_pound_(gbp)). Currencies are the entries whose type is fiat_currency.
expense_type, product_name and purchase_date are required, and the schema rejects unknown fields — so a date key instead of purchase_date fails validation rather than being ignored.

Offer your users the units the app offers

When your own users pick a unit, request the list for the matching form (type=water, type=stationary_combustion, …) and offer those: they are the units the Dcycle app offers in the same form. This does not replace the checks of the endpoint you write to: type validates nothing, and each write endpoint decides which units it accepts.

Create Purchase

Takes the currency as unit_id and the physical unit as non_currency_unit_id

Create Invoice

Takes unit_id for the consumption in base_quantity

List LER Codes

LER code catalog: the waste_ler_code_id of a waste

List R/D Codes

Treatment code catalog: the waste_rd_code_id of a waste

List Vehicle Fuels

Fuel catalog, with the units accepted for each fuel

Create Transport Route

Takes the weight of a shipment as unit_id, one of the type=transport units