Connected Workers CSV Import
The Connected Workers CSV Import API loads CSV files into data tables, work requests, and work orders asynchronously. The table flow handles large files of up to ~200,000 rows; work requests and work orders use their normal save flow. Where the synchronous /bulk endpoint handles a payload inline, CSV import uploads the file to S3, processes it in a background job, and reports progress you poll for.
Table CSV imports use these CW entity mounts:
/v2/api/workspaces/{workspaceId}/cw/{locations|departments|users|assets|lists}/csv-import
- Locations, Departments and Users are record-native — one table per workspace — so you omit
tableKey. - Users upsert by Email, and landing a new address registers and invites that person — see the Users guide.
- Assets and Lists have many tables per workspace, so you must pass
tableKey(the target table slug).
Work request and work order imports use collection paths outside /cw. See their CSV fields and complete upload flow below.
Table CSV imports versus /bulk
| CSV Import | /bulk |
|
|---|---|---|
| Best for | Large data sets — more than a few thousand rows (up to ~200k) | Small imports up to a few thousand rows |
| Transport | File uploaded to S3, processed in the background | JSON payload processed inline |
| Response | 202 with a jobId — poll for progress |
Synchronous result in one response |
Rule of thumb: reach for CSV import once a table has more than a few thousand rows. Below that, /bulk is simpler — one call, one synchronous answer.
Table imports with a configured primary key are idempotent by primary key: re-running a CSV import upserts set-based, so a retry converges rather than duplicating.
Base URL & auth
Table CSV endpoints are scoped to a workspace and served under:
https://api.treedis.com/v2/api/workspaces/{workspaceId}/cw/{entity}/csv-import
All endpoints require authentication (OAuth2 Bearer token or API key), and the caller must have access to the workspace. workspaceId is always a numeric ID. An API key is bound to a single workspace and can only address its own.
Table CSV format
The file is a plain CSV with a header row (the default). Header names are slugified and matched to the target table's column keys — so a header PM_WKCTR maps to column key pm_wkctr, TPLNR to tplnr, and so on. Columns that don't match a header are left untouched.
If your file has no header, set hasHeader: false on the start call and the columns are taken in order.
Table upload flow
Presign — get an upload URL
POST …/csv-import/presign with the file name and optional positive byte count fileSize. When sent, the S3 PUT must use exactly that size. You get back a presigned S3 uploadUrl and the s3Key to reference later.
PUT the CSV to S3
Upload the raw CSV bytes to uploadUrl with Content-Type: text/csv. This request goes straight to S3, not through the Treedis API.
Start — enqueue the job, then poll
POST …/csv-import with the s3Key (and tableKey for assets / lists) returns 202 and a jobId. Poll GET …/csv-import/{jobId} until state is succeeded or failed.
Example: locations import (no tableKey)
1. Presign
curl -X POST "https://api.treedis.com/v2/api/workspaces/7/cw/locations/csv-import/presign" \
-H "Authorization: Bearer your-access-token" \
-H "Content-Type: application/json" \
-d '{ "fileName": "locations.csv", "fileSize": 256 }'
{
"status": 200,
"message": "Success",
"data": {
"uploadUrl": "https://s3.eu-west-1.amazonaws.com/treedis-uploads/cw-imports/7/8f3a-locations.csv?X-Amz-Signature=...",
"s3Key": "cw-imports/7/8f3a-locations.csv"
}
}
2. PUT the CSV to S3
The upload goes directly to the presigned URL — no Authorization header, Content-Type: text/csv.
curl -X PUT "<uploadUrl from step 1>" \
-H "Content-Type: text/csv" \
--data-binary @locations.csv
3. Start the job
Locations are record-native, so omit tableKey.
curl -X POST "https://api.treedis.com/v2/api/workspaces/7/cw/locations/csv-import" \
-H "Authorization: Bearer your-access-token" \
-H "Content-Type: application/json" \
-d '{ "s3Key": "cw-imports/7/8f3a-locations.csv", "hasHeader": true }'
{
"status": 200,
"message": "Success",
"timestamp": 1793544000000,
"data": { "jobId": 12345 }
}
Example: assets import (with tableKey)
Assets have many tables per workspace, so the start call requires tableKey — the slug of the target table (here assets). Presign and the S3 upload are identical to the locations flow.
# 1. presign
curl -X POST "https://api.treedis.com/v2/api/workspaces/7/cw/assets/csv-import/presign" \
-H "Authorization: Bearer your-access-token" \
-H "Content-Type: application/json" \
-d '{ "fileName": "assets.csv" }'
# 2. PUT the file to the returned uploadUrl
curl -X PUT "<uploadUrl>" \
-H "Content-Type: text/csv" \
--data-binary @assets.csv
# 3. start — tableKey is required for assets (and lists)
curl -X POST "https://api.treedis.com/v2/api/workspaces/7/cw/assets/csv-import" \
-H "Authorization: Bearer your-access-token" \
-H "Content-Type: application/json" \
-d '{ "s3Key": "cw-imports/7/8f3a-assets.csv", "tableKey": "assets", "hasHeader": true }'
Lists work exactly the same — post to …/cw/lists/csv-import with the target list's tableKey.
Polling for progress
Poll GET …/csv-import/{jobId} until state is succeeded or failed.
curl "https://api.treedis.com/v2/api/workspaces/7/cw/locations/csv-import/12345" \
-H "Authorization: Bearer your-access-token"
{
"status": 200,
"message": "Success",
"data": {
"state": "active",
"progress": 42,
"result": null
}
}
Once finished, result summarises the outcome:
{
"status": 200,
"message": "Success",
"data": {
"state": "succeeded",
"progress": 100,
"result": {
"processed": 200000,
"inserted": 180000,
"updated": 19995,
"failed": 5,
"errorReportKey": "cw-imports/7/8f3a-locations-errors.csv"
}
}
}
Poll the status endpoint on an interval — every few seconds is plenty — and stop once data.state reads succeeded or failed. data.progress (0–100) lets you show a progress bar while state is waiting or active.
Failed rows
Use GET …/csv-import/{jobId}/errors to request a signed download URL. Its data contains downloadUrl and errorReportKey; do not try to fetch a private S3 key directly. A failed job may have no row report, in which case this endpoint returns 404.
When result.failed is greater than 0, download the report, fix those rows, and re-run the table import. With a configured primary key, the retry upserts matching rows. Work request and work order retries follow the separate rules below.
Work request and work order CSV imports
Work requests and work orders use the same presign, PUT, start, and poll sequence as tables, with their collection paths outside /cw:
| Record type | CSV import base path |
|---|---|
| Work requests | /v2/api/workspaces/{workspaceId}/workRequests/csv-import |
| Work orders | /v2/api/workspaces/{workspaceId}/workOrders/csv-import |
/work-requests and /notes are work request aliases; /work-orders is a work order alias. All aliases support the CSV paths. These collections have no tableKey or table column definitions. Work requests create or edit by id; work orders are create-only. All rows use the normal save flow, including business-key anchors, workspace forms, assignments, field permissions, and location access.
Send your usual Bearer token or X-API-Key. OAuth2 requires write:cw to presign or start and read:cw to poll or download reports. The token must permit the workspace and the Work Orders section when section restrictions apply. Normal create/edit permissions apply; work order fields can also require assignment, planning, or status permissions. CSV callbacks recheck the initiating caller's permissions for each batch. API keys remain bound to their workspace.
Job status and reports are bound to the workspace, initiating user, and entity. Another caller or entity sees data.state: "missing".
These CSV endpoints require the release/1.0.1 server and microservices worker to be deployed.
For JSON batches of 1–100 records, see bulk work requests or bulk work orders. Bulk and CSV rows do not accept files, filesS3Key, or filesS3Name; attach files with the individual record endpoint.
Each collection exposes the same sequence:
| Method | Suffix | Result |
|---|---|---|
POST |
/csv-import/presign |
Upload URL and S3 key |
POST |
/csv-import |
HTTP 202 and data.jobId |
GET |
/csv-import/{jobId} |
State, progress, and counts |
GET |
/csv-import/{jobId}/errors |
Signed report download URL, when a report exists |
1. Prepare a headered CSV
Use the exact, case-sensitive API field names. Work item headers are not slugified. Work requests need a location header; work orders need a title header. Each row must also meet the normal record and form requirements. Headerless CSV files are not supported.
Work requests:
location,title,description,customFields
FL-1001,Pump leak,Check seal,"{""fault"":""seal""}"
FL-1001,Loose guard,Check fasteners,
Work orders:
title,location,startDate,dueDate
Replace seal,FL-1001,2026-11-02T08:00:00Z,2026-11-02T16:00:00Z
Tighten guard,FL-1001,2026-11-02T08:00:00Z,2026-11-02T16:00:00Z
- Blank cells omit optional fields. Business keys stay strings, so leading zeros survive.
id,assigneeUserId,teamId,reporterId,formTemplateId,parentWorkOrderId, andestimatedDurationMinutesare parsed as positive integers when present.customFields,customFieldValues,activities,checklists,adHocTasks,assigneeUserIds, andcustomDatesare parsed as JSON cells. Quote and escape them according to CSV rules.isMainMessageandtooltipaccepttrueorfalse. Dates use ISO 8601 strings.- Duplicate headers, malformed CSV, and a missing required header fail the job. Invalid typed cells or rejected saves count as row failures.
- A CSV record is limited to 1 MiB; the upload is limited to 1 GiB. The worker streams rows and continues long imports under the original job id.
2. Presign
curl -X POST "https://api.treedis.com/v2/api/workspaces/7/workRequests/csv-import/presign" \
-H "Authorization: Bearer your-access-token" \
-H "Content-Type: application/json" \
-d '{ "fileName": "requests.csv", "fileSize": 256 }'
fileName must end in .csv. fileSize is optional; when provided, send the actual positive integer byte count. The returned S3 PUT is bound to that size.
Read data.uploadUrl and data.s3Key from the response. The server places the upload under cw-imports/{workspaceId}/.
3. Upload directly to S3
curl -X PUT "<data.uploadUrl>" \
-H "Content-Type: text/csv" \
--data-binary @requests.csv
Send the raw bytes to the returned URL. Do not add your Treedis Authorization header to this S3 request.
4. Start the job
curl -X POST "https://api.treedis.com/v2/api/workspaces/7/workRequests/csv-import" \
-H "Authorization: Bearer your-access-token" \
-H "Content-Type: application/json" \
-d '{ "s3Key": "cw-imports/7/<returned-file-name>.csv" }'
Use the exact key returned by presign. A key outside this workspace is rejected. Do not send tableKey. hasHeader may be omitted or true; false is rejected.
HTTP 202 returns the standard envelope with data: { "jobId": 12345 }.
For work orders, replace workRequests with workOrders in all four URLs.
5. Poll and inspect the result
curl "https://api.treedis.com/v2/api/workspaces/7/workRequests/csv-import/12345" \
-H "Authorization: Bearer your-access-token"
Poll every few seconds until data.state is succeeded or failed. waiting and active are nonterminal; missing means the job is unavailable to this caller, belongs to another target, or expired.
A finished job's data looks like this:
{
"state": "succeeded",
"progress": 100,
"result": {
"processed": 3,
"inserted": 2,
"updated": 0,
"failed": 1,
"errorReportKey": "cw-imports/7/errors/work-12345.csv",
"errorReportKeys": ["cw-imports/7/errors/work-12345.csv"]
}
}
state: "succeeded" means processing finished; check result.failed for rejected rows. inserted counts new records; updated counts existing work requests edited by id. Work orders are create-only. Counts cover all continuation segments. While a continuation is running, keep polling the original id. Job status is retained for 24 hours; an unused callback capability expires after 24 hours.
For each available report, get a short-lived signed download URL:
curl "https://api.treedis.com/v2/api/workspaces/7/workRequests/csv-import/12345/errors" \
-H "Authorization: Bearer your-access-token"
The response contains data.downloadUrl and data.errorReportKey. For jobs with several continuation reports, add ?reportIndex=1, ?reportIndex=2, and so on to select another report from result.errorReportKeys. Index zero is the default. Each report contains the original cells plus _error, capped at 10,000 failed rows per segment. HTTP 404 means no report is available for the selected index.
A failed job can have already saved rows. Inspect the result and saved records before resubmitting a create file. CSV work item imports are not primary-key upserts like table CSV imports.
Table import errors
Errors use the same envelope with success: false and an optional details object:
{
"success": false,
"code": 400,
"message": "tableKey is required for assets imports",
"details": {
"error": "Assets have multiple tables per workspace — provide the target table slug"
}
}
| Status | When |
|---|---|
400 |
Missing s3Key, missing tableKey for assets / lists, or an unreadable / malformed file |
404 |
Job id not found (on the status endpoint) |
See the Connected Workers tags in the API Reference for the full request and response schemas.

