Prerequisites
- A DeepL API authentication key for an account with example documents enabled, exported as
API_KEY. A scoped key needs the scopes listed under permission scopes. - A document in a supported file format, written in a language that supports example documents. To check programmatically, call
GET /v3/languages?resource=example_documents.
member-newsletter.txt, a German customer newsletter that addresses readers informally and uses gender-inclusive forms such as “Kund:innen”.
Step 1: Create the import job
Declare the file you are going to upload. Send its name and its size in bytes, and optionally a name for the example document.Example request
Example response
UPLOAD_URL for Step 2. The URL stops working at the expiry time in the response.
To get the size of a file in bytes, run wc -c < member-newsletter.txt.
Step 2: Upload the file
Send the file to the upload URL with aPUT request. The URL is already signed, so leave out the Authorization header.
Example request
201 Created. Processing starts on its own, so there is no call to confirm the upload.
Step 3: Wait for the import to finish
Poll the job until its status iscompleted, failed, or expired. Imports of short documents typically finish within a minute.
Example request
Example response
failed, the result carries a message instead. See the import job reference for the status values and failure messages.
Step 4: Translate with the example document
Reference the example document in a text translation request. Send the request as JSON and translate into the language the document is written in.Example request
Example response
Verify the result
Nothing in the response says whether an example document was applied. To confirm it, send the same request without the example document and compare the two translations.Example response without the example document
Remove an example document
To see which example documents your account holds, list them. When a document is out of date, delete it and import the new version, because an imported document cannot be edited. Remove the ID from your translation requests before you delete the document. A request that references a deleted example document fails.Example request
204 No Content with an empty body.