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
namestringrequiredThe child client's display name.
external_referencestringYour 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.
metadataobjectYour own key-value pairs, such as the ID of the customer in your own systems.
methodology_configurationobjectThe methodologies the child calculates with, as { "methodology_options": [...] }. Omit the whole object to give the child a copy of its parent's current options.
POST /v2/clients in the API referenceThis 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.jsonResponse
SQUAKE responds with 201 Created and the new client:
{
"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_configurationand 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_configurationand itsmethodology_optionsreplace the inherited options outright. Include every option the child should have. An empty array configures no methodology at all. - An empty
methodology_configurationobject, withoutmethodology_options, is rejected with400.
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
| Status | Code | Meaning |
|---|---|---|
400 | invalid_parent_client | The parent_id isn't the authenticated client or one of its descendants. |
400 | invalid_methodology_options | methodology_options isn't an array, an entry isn't an object, or an entry has no boolean default. |
401 | The API key is missing or invalid. | |
404 | The Clients API isn't enabled for your account. | |
422 | invalid_methodology_options | An 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.
Related
- Update a client
- Invite a user to the new client
- Create Child Client in the API reference