API

POST /v1/translate

Translate a piece of text with your account's settings and language assets. The core endpoint of the API.

Send text and a target language; receive the translation. Your account's translation memory can be reused automatically, and glossary enforcement applies just as in the workspace.

Request

cURLbash
curl -X POST https://www.deepreference.com/api/v1/translate \
  -H "Authorization: Bearer dr_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "The agreement enters into force upon signature.",
    "target_lang": "de",
    "domain": "legal",
    "tone": "formal"
  }'
FieldTypeDefaultDescription
textstringrequiredThe text to translate, up to 20,000 characters.
target_langstringrequiredTarget language code, e.g. "de", "fr", "zh".
source_langstring"auto"Source language code, or "auto" to detect it.
domainstring"general"One of the 13 domains (see Domains).
modestring"natural""natural" or "literal" (see Tone and mode).
tonestring"standard"The tone of the result (see Tone and mode).
use_tmbooleantrueReuse your translation memory for exact matches.

Response

200 OKjson
{
  "translation": "Die Vereinbarung tritt mit der Unterzeichnung in Kraft.",
  "source_lang": "en",
  "target_lang": "de",
  "billable_words": 9,
  "tm_match": false
}
FieldMeaning
translationThe translated text.
source_langThe detected or provided source language.
target_langThe target language of the result.
billable_wordsWords charged for this request: the visible words of the result.
tm_matchtrue if the result came from your translation memory instead of fresh generation.

Sending the same text twice with use_tm enabled? The second call returns your stored translation: consistent, fast, and marked with tm_match: true.

Errors

  • 401: missing or invalid API key. The response tells you which header formats are accepted.
  • 403: the key's account plan does not include API access, or the key lacks the translate scope.
  • 422: invalid parameters (empty text, unknown field values, text over the length limit).
  • 429 / quota errors: your monthly word allowance is exhausted; check /v1/usage.