Translation portal

Machine-translate text on the spot, or files as requests, with your organization's portal setups.

Owners, admins, project managers and customers can use the portal's endpoints with their own access key; a linguist's key gets 403. A Customer's key reaches only /api/v1/portal/*, /mcp (the portal's translate tool and the docs tools only) and, read-only, their own file requests as projects: GET /api/v1/projects, /api/v1/projects/{projectID}, its /jobs and GET /api/v1/files/{fileID}/source. Each file request is yours alone: another member gets 404 for it.

The portal is always on. Until an owner or admin has published a portal setup, ready in the configuration is false, and a text or a new request answers 409 with code portal_not_set_up.

1. Read the configuration

GET /api/v1/portal/config

max_text_chars is the longest text, max_file_bytes the largest file, max_targets the most target languages, max_files the most files one request holds, sent together or added later (and the most requests one zip download takes), and max_send_bytes the most all the files of one request may hold together.

2. Pick a portal setup

GET /api/v1/portal/setups

This lists your organization's portal setups. A portal setup decides the MT engine for each target language, and the TMs and term bases used. source_language and target_languages are the only languages it takes; empty means any language. engines lists the engines it may use, one per provider, each with provider and name. Send a portal setup's id as setup_id.

kind is ai when every step is automated, so a request finishes on its own, or human when a person works a step. A customer's list leaves out human portal setups unless an owner or admin allowed them; naming one anyway answers 400 with "portal setup not found". automated is true when a step runs on its own, with AI or machine translation: always for ai, and for a human portal setup that is AI and human. text is true when the portal setup also translates pasted text (it is Pre-translation alone).

Without setup_id, your last portal setup is used while the portal still offers it, else the one marked is_default, else the first. For text, only portal setups with text: true count.

3. Translate text

POST /api/v1/portal/translate
Content-Type: application/json

{"text": "Hello world.", "source": "en", "targets": ["de", "fr"]}

The answer holds the translations, one per target language:

{"data": {"source_language": "en", "setup_id": 4, "word_count": 2, "translations": [
  {"language": "de", "status": "done", "text": "Hallo Welt."},
  {"language": "fr", "status": "failed", "error": "This portal setup has no machine translation engine for this language. Try another portal setup, or ask your admin."}
]}}

No request or project is made, so there is nothing to read again, and the text never reaches a TM. A language that fails says why, and the others still translate. Send a text longer than max_text_chars as a file. A setup_id whose portal setup has text: false answers 400.

word_count counts the source text once, not per target. A standalone number such as 42 or $9.99 is one word, unless an owner or admin has turned off counting numbers as words in the organization's settings; then it is zero.

4. Send files

POST /api/v1/portal/requests
Content-Type: multipart/form-data

Send each file as its own file part (up to max_files, max_send_bytes in all), with source, targets (comma-separated, or the field repeated) and an optional setup_id. The files sent together are one request. Every file is checked first: one the portal cannot take, such as a PDF (it cannot be given back as a PDF), refuses the whole request with 400, naming each such file. The answer is the request with status: "running"; the translation runs in the background; with a human portal setup it stays running until a person finishes their step. A file that fails only when it is stored is left out and named in not_sent, and the other files go on. More than max_files files answer 400 with "a request holds at most 100 files".

Drafts and more files

Send draft=true with no targets to store the files as a draft with status: "draft": nothing runs, and source may be left out. The draft keeps its portal setup.

GET /api/v1/portal/draft
POST /api/v1/portal/requests/{requestID}/send
Content-Type: application/json

{"source": "en", "targets": ["de", "fr"]}

GET /portal/draft returns your latest draft, or {"data": null} when you have none. send starts the draft in the languages you give and answers the request, now running; an optional setup_id must be the draft's own.

POST /api/v1/portal/requests/{requestID}/files
Content-Type: multipart/form-data

This adds file parts to one of your requests, checked like a new request's; the files already in it count toward max_files. On a sent request each new file runs in the request's languages and the files already there do not run again; a finished request runs again. On a draft the new files wait until it is sent. A request on hold, or one whose portal setup is no longer offered, takes no files.

5. Wait for the result

GET /api/v1/portal/requests/{requestID}

Read it until status is done, editing or failed. files lists the files in the order you sent them, each with its id and its languages: the state of each target language, where a failed one carries an error. editing means you reopened a language in the app's CAT editor: it downloads with your edits so far, and reads done again once you complete it there. Each language's job_id is the job the app's editor opens. tm_words counts the words filled from translation memory, over every target language, and tm_percent is their share (0 to 100) of word_count times the languages; the request and each file carry both. Both are 0 while the request is running and in the list of requests: read one finished request for them.

6. Download

GET /api/v1/portal/requests/{requestID}/download?file=31&lang=de
GET /api/v1/portal/requests/archive?ids=12,13

download returns one file in its own format; file (the file's id) may be left out when the request has one file, and lang when it has one target language. The file is named <language> <file name>, for example de report.docx. It answers 409 with code not_ready while the language is running or failed.

archive returns a zip with every done or editing language of every file of up to 20 of your requests, each entry named the same way; languages still running or failed are left out. It answers 409 (not_ready) when none is ready to download yet, and 413 (archive_too_large) past 200 MB.

GET /api/v1/portal/requests lists your requests, newest first, and DELETE /api/v1/portal/requests/{requestID} deletes one with its files.

Related