Skip to main content
POST
← Hotel Stays API Create one or many hotel stays (Scope 3 category 6). Say where each stay was, when, for how many nights and how many rooms; Dcycle applies the hotel emission factor of its country and calculates the emissions in the background. The stays are the ones /v1/hotel-stays reads and edits. The request checks every record and writes them all at once, then answers 202 Accepted with an ingest job that calculates them (see how bulk ingestion works). Follow it with GET /v2/ingest-jobs/{id} or, for a job submitted with an API key, the ingest_job.finished webhook.
Beta. Part of the bulk ingest API, in beta. The contract may still change before general availability.

How it works

  1. Every record is checked, its country included: one without a hotel emission factor (not in List Available Countries) is rejected here. If any record is invalid the whole request is rejected with 422 and nothing is written; rejected is the number of invalid records and errors lists them (up to 100).
  2. The stays are written at once, with status pending, in the x-organization-id organization. The request does not look up any address.
  3. The job calculates them in the background, in chunks. A stay sent with an address is first placed on the map (best effort: an address that cannot be found does not fail the stay). Then its emissions are calculated: rooms × nights × the hotel room-night emission factor of its country (DEFRA, or Greenview where DEFRA has none). Each stay ends active or error; its job item is failed with CALCULATION_FAILED when no emissions came out of it.
  4. When every chunk is done the job is completed (or completed_with_errors). For a job submitted with an API key, ingest_job.finished is sent to the webhook endpoints of the x-organization-id organization.

Coming from POST /v1/hotel-stays

The record is the stay v1 takes, with these differences:
  • A stay has at least one night: check_out_date is after check_in_date (v1 accepts the same day).
  • A stay cannot be in the future, neither its check-in nor its check-out.
  • A country without a hotel emission factor is rejected in the request (COUNTRY_NOT_SUPPORTED); v1 stores the stay and it ends in error when it is calculated.
  • There is no organization_id, nor any other field not listed below: the stays belong to the x-organization-id organization.
  • There is no custom emission factor, as in v1.

Request

Headers

string
required
Your API key (see Authentication).
string
required
The organization the stays belong to. A record cannot name another organization: send each organization’s stays with its own x-organization-id. The job and its ingest_job.finished webhook belong to that organization too, so register a webhook endpoint in each organization you send as.
string
required
1 to 255 characters, one per batch, looked up per organization across every v2 bulk route. Within 24 hours, the same key with the same route and body returns the original job (with Idempotent-Replayed: true) instead of creating the stays again; the same key with another body or on another route is 422 IDEMPOTENCY_KEY_REUSED, and while the first request is still being processed 409 IDEMPOTENCY_KEY_IN_PROGRESS. After 24 hours the key is free, and a request with it is a new one. See The Idempotency-Key.

Query Parameters

boolean
default:"false"
Check only: the same 422 for invalid records, nothing written, no job; 200 with {"dry_run": true, "submitted": n, "valid": n} when every record is valid. It does not check or store the Idempotency-Key.

Body Parameters

array[object]
required
The hotel stays to create, 1 to 5,000. A field not listed here is rejected (SCHEMA_INVALID).

Response

202 Accepted with the job (entity_type: hotel_stays, operation: create) and a Location header to it. To read the result:
If chunks_done stops moving, see A job that does not finish: never resend the batch with a new Idempotency-Key, because its hotel stays are already stored.

Errors

Problem details. Per-record codes in errors[].error_code of a 422 BULK_RECORDS_REJECTED: Request-level errors: 401 for a missing or invalid API key, 403 LOGGED_USER_NOT_MEMBER when the key’s user is not a member of the organization, 422 REQUEST_VALIDATION_FAILED for a malformed body (no records, more than 5,000, no Idempotency-Key), 422 IDEMPOTENCY_KEY_REUSED, 409 IDEMPOTENCY_KEY_IN_PROGRESS, and 429 beyond the rate limits.

Limits

Delete Hotel Stays (v2)

Delete stays by id

List Available Countries

The countries a stay can be in

Get Ingest Job

Follow the calculation

List Hotel Stays

The stays and their emissions