Skip to main content
POST
/
v1
/
hotel-stays
Create Hotel Stay
const options = {
  method: 'POST',
  headers: {
    'x-api-key': '<x-api-key>',
    'x-organization-id': '<x-organization-id>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    check_in_date: '<string>',
    check_out_date: '<string>',
    country: '<string>',
    name: '<string>',
    hotel_name: '<string>',
    address: '<string>',
    rooms: 123
  })
};

fetch('https://api.dcycle.io/v1/hotel-stays', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "id": "<string>",
  "organization_id": "<string>",
  "name": {},
  "check_in_date": "<string>",
  "check_out_date": "<string>",
  "country": "<string>",
  "address": {},
  "hotel_name": {},
  "rooms": 123,
  "status": "<string>",
  "source": "<string>",
  "file_id": {},
  "file_name": {},
  "co2e": {},
  "uploaded_by": {},
  "location_geocode": {},
  "created_at": {},
  "updated_at": {}
}

Create Hotel Stay

Create a new hotel stay record. CO2e is calculated asynchronously using DEFRA emission factors based on the country and number of room-nights (rooms × nights).

Request

Headers

x-api-key
string
required
Your API key for authenticationExample: sk_live_1234567890abcdef
x-organization-id
string
required
Your organization UUIDExample: a8315ef3-dd50-43f8-b7ce-d839e68d51fa

Body Parameters

check_in_date
string
required
Check-in date in ISO format (YYYY-MM-DD)
check_out_date
string
required
Check-out date in ISO format (YYYY-MM-DD). Must be on or after check_in_date.
country
string
required
ISO-2 country code (e.g. ES, GB, US). Must be a country with available emission factors — see Available Countries.
name
string
Label for the trip or traveler (max 255 characters)
hotel_name
string
Name of the hotel (max 255 characters)
address
string
Plain-text address for geocoding (max 500 characters)
rooms
integer
default:"1"
Number of booked rooms (1–10 000)

Response

Returns the created hotel stay with CO2e fields (HTTP 201). CO2e may be null initially — it is calculated asynchronously.
id
string
Hotel stay UUID
organization_id
string
UUID of the owning organization
name
string | null
Trip or traveler label
check_in_date
string
Check-in date (YYYY-MM-DD)
check_out_date
string
Check-out date (YYYY-MM-DD)
country
string
ISO-2 country code
address
string | null
Plain-text address
hotel_name
string | null
Hotel name
rooms
integer
Number of booked rooms
status
string
Record status: active, pending, or deleted
source
string
How the record was created: api, csv, or manual
file_id
string | null
UUID of the source file, if created from a file upload
file_name
string | null
Name of the source file, if created from a file upload
co2e
number | null
Calculated CO2e emissions in tCO2e. null until async calculation completes.
uploaded_by
string | null
UUID of the user who created the record
location_geocode
object | null
Geocoded location data resolved from the address
FieldTypeDescription
country_codestringISO-2 country code
place_idstringPlace identifier
address_formattedstringFull formatted address
latitudenumberLatitude coordinate
longitudenumberLongitude coordinate
created_at
datetime
Creation timestamp
updated_at
datetime | null
Last update timestamp

Example

curl -X POST "https://api.dcycle.io/v1/hotel-stays" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  -H "Content-Type: application/json" \
  -d '{
    "check_in_date": "2025-03-10",
    "check_out_date": "2025-03-13",
    "country": "ES",
    "hotel_name": "Hotel Madrid Centro",
    "name": "Spring conference",
    "rooms": 1
  }'

Successful Response

{
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "organization_id": "a8315ef3-dd50-43f8-b7ce-d839e68d51fa",
  "name": "Spring conference",
  "check_in_date": "2025-03-10",
  "check_out_date": "2025-03-13",
  "country": "ES",
  "address": null,
  "hotel_name": "Hotel Madrid Centro",
  "rooms": 1,
  "status": "active",
  "source": "api",
  "file_id": null,
  "file_name": null,
  "co2e": null,
  "created_at": "2025-03-01T12:00:00Z",
  "updated_at": null,
  "uploaded_by": null,
  "location_geocode": null
}
co2e is null immediately after creation — it is calculated asynchronously and populated within a few seconds.

Common Errors

401 Unauthorized

Cause: Missing or invalid API key
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}

403 Forbidden

Cause: The authenticated user is not a member of the organization
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}

422 Validation Error

Cause: Check-out date is before check-in date
{
  "detail": [
    {
      "loc": ["body", "check_out_date"],
      "msg": "check_out_date must be on or after check_in_date",
      "type": "value_error"
    }
  ]
}

Available Countries

Check which countries have emission factors

List Hotel Stays

Browse all hotel stay records