ErgOpsDocs

API reference

Reference for the ErgOps Embedded API v1, generated from the authoritative OpenAPI specification.

New to the API? Start with Send your first API calculation, then read Create and manage API keys, Idempotency and Error handling.

Base URL#

https://api.ergops.com/v1

Test and Live are selected by the API key, not by the hostname. The API is server-to-server; browser cross-origin requests are not enabled.

Authentication#

Send your API key as an HTTP bearer token: Authorization: Bearer <API key>. Key format: ergops_test_* or ergops_live_*. See Authentication and API keys.

POST /emissions/logistics#

Calculate customer-attributed logistics emissions

Creates or replays a customer-attributed logistics calculation. The result is never automatically added to the caller's own corporate inventory — see inventory_attribution on the response. 403 USAGE_LIMIT_REACHED means the effective contract period's included capacity is exhausted; it is a commercial limit, not a request-rate limit, and retrying immediately will not help. A duplicate external_reference within the same organization and environment returns 409 EXTERNAL_REFERENCE_CONFLICT, which is distinct from reusing Idempotency-Key with a different payload (409 IDEMPOTENCY_KEY_REUSED).
Authentication
API key (Bearer)
Required scope
emissions:calculate
Operation ID
calculateLogisticsEmissions

Parameters#

NameInTypeRequiredDescription
Idempotency-KeyheaderstringYesStable retry key for one logical write. Reuse with a different material payload returns 409. Distinct from external_reference: this key identifies one retry attempt, while external_reference identifies the shipment in your own business system and is unique per organization and environment. Completed idempotency records are retained for at least 30 days. At least 1 characters. Up to 200 characters.

Request body#

application/json · LogisticsRequest

FieldTypeRequiredDescription
customer_referencestringYesUp to 120 characters.
external_referencestringYesUp to 120 characters.
modestringYesOne of: ROAD, SEA, AIR.
originPlaceYesProvide at least one of: code or label. Unknown fields are rejected.
origin.codestringNoUp to 20 characters.
origin.labelstringNoUp to 200 characters.
origin.countrystringNoExactly 2 characters.
destinationPlaceYesProvide at least one of: code or label. Unknown fields are rejected.
destination.codestringNoUp to 20 characters.
destination.labelstringNoUp to 200 characters.
destination.countrystringNoExactly 2 characters.
cargoobjectYesUnknown fields are rejected.
cargo.valuenumberYesGreater than 0.
cargo.unitstringYesAlways tonne.
distanceobjectYesUnknown fields are rejected.
distance.valuenumberYesGreater than 0.
distance.unitstringYesAlways km.
activity_datestring (date)Yes
business_contextstringNoOne of: upstream, downstream. Default upstream.
factor_referencestringYesExisting governed factor key; direct factor values are not accepted.

Example request#

curl -X POST "https://api.ergops.com/v1/emissions/logistics" \
  -H "Authorization: Bearer $ERGOPS_API_KEY" \
  -H "Idempotency-Key: YOUR_IDEMPOTENCY_KEY" \
  -H "Content-Type: application/json" \
  -d '{"customer_reference":"CUSTOMER_REFERENCE","external_reference":"EXTERNAL_REFERENCE","mode":"ROAD","origin":{"code":"CODE","label":"LABEL","country":"GB"},"destination":{"code":"CODE","label":"LABEL","country":"GB"},"cargo":{"value":1,"unit":"tonne"},"distance":{"value":1,"unit":"km"},"activity_date":"2026-01-31","factor_reference":"FACTOR_REFERENCE"}'

Responses#

StatusMeaningBody
200The same logical calculation was replayed idempotently
Headers: X-Request-Id, Idempotent-Replayed
—
201A new canonical calculation was created
Headers: X-Request-Id
Calculation
400Malformed request — for example invalid path-parameter encodingError
401InvalidError
403Scope, entitlement or lifecycle denied (`INSUFFICIENT_SCOPE`, `FEATURE_NOT_ENTITLED`, `ORGANIZATION_NOT_ACTIVE`), or the effective contract period's included calculation capacity is exhausted (`USAGE_LIMIT_REACHED`). `USAGE_LIMIT_REACHED` is a commercial limit set by your contract, not a request-rate limit — see `429` for that. Retrying immediately will not succeed; capacity is restored by a new period or a contract amendment.Error
404Tenant-safe not foundError
409`IDEMPOTENCY_KEY_REUSED` — the same `Idempotency-Key` was sent with a materially different request, or the original request with that key is still being processed. `EXTERNAL_REFERENCE_CONFLICT` — `external_reference` already identifies a different calculation in this organization and environment; each `external_reference` may resolve to only one calculation.Error
422ValidationError
429Technical request-rate limit exceeded (`RATE_LIMITED`) — this protects throughput and is unrelated to commercial contract capacity. Retrying after the `Retry-After` interval will normally succeed.
Headers: Retry-After
Error
500An internal service error occurred (`INTERNAL_ERROR`) — for example the rate-limiting infrastructure was temporarily unavailable. Safe to retry; no infrastructure or database detail is included in the response.Error
201 response fields · Calculation
FieldTypeRequiredDescription
idstring (uuid)Yes
external_referencestringYes
statusstringYesAlways succeeded.
environmentstringYesOne of: test, live.
customerobjectYes
customer.referencestringYes
activityobjectYes
activity.valuenumberYes
activity.unitstringYesAlways tkm.
emissionsobjectYes
emissions.valuenumberYes
emissions.unitstringYesAlways kgCO2e.
methodologyobjectYes
factorobjectYes
inventory_attributionstringYesnone (the default) means this calculation is attributed only to the named customer and is not part of your own corporate emissions inventory. explicit means someone with sustainability write access deliberately added it to your corporate inventory; that step is manual, reuses this same calculation, and never creates a second billable unit. One of: none, explicit.
corporate_record_idstring | null (uuid)NoPresent only once inventory_attribution is explicit. An opaque reference to the corporate inventory record this calculation was added to.
created_atstring (date-time)Yes

Example shape, generated from the schema:

{
  "id": "00000000-0000-4000-8000-000000000000",
  "external_reference": "EXTERNAL_REFERENCE",
  "status": "succeeded",
  "environment": "test",
  "customer": {
    "reference": "REFERENCE"
  },
  "activity": {
    "value": 0,
    "unit": "tkm"
  },
  "emissions": {
    "value": 0,
    "unit": "kgCO2e"
  },
  "methodology": {},
  "factor": {},
  "inventory_attribution": "none",
  "created_at": "2026-01-31T12:00:00Z"
}

GET /calculations/{id}#

Read a calculation from the credential's organization and environment

Authentication
API key (Bearer)
Required scope
emissions:read or emissions:calculate
Operation ID
getCalculation

Parameters#

NameInTypeRequiredDescription
idpathstring (uuid)Yes

Example request#

curl "https://api.ergops.com/v1/calculations/CALCULATION_ID" \
  -H "Authorization: Bearer $ERGOPS_API_KEY"

Responses#

StatusMeaningBody
200CalculationCalculation
401InvalidError
403Scope, entitlement or lifecycle denied (`INSUFFICIENT_SCOPE`, `FEATURE_NOT_ENTITLED`, `ORGANIZATION_NOT_ACTIVE`), or the effective contract period's included calculation capacity is exhausted (`USAGE_LIMIT_REACHED`). `USAGE_LIMIT_REACHED` is a commercial limit set by your contract, not a request-rate limit — see `429` for that. Retrying immediately will not succeed; capacity is restored by a new period or a contract amendment.Error
404Tenant-safe not foundError
429Technical request-rate limit exceeded (`RATE_LIMITED`) — this protects throughput and is unrelated to commercial contract capacity. Retrying after the `Retry-After` interval will normally succeed.
Headers: Retry-After
Error
500An internal service error occurred (`INTERNAL_ERROR`) — for example the rate-limiting infrastructure was temporarily unavailable. Safe to retry; no infrastructure or database detail is included in the response.Error
200 response fields · Calculation
FieldTypeRequiredDescription
idstring (uuid)Yes
external_referencestringYes
statusstringYesAlways succeeded.
environmentstringYesOne of: test, live.
customerobjectYes
customer.referencestringYes
activityobjectYes
activity.valuenumberYes
activity.unitstringYesAlways tkm.
emissionsobjectYes
emissions.valuenumberYes
emissions.unitstringYesAlways kgCO2e.
methodologyobjectYes
factorobjectYes
inventory_attributionstringYesnone (the default) means this calculation is attributed only to the named customer and is not part of your own corporate emissions inventory. explicit means someone with sustainability write access deliberately added it to your corporate inventory; that step is manual, reuses this same calculation, and never creates a second billable unit. One of: none, explicit.
corporate_record_idstring | null (uuid)NoPresent only once inventory_attribution is explicit. An opaque reference to the corporate inventory record this calculation was added to.
created_atstring (date-time)Yes

Example shape, generated from the schema:

{
  "id": "00000000-0000-4000-8000-000000000000",
  "external_reference": "EXTERNAL_REFERENCE",
  "status": "succeeded",
  "environment": "test",
  "customer": {
    "reference": "REFERENCE"
  },
  "activity": {
    "value": 0,
    "unit": "tkm"
  },
  "emissions": {
    "value": 0,
    "unit": "kgCO2e"
  },
  "methodology": {},
  "factor": {},
  "inventory_attribution": "none",
  "created_at": "2026-01-31T12:00:00Z"
}

GET /customers/{customerReference}#

Read a customer using its organization-scoped external reference

Authentication
API key (Bearer)
Required scope
customers:read
Operation ID
getCustomer

Parameters#

NameInTypeRequiredDescription
customerReferencepathstringYesUp to 120 characters. Pattern ^[A-Za-z0-9][A-Za-z0-9._:/-]*$.

Example request#

curl "https://api.ergops.com/v1/customers/CUSTOMER_REFERENCE" \
  -H "Authorization: Bearer $ERGOPS_API_KEY"

Responses#

StatusMeaningBody
200Customer-safe metadataCustomer
401InvalidError
403Scope, entitlement or lifecycle denied (`INSUFFICIENT_SCOPE`, `FEATURE_NOT_ENTITLED`, `ORGANIZATION_NOT_ACTIVE`), or the effective contract period's included calculation capacity is exhausted (`USAGE_LIMIT_REACHED`). `USAGE_LIMIT_REACHED` is a commercial limit set by your contract, not a request-rate limit — see `429` for that. Retrying immediately will not succeed; capacity is restored by a new period or a contract amendment.Error
404Tenant-safe not foundError
429Technical request-rate limit exceeded (`RATE_LIMITED`) — this protects throughput and is unrelated to commercial contract capacity. Retrying after the `Retry-After` interval will normally succeed.
Headers: Retry-After
Error
500An internal service error occurred (`INTERNAL_ERROR`) — for example the rate-limiting infrastructure was temporarily unavailable. Safe to retry; no infrastructure or database detail is included in the response.Error
200 response fields · Customer
FieldTypeRequiredDescription
referencestringYes
namestringYes
statusstringYes
country_codestring | nullNo
analyticsobject | nullNo

Example shape, generated from the schema:

{
  "reference": "REFERENCE",
  "name": "NAME",
  "status": "STATUS"
}

GET /customers/{customerReference}/emissions#

Read environment-isolated customer calculation aggregates

Authentication
API key (Bearer)
Required scope
customers:read + customer-analytics:read
Operation ID
getCustomerEmissions

Parameters#

NameInTypeRequiredDescription
customerReferencepathstringYesUp to 120 characters. Pattern ^[A-Za-z0-9][A-Za-z0-9._:/-]*$.

Example request#

curl "https://api.ergops.com/v1/customers/CUSTOMER_REFERENCE/emissions" \
  -H "Authorization: Bearer $ERGOPS_API_KEY"

Responses#

StatusMeaningBody
200Customer analyticsCustomer
401InvalidError
403Scope, entitlement or lifecycle denied (`INSUFFICIENT_SCOPE`, `FEATURE_NOT_ENTITLED`, `ORGANIZATION_NOT_ACTIVE`), or the effective contract period's included calculation capacity is exhausted (`USAGE_LIMIT_REACHED`). `USAGE_LIMIT_REACHED` is a commercial limit set by your contract, not a request-rate limit — see `429` for that. Retrying immediately will not succeed; capacity is restored by a new period or a contract amendment.Error
404Tenant-safe not foundError
429Technical request-rate limit exceeded (`RATE_LIMITED`) — this protects throughput and is unrelated to commercial contract capacity. Retrying after the `Retry-After` interval will normally succeed.
Headers: Retry-After
Error
500An internal service error occurred (`INTERNAL_ERROR`) — for example the rate-limiting infrastructure was temporarily unavailable. Safe to retry; no infrastructure or database detail is included in the response.Error
200 response fields · Customer
FieldTypeRequiredDescription
referencestringYes
namestringYes
statusstringYes
country_codestring | nullNo
analyticsobject | nullNo

Example shape, generated from the schema:

{
  "reference": "REFERENCE",
  "name": "NAME",
  "status": "STATUS"
}

POST Webhook: calculationEvent#

Signed calculation lifecycle event delivered to a configured endpoint

ErgOps sends this request to your endpoint. Verify it before processing — see Verify webhook signatures.

Headers#

HeaderTypeDescription
X-ErgOps-Webhook-Idstring (uuid)
X-ErgOps-Webhook-Timestampstring
X-ErgOps-Webhook-SignaturestringPattern ^v1=[a-f0-9]{64}(,v1=[a-f0-9]{64})*$.

Body#

FieldTypeRequiredDescription
idstring (uuid)Yes
typestringYesOne of: calculation.succeeded, calculation.failed.
created_atstring (date-time)Yes
environmentstringYesOne of: test, live.
dataobjectYesCustomer-safe calculation result or stable error reference.

Errors#

Every error uses the same envelope. Always log request_id when contacting support.

{
  "error": {
    "code": "INVALID_API_KEY",
    "message": "MESSAGE",
    "request_id": "00000000-0000-4000-8000-000000000000"
  }
}

Error codes defined in the contract:

  • INVALID_API_KEY
  • API_KEY_REVOKED
  • API_KEY_EXPIRED
  • INSUFFICIENT_SCOPE
  • FEATURE_NOT_ENTITLED
  • ORGANIZATION_NOT_ACTIVE
  • CUSTOMER_NOT_FOUND
  • CUSTOMER_ACCESS_DENIED
  • INVALID_REQUEST
  • IDEMPOTENCY_KEY_REQUIRED
  • IDEMPOTENCY_KEY_REUSED
  • EXTERNAL_REFERENCE_CONFLICT
  • FACTOR_NOT_FOUND
  • CALCULATION_FAILED
  • USAGE_LIMIT_REACHED
  • RATE_LIMITED
  • INTERNAL_ERROR

See Error handling for guidance.

Download the specification#

openapi.yaml (OpenAPI 3.1.0) is the authoritative contract. Use it to generate clients or import into API tools.