Create a child client

Create a client below your own for travel data ingestion, optionally with its own methodologies.

Creates a child client under the authenticated client, or under one of its descendants when you pass parent_id. The child exists for travel data ingestion: it inherits its address, tax, currency and methodology defaults from its parent, and it has no credentials, no billing or purchasing, and no access to products or projects. See Clients.

The Clients API must be enabled for your account. Until it is, this endpoint responds with 404.

Request

POST /v2/clients

namestringrequired

The child client's display name.

external_referencestring

Your own reference for the client. It must be unique among the children of the same parent. SQUAKE generates one from the name when you omit it.

parent_idstring (UUID)

The parent to create the child under. Defaults to the authenticated client. It must be the authenticated client or one of its descendants.

metadataobject

Your own key-value pairs, such as the ID of the customer in your own systems.

methodology_configurationobject

The methodologies the child calculates with, as { "methodology_options": [...] }. Omit the whole object to give the child a copy of its parent's current options.

See every field of POST /v2/clients in the API reference

This request creates a child that calculates trains with REM instead of its parent's DEFRA default:

{
  "name": "Example Travel Germany",
  "external_reference": "example-de",
  "metadata": { "crm_id": "ACC-1042" },
  "methodology_configuration": {
    "methodology_options": [
      { "activity_type": "flight", "methodology": "TIM", "version": "AT_TIME_OF_TRAVEL", "default": true },
      { "activity_type": "flight", "methodology": "DEFRA", "version": "AT_TIME_OF_TRAVEL", "default": false },
      { "activity_type": "train", "methodology": "REM", "default": true },
      { "activity_type": "car", "methodology": "DEFRA", "version": "AT_TIME_OF_TRAVEL", "default": true },
      { "activity_type": "hotel", "methodology": "GREENVIEW", "version": "AT_TIME_OF_TRAVEL", "default": true }
    ]
  }
}

Save it as client.json and send it:

curl --request POST "https://api.sandbox.squake.earth/v2/clients" \
  --header "Authorization: Bearer $SQUAKE_API_KEY" \
  --header "Content-Type: application/json" \
  --data @client.json

Response

SQUAKE responds with 201 Created and the new client:

201 Createdapplication/json
{
  "id": "4fb3ec7a-92cb-471f-b75f-c3fe7c2a34d5",
  "name": "Example Travel Germany",
  "external_reference": "example-de",
  "parent_id": "0f1f3d3b-2775-4cc0-885e-8d51db6d6de1",
  "status": "active",
  "metadata": { "crm_id": "ACC-1042" },
  "methodology_options": [
    { "activity_type": "flight", "methodology": "TIM", "version": "AT_TIME_OF_TRAVEL", "default": true },
    { "activity_type": "flight", "methodology": "DEFRA", "version": "AT_TIME_OF_TRAVEL", "default": false },
    { "activity_type": "train", "methodology": "REM", "version": null, "default": true },
    { "activity_type": "car", "methodology": "DEFRA", "version": "AT_TIME_OF_TRAVEL", "default": true },
    { "activity_type": "hotel", "methodology": "GREENVIEW", "version": "AT_TIME_OF_TRAVEL", "default": true }
  ]
}

The REM option comes back with version: null, because the request didn't set a version. The child is usable on the next request: pass its id as client_id to POST /v2/travel-data to submit travel data for it.

Methodology configuration

  • Omit methodology_configuration and the child gets a copy of its parent's current options. It's a copy, not a link: later changes to the parent never reach the child.
  • Send methodology_configuration and its methodology_options replace the inherited options outright. Include every option the child should have. An empty array configures no methodology at all.
  • An empty methodology_configuration object, without methodology_options, is rejected with 400.

Every option must follow the rules in Methodology options: at most three options per activity type, exactly one default: true per activity type, and a methodology that's available for the type.

Errors

StatusCodeMeaning
400invalid_parent_clientThe parent_id isn't the authenticated client or one of its descendants.
400invalid_methodology_optionsmethodology_options isn't an array, an entry isn't an object, or an entry has no boolean default.
401The API key is missing or invalid.
404The Clients API isn't enabled for your account.
422invalid_methodology_optionsAn option has an unknown activity_type or methodology, an activity type has two defaults, or an activity type has more than three options.

If the request fails, SQUAKE creates no client.

On this page

POST/v2/clients

Run this request against the sandbox with your test key.

Open in API reference