Skip to main content

Jobs

Long-running work runs as a job. A 202 Accepted response contains the job and a Location header with its URL:
Request GET /jobs/{jobId} until status is succeeded or failed. A failed job has an error with a fixed code and a message, for example: Poll calmly, for example every 2 to 5 seconds: every poll counts towards the rate limit.

Importing

POST /imports takes multipart/form-data with files[]: JSON, PHP, PO, MO, CSV, XLSX, XLIFF or a zip of these (at most 50 MB). Tolk detects the format, language and namespace from each path, just like the import dialog, and imports without a preview.
An unsafe or unreadable file returns a 422 on files.N, and nothing is saved. The number of lines is only known once the files have been read: an import that is too large therefore first returns 202 and then a failed job with too_many_lines, without anything being written. A CSV or XLSX file needs a column mapping saved as a preset in Tolk; without one, the job fails with needs_mapping. A preset without a language column creates keys only, when createUnknownKeys is on. When it is done, Tolk sends the import.finished webhook.

Exporting

GET /exports/{profileKey} returns the file of an export profile. GET /project lists the project’s profiles under exportProfiles. Store the ETag of the response and send it next time as If-None-Match. If the export has not changed, you get a 304 without a body. The ETag is the hash of the bytes: a change that does not alter the file keeps the same ETag.
A large export that has not been built yet returns a 202 with a job. Fetch the export again once the job has succeeded.
After a change, Tolk rebuilds exports in the background and stores them. Fetching an export that has not changed therefore costs almost nothing.