API Reference
Log In
API Reference

Import the department tree by your own department codes

Accepts multipart/form-data with a file field named 'file', an Excel workbook (.xlsx) or a CSV in UTF-8, read the same way as the department import. Header: code,name[,parent_code]. Each row is one department: code is the department's code in your own system, name its name, and parent_code the code of its parent, empty for a top-level department. Each row finds the department that has its code (its externalRef) and renames it or moves it under parent_code when they differ; the department keeps its id, admins and people, and its past spend moves with it to the new parent. When no department has the code, the row adopts a department without a code: the one with the row's name under the row's parent, else the only one with that name anywhere, and gives it the code. When none matches, the department is created with the code. parent_code may name another row or a department that already has that code. A file with any row error is rejected whole and nothing is saved: an empty code or name, a code listed twice, a parent_code that matches no row and no department, a parent_code loop or one that puts a department under its own sub-department, two departments of one name under one parent, or a name shared by several departments without a code when the row adopts by name. Nothing is deleted: with removeMissing=true, the active departments the file does not list are reported in absent and left as they are. dryRun=true reports what the file does and saves nothing. A file that renames or moves a department is applied only with the previewVersion of a dry run made against the current departments: without it the run is refused with 400, with a stale one with 409. A file that only creates departments or gives them codes applies without it. An applied file is listed in the import history as kind TREE and cannot be undone; import the earlier file again to put names and parents back.

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…
Query Params
string
required

ID of the team that owns this data.

boolean
Defaults to false

When true, reports what the file does without saving anything

boolean
Defaults to false

When true, the file is the full tree: the active departments it does not list are reported in absent. They are not changed or deleted

string

The previewVersion of the dry run this run applies. Required to apply a file that renames or moves a department. When sent, the run is refused with 409 if departments changed since that dry run

Body Params
file
required
Headers
string
enum
Defaults to application/json

Generated from available response content types

Allowed:
Responses

Language
Credentials
Header
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json
*/*