Skip to main content
GET
List Units (Legacy)
Legacy API. This page documents the previous version of the API. For new integrations use List Units (GET /v2/units) instead: it does not need x-user-id, and its type parameter returns the units the Dcycle app offers in each form.
Retrieve the measurement units available in Dcycle. Their ids are what you send as unit_id when you create invoices, purchases and other consumption records.
Units are reference data maintained by Dcycle. You cannot create or modify units through the API - this endpoint is read-only.

Request

Headers

string
required
Your API key. You can send it as Authorization: Bearer <key> instead, as the examples below do. It must be an active key of the organization in x-organization-id.Format: Your API key string
string
required
Your organization UUIDFormat: UUID
string
required
UUID of a user with an active membership in that organizationFormat: UUID

Query Parameters

string
Return only the units whose stored type is exactly this value. It is free text, not a list of options: a value no unit has returns 200 with an empty array, not an error. Omit it to get the whole catalog.The stored type is a legacy classification, and it is not consistent: kilogram_(kg) is solid, cubic_metre_(m3) and kilometer_(km) are gas, and imperial_gallon_(gal_imp) is mass. Values in use include fiat_currency, mass, energy, volume, ghgemissions, gas, liquid, solid, time, area and several waste_water_treatment_* values. The filter is dependable for fiat_currency, which returns the currencies; for physical units, pick them by exact name from the whole catalog instead.Example: fiat_currency

Response

Returns an array of unit objects, not paginated. Without type it is ordered by name; with type the order is not guaranteed.
array
Array of unit objects

Unit Object Fields:

string
Unit id (UUID). This is the value to send as unit_id.
string
Unit name, in snake_case with its symbol or ISO code in parentheses: kilowatt_hour_(kwh), litre_(l), euros_(eur)
string
Legacy classification stored with the unit (see the type parameter above)

Example

Successful Response

Returns 200 OK with the unit array. An excerpt of ?type=fiat_currency:
A type that no unit has, such as ?type=kWh, also returns 200 OK:

Common Errors

The authentication errors of this endpoint have a bare JSON string as body, not an object. They are checked in this order: organization, user, membership, and finally the API key.

401 Unauthorized

Cause: No API key was sent, or the key is not an active key of the organization in x-organization-id.

403 Forbidden

Cause: No organization has the id in x-organization-id.
Cause: No user has the id in x-user-id.
Cause: The user in x-user-id has no active membership in the organization.

422 Unprocessable Entity

Cause: x-organization-id or x-user-id is missing.

Use Cases

Find a Unit by Exact Name

Request the whole catalog and index it by name. Compare exact names, never a prefix: many names start with kilogram (kilogram_(kg), kilogram_(kg) material, kilograms_co2_(kg_co2), …).
A few names belong to two units (kilogram_day_(kg_day) is one). For those, the dictionary keeps only one of them, so use the id.

Store Unit IDs in Configuration

Unit ids do not change, so you can keep the ones you use in your configuration instead of requesting the catalog on every run:

List Units

Current API: no x-user-id, and the units the app offers in each form

Create Invoice

Create invoices using unit IDs

List Suppliers

Get suppliers for invoices

Authentication

Learn about API authentication