Create Travel Data Items

Changed Nov 2
POST
/v2/travel-data

Accepts trip records with nested activities for travel data ingestion.

Request size limit: A single request may contain a maximum of 50 activities in total across all trips. For larger data sets, split your payload into batches of up to 50 activities and send each batch as a separate request. Requests exceeding this limit are rejected with a 400 error before any data is persisted.

If an activity omits methodology, SQUAKE selects the client's configured default methodology for that activity type. Pass methodology only when you want to override that default for a specific activity. Supported activity types: car, flight, hotel, and train.

Monetary values: Both trips and individual activities accept amount_in_cents and currency. Use activity-level values to attribute spend to a specific leg; they take precedence over trip-level values in activity-based reporting. When currency is present, amount_in_cents must be a positive integer. The API does not accept amount_base_currency.

Reading the data back: alongside the flat items array, the response returns a trips array with the ID of every trip this request persisted and the IDs of the activities written under it. Store those IDs to read, or delete, the stored records later via /v2/travel-data/trips — or address a trip by your own trip_reference instead. A trips entry reports the trip's identity only; a trip read returns those same fields plus the trip as you described it (name, purpose, status, dates, booking provider, amount, cost center).

On behalf of another client: pass an optional root-level client_id (a client id as returned by /v2/clients) to store this travel data under a descendant client. Submitting data for another client must be enabled for your account (contact us); omitting client_id preserves the existing behavior of ingesting for the authenticated client. Note that CSV imports (/v2/travel-data/imports) do not accept client_id.

Flight routing: flight activities accept the same methodology-specific fields as the corresponding /v2/calculations flight schemas, including routing for multi-leg itineraries (a hyphen-separated airport chain, e.g. BER-FRA-JFK) as an alternative to origin/destination. Exactly one of routing or the origin/destination pair must be provided; routing only applies to flight activities.

Authorization

Bearer-Auth
headerAuthorizationBearer <token>

Request Body

application/json
  1. body
client_id?string

Optional. Submit this travel data on behalf of a descendant client — pass the target client's id (a UUID as returned by /v2/clients). Omit it to ingest for the authenticated client (the default, unchanged behavior). Providing client_id requires this capability to be enabled for your account (contact us); an id outside your hierarchy returns client_not_found (404) and nothing is persisted. All trips in one request are owned by the same target client.

Formatuuid
trips?array<>

Response Body

OK

application/json
  1. response
carbon_quantity*number

Total carbon quantity aggregated across all items

carbon_unit*Carbon Unit

SQUAKE uses The International System of Units (SI), commonly referred to as "metric system".

Value in"tonne""kilogram""gram"
items?array<>
trips*array<>

The trips this request persisted, with the IDs of the activities it wrote under each one. Use these IDs to read the stored data back from the trip endpoints — including the calculations of any additional methodologies, which items does not report.

One entry per trip: two payload entries sharing a trip_reference resolve to a single trip and are reported once. activity_ids lists only the activities this request persisted, so a re-used trip holds more than the response shows.

Each entry carries the trip's identity, not the descriptive fields the request sent — reading the trip back returns those on top of these (Travel-Data-Stored-Trip).

curl -X POST 'https://api.sandbox.squake.earth/v2/travel-data' \  -H 'Content-Type: application/json' \  -d '{  "trips": [    {      "amount_in_cents": 10000,      "currency": "USD",      "trip_name": "Business Trip to NYC",      "trip_purpose": "Client Meeting",      "trip_reference": "BT-2023-001",      "trip_status": "completed",      "start_date_utc": "2023-10-01",      "end_date_utc": "2023-10-05",      "booking_provider": "Test Provider",      "activities": [        {          "type": "car",          "amount_in_cents": 2500,          "currency": "EUR",          "origin": "BER",          "destination": "MUC",          "fuel_type": "diesel",          "traveler": {            "name": "Mustermann",            "email": "test@company.io",            "traveler_type": "employee"          }        }      ],      "cost_center": {        "name": "Marketing",        "purpose": "Marketing Campaign",        "email": "cc@company.io"      }    }  ]}'
Example Response
{  "carbon_quantity": 0,  "carbon_unit": "tonne",  "items": [    {      "carbon_quantity": 0,      "carbon_unit": "tonne",      "external_reference": "string",      "trip_reference": "string",      "type": "air_freight",      "methodology": {        "errors": [          [            {              "code": "field_validation_error",              "detail": "string",              "source": {                "id": "string",                "attribute": "string",                "model": "string"              }            }          ]        ],        "carbon": {          "quantity": 0,          "unit": "tonne"        },        "distance": {          "distance": 0,          "unit": "kilometer"        },        "original_distance": {          "distance": 0,          "unit": "kilometer"        },        "emission_factors": {          "co2_per_km_grams": 0,          "energy_scope": "ttw"        },        "meta": {}      },      "distance": 0,      "distance_unit": "kilometer"    }  ],  "trips": [    {      "id": "0194d6b4-8711-7873-899d-c8133cd742f8",      "trip_reference": "BT-2023-001",      "client_id": "4fb3ec7a-92cb-471f-b75f-c3fe7c2a34d5",      "submitted_by_client_id": "4fb3ec7a-92cb-471f-b75f-c3fe7c2a34d5",      "activity_ids": [        "6c1f6a5e-1d0e-4b8a-9f2c-2b1e6d4a7c31",        "b9a2c47d-3f61-4d0e-8f52-7c9a1e2b4d68"      ]    }  ]}

List Travel Data Trips

Returns the trips stored for the authenticated client, most recently ingested first. Trips from every source are listed — API submissions, CSV imports and TMC integrations alike. Each trip is returned in full: the identity fields a submission echoes back (`id`, `trip_reference`, `client_id`, `submitted_by_client_id`, `activity_ids`) plus the trip as you described it on ingestion — `trip_name`, `trip_purpose`, `trip_status`, `start_date_utc`, `end_date_utc`, `booking_provider`, `amount_in_cents`, `currency` and the nested `cost_center`. What a trip does *not* carry is its activities: only their IDs. Read an activity, its traveler, its calculations and its audit references from [`/v2/travel-data/trips/{trip_id}/activities`](https://docs.squake.earth/reference/squake/travel-data/get-v2-travel-data-trips-trip-id-activities). **Pagination:** results are paginated with the `page` and `items` query parameters, and the pagination metadata is returned in the response headers (`Current-Page`, `Page-Items`, `Total-Pages`, `Total-Count`, and an RFC 8288 `Link` header). **Multi-client:** if submitting on behalf of other clients is enabled for your account, this lists the trips of the authenticated client and all of its descendants. Otherwise only your own trips are returned — never a parent's, a sibling's, or an unrelated client's. A client with no stored trips gets an empty array.

Delete a Client

Soft-deletes a descendant client and removes it from the client hierarchy. Only leaf clients can be deleted. If the client still has children, this endpoint returns `client_has_children` (`422`); delete its descendants first, from the bottom of the hierarchy upwards. The authenticated client cannot delete itself. The authenticated client, an unknown or already deleted client, and a client outside your hierarchy all return `client_not_found` (`404`). Requires this feature to be enabled for your account (contact us); otherwise this endpoint responds with `404`.