Update a client
Change a client's name, reference, metadata or methodologies. Methodology changes recalculate stored travel data.
Updates the editable fields of a client in your hierarchy: name, external_reference, metadata and methodology_configuration. Fields you don't send keep their current values.
The Clients API must be enabled for your account. Until it is, this endpoint responds with 404.
Request
PATCH /v2/clients/{id}
idstring (UUID)requiredThe client's ID, in the path.
namestringThe new display name.
external_referencestringYour new reference for the client, unique among the children of its parent.
metadataobjectYour own key-value pairs.
methodology_configurationobjectThe new methodology configuration, as { "methodology_options": [...] }. Replaces all current options. Omit it to keep the current configuration.
PATCH /v2/clients/{id} in the API referenceThis request renames the client and switches its hotel methodology from Greenview to HCMI. It sends every option the client keeps, because methodology_options replaces the full list:
{
"name": "Example Travel Deutschland",
"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": "HCMI", "version": "AT_TIME_OF_TRAVEL", "default": true }
]
}
}Save it as client-update.json and send it:
curl --request PATCH "https://api.sandbox.squake.earth/v2/clients/4fb3ec7a-92cb-471f-b75f-c3fe7c2a34d5" \
--header "Authorization: Bearer $SQUAKE_API_KEY" \
--header "Content-Type: application/json" \
--data @client-update.jsonResponse
{
"id": "4fb3ec7a-92cb-471f-b75f-c3fe7c2a34d5",
"name": "Example Travel Deutschland",
"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": "HCMI", "version": "AT_TIME_OF_TRAVEL", "default": true }
]
}Changing methodologies
methodology_optionsreplaces the client's options in full. Send every option the client should keep, not only the ones that change. An empty array clears all options.- When the new list differs from the current one, SQUAKE recalculates the activities already stored for the client with the new methodologies. The recalculation runs in the background, and the response returns as soon as the configuration is written.
- The update is atomic. If the options are invalid, SQUAKE writes nothing, including the other fields in the same request.
Changing the parent
Moving a client to another parent isn't supported. A parent_id that would move the client, including null, is rejected with 400 and error code parent_id_immutable. Sending the client's current parent_id is accepted and ignored, so you can read a client, change a field and send the whole object back.
Errors
| Status | Code | Meaning |
|---|---|---|
400 | parent_id_immutable | The parent_id would move the client to another parent. |
400 | invalid_methodology_options | methodology_options can't be read as a list of options. |
401 | The API key is missing or invalid. | |
404 | client_not_found | No client has this ID, or the client is outside your hierarchy. |
422 | invalid_methodology_options | The options break a rule. See Methodology options. |
Related
- Retrieve a client
- Update a Client in the API reference