# Request Translation
**POST /v2/translate**
The translate function.
The total request body size must not exceed 128 KiB (128 · 1024 bytes). Please split up your text into multiple
calls if it exceeds this limit.
## Servers
- DeepL API Pro: https://api.deepl.com (DeepL API Pro)
- DeepL API Free: https://api-free.deepl.com (DeepL API Free)
## Authentication methods
- Auth header
## Parameters
### Body: application/json (object)
- **text** (array[string])
Text to be translated. Only UTF-8-encoded plain text is supported. The parameter may be specified
multiple times and translations are returned in the same order as they are requested. Each of the
parameter values may contain multiple sentences.
- **source_lang** (string)
Language of the text to be translated. If this parameter is omitted, the API will attempt to detect the language of the text and translate it.
**Note:** Some languages only work with `model_type` set to `quality_optimized`. See [supported languages](https://developers.deepl.com/docs/getting-started/supported-languages) for more details.
- **target_lang** (string)
The language into which the text should be translated.
**Note:** Some languages only work with `model_type` set to `quality_optimized`. See [supported languages](https://developers.deepl.com/docs/getting-started/supported-languages) for more details.
- **context** (string)
The `context` parameter makes it possible to include additional context that can influence a translation but is not translated itself.
This additional context can potentially improve translation quality when translating short, low-context source texts such
as product names on an e-commerce website, article headlines on a news website, or UI elements.
For example...
- When translating a product name, you might pass the product description as context.
- When translating a news article headline, you might pass the first few sentences or a summary of the article as context.
For best results, we recommend sending a few complete sentences of context in the same language as the source text.
There is no size limit for the `context` parameter itself, but the request body size limit of 128 KiB still applies to
all text translation requests.
If you send a request with multiple `text` parameters, the `context` parameter will be applied to each one.
Characters included in the `context` parameter will not be counted toward billing (i.e. there is no additional
cost for using the `context` parameter, and only characters sent in the text parameter(s) will be counted toward
billing for text translation even when the `context` parameter is included in a request).
- **show_billed_characters** (boolean)
When true, the response will include the billed_characters parameter, giving the
number of characters from the request that will be counted by DeepL for billing purposes.
Note: for requests sent as URL-encoded forms, boolean values should be specified as "1" or "0".
- **split_sentences** (string)
Sets whether the translation engine should first split the input into sentences. For text translations where
`tag_handling` is not set to `html`, the default value is `1`, meaning the engine splits on punctuation and on newlines.
For text translations where `tag_handling=html`, the default value is `nonewlines`, meaning the engine splits on punctuation only, ignoring newlines.
The use of `nonewlines` as the default value for text translations where `tag_handling=html` is new behavior that was implemented in November 2022,
when HTML handling was moved out of beta.
Possible values are:
* `0` - no splitting at all, whole input is treated as one sentence
* `1` (default when `tag_handling` is not set to `html`) - splits on punctuation and on newlines
* `nonewlines` (default when `tag_handling=html`) - splits on punctuation only, ignoring newlines
For applications that send one sentence per text parameter, we recommend setting `split_sentences` to `0`, in order to prevent the engine from splitting the sentence unintentionally.
Please note that newlines will split sentences when `split_sentences=1`. We recommend cleaning files so they don't contain breaking sentences or setting the parameter `split_sentences` to `nonewlines`.
- **preserve_formatting** (boolean)
Sets whether the translation engine should respect the original formatting, even if it would usually correct some aspects.
The formatting aspects affected by this setting include:
* Punctuation at the beginning and end of the sentence
* Upper/lower case at the beginning of the sentence
Note: for requests sent as URL-encoded forms, boolean values should be specified as "1" or "0".
- **formality** (string)
Sets whether the translated text should lean towards formal or informal language.
This feature currently only works for target languages
`DE` (German),
`FR` (French),
`IT` (Italian),
`ES` (Spanish),
`ES-419` (Latin American Spanish),
`NL` (Dutch),
`PL` (Polish),
`PT-BR` and `PT-PT` (Portuguese),
`JA` (Japanese),
and `RU` (Russian).
Learn more about the plain/polite feature for Japanese [here](https://support.deepl.com/hc/en-us/articles/6306700061852-About-the-plain-polite-feature-in-Japanese).
Setting this parameter with a target language that does not support formality will fail,
unless one of the `prefer_...` options are used.
Possible options are:
* `default` (default)
* `more` - for a more formal language
* `less` - for a more informal language
* `prefer_more` - for a more formal language if available, otherwise fallback to default formality
* `prefer_less` - for a more informal language if available, otherwise fallback to default formality
- **model_type** (string)
Specifies which DeepL model should be used for translation.
Possible values are:
* `latency_optimized` (default) - uses lower latency “classic” translation models, which support all language pairs;
default value
* `quality_optimized` - uses higher latency, improved quality “next-gen” translation models, which support only a
subset of language pairs; if a language pair that is not supported by next-gen models is included in the
request, it will fail. Consider using prefer_quality_optimized instead.
* `prefer_quality_optimized` - prioritizes use of higher latency, improved quality “next-gen” translation models,
which support only a subset of DeepL languages; if a request includes a language pair not supported by
next-gen models, the request will fall back to latency_optimized classic models.
- **glossary_id** (string)
- **custom_instructions** (array[string])
Specify a list of instructions to customize the translation behavior. Up to 10 custom instructions can be specified, each with a maximum of 300 characters.
**Important:** The target language must be `de`, `en`, `es`, `fr`, `it`, `ja`, `ko`, `zh` or any variants of these languages.
**Note:** Any request with the `custom_instructions` parameter enabled will default to use the `quality_optimized` model type. Requests combining `custom_instructions` and `model_type: latency_optimized` will be rejected.
- **enable_beta_languages** (boolean)
Enables 81 additional beta languages. See the full list at https://developers.deepl.com/docs/getting-started/supported-languages#beta-languages. **Note:** Any request with the `enable_beta_languages` parameter enabled will use `quality_optimized` models. Requests combining `enable_beta_languages: true` and `model_type: latency_optimized` will be rejected. Beta languages do not support formality or glossaries.
- **tag_handling** (string)
Sets which kind of tags should be handled. Options currently available:
* `xml`: Enable XML tag handling; see [XML Handling](https://www.deepl.com/docs-api/xml).
* `html`: Enable HTML tag handling; see [HTML Handling](https://www.deepl.com/docs-api/html).
- **outline_detection** (boolean)
The automatic detection of the XML structure won't yield best results in all XML files. You can disable this automatic mechanism altogether by setting the `outline_detection` parameter to `false` and selecting the tags that should be considered structure tags. This will split sentences using the `splitting_tags` parameter.
In the example below, we achieve the same results as the automatic engine by disabling automatic detection with `outline_detection=0` and setting the parameters manually to `tag_handling=xml`, `split_sentences=nonewlines`, and `splitting_tags=par,title`.
* Example request:
```
A document's title
This is the first sentence. Followed by a second one.
This is the third sentence.
```
* Example response:
```
Der Titel eines Dokuments
Das ist der erste Satz. Gefolgt von einem zweiten.
Dies ist der dritte Satz.
```
While this approach is slightly more complicated, it allows for greater control over the structure of the translation output.
Note: for requests sent as URL-encoded forms, boolean values should be specified as "1" or "0".
- **non_splitting_tags** (array[string])
List of XML tags which never split sentences.
For some XML files, finding tags with textual content and splitting sentences using those tags won't yield the best results. The following example shows the engine splitting sentences on `par` tags and proceeding to translate the parts separately, resulting in an incorrect translation:
* Example request:
```
The firm said it had been conducting an internal investigation.
```
* Example response:
```
Die Firma sagte, es sei eine gute Idee gewesen. Durchführung einer internen Untersuchung.
```
As this can lead to bad translations, this type of structure should either be avoided, or the `non_splitting_tags` parameter should be set. The following example shows the same call, with the parameter set to `par`:
* Example request:
```
The firm said it had been conducting an internal investigation.
```
* Example response:
```
Die Firma sagte, dass sie eine interne Untersuchung durchgeführt habe.
```
This time, the sentence is translated as a whole. The XML tags are now considered markup and copied into the translated sentence. As the translation of the words "had been" has moved to another position in the German sentence, the two par tags are duplicated (which is expected here).
- **splitting_tags** (array[string])
List of XML tags which always cause splits.
See the example in the `outline_detection` parameter's description.
- **ignore_tags** (array[string])
List of XML tags that indicate text not to be translated.
Use this parameter to ensure that elements in the original text are not altered in the translation (e.g., trademarks, product names) and insert tags into your original text. In the following example, the `ignore_tags` parameter is set to `keep`:
* Example request:
```
Please open the page Settings to configure your system.
```
* Example response:
```
Bitte öffnen Sie die Seite Settings um Ihr System zu konfigurieren.
```
## Responses
### 200
The translate function returns a JSON representation of the translations in the order the text parameters have been specified.
#### Headers
- **X-Trace-ID** ()
A unique identifier for the request that can be included in bug reports to DeepL support.
#### Body: application/json (object)
- **translations** (array[object])
### 400
Bad request. Please check error message and your parameters.
#### Headers
- **X-Trace-ID** ()
A unique identifier for the request that can be included in bug reports to DeepL support.
### 403
Authorization failed. Please supply a valid `DeepL-Auth-Key` via the `Authorization` header.
#### Headers
- **X-Trace-ID** ()
A unique identifier for the request that can be included in bug reports to DeepL support.
### 404
The requested resource could not be found.
#### Headers
- **X-Trace-ID** ()
A unique identifier for the request that can be included in bug reports to DeepL support.
### 413
The request size exceeds the limit.
#### Headers
- **X-Trace-ID** ()
A unique identifier for the request that can be included in bug reports to DeepL support.
### 414
The request URL is too long. You can avoid this error by using a POST request instead of a GET request, and sending the parameters in the HTTP body.
#### Headers
- **X-Trace-ID** ()
A unique identifier for the request that can be included in bug reports to DeepL support.
### 429
Too many requests. Please wait and resend your request.
#### Headers
- **X-Trace-ID** ()
A unique identifier for the request that can be included in bug reports to DeepL support.
### 456
Quota exceeded. The character limit has been reached.
#### Headers
- **X-Trace-ID** ()
A unique identifier for the request that can be included in bug reports to DeepL support.
### 500
Internal error.
#### Headers
- **X-Trace-ID** ()
A unique identifier for the request that can be included in bug reports to DeepL support.
### 504
Resource currently unavailable. Try again later.
#### Headers
- **X-Trace-ID** ()
A unique identifier for the request that can be included in bug reports to DeepL support.
### 529
Too many requests. Please wait and resend your request.
#### Headers
- **X-Trace-ID** ()
A unique identifier for the request that can be included in bug reports to DeepL support.
[Powered by Bump.sh](https://bump.sh)