TranslateText

Request Translation

Changed on

Translate one or more text strings into a target language. Send multiple strings in a single request, within the request size limit, and specify formatting, tag handling, and customization options such as glossaries, style rules, and translation memories.

post/v2/translate

Request

  • Base URL
    https://api.deepl.com
  • URL
    https://api.deepl.com/v2/translate
  • Auth
    API key in header Authorization

Headers

X-DeepL-Reporting-Tagstring

An optional custom reporting tag used to attribute this request's usage to a team, project, customer, or other category of your choosing. Values are limited to 100 characters. See How to use custom reporting tags for validation rules, naming guidance, and how to retrieve usage by tag.

Request body

textstring[] required

Text to be translated. Only UTF-8-encoded plain text is supported. The parameter may be specified many times in a single request, within the request size limit (128KiB). Translations are returned in the same order as they are requested. Each text in the array is translated independently — texts do not share context with each other.

source_langstring

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.

For the full list of supported source languages, see supported languages or query the GET /v3/languages endpoint.

target_langstring required

The language into which the text should be translated.

For the full list of supported target languages, see supported languages or query the GET /v3/languages endpoint.

contextstring

Additional context that can influence a translation but is not translated itself.

Characters included in the context parameter will not be counted toward billing.

show_billed_charactersboolean

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.

split_sentences'0' | '1' | 'nonewlines'

Sets whether the translation engine should first split the input into sentences.

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
preserve_formattingboolean

Sets whether the translation engine should respect the original formatting, even if it would usually correct some aspects.

formality'default' | 'more' | 'less' | 'prefer_more' | 'prefer_less'

Sets whether the translated text should lean towards formal or informal language. This feature is only available for certain target languages. 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'quality_optimized' | 'prefer_quality_optimized' | 'latency_optimized'

Specifies which DeepL model should be used for translation.

glossary_idstring

Specify the glossary to use for the translation. The glossary needs a dictionary for the language pair of the request.

If source_lang is omitted, DeepL detects the source language and uses the dictionary for the detected language pair. The request returns a 400 if the glossary has no dictionary for that pair.

Cannot be used together with glossary_ids.

glossary_idsstring[]

Specify up to 5 glossaries to use for the translation, as an array of glossary IDs. Each glossary's matching terms are applied to the translation.

Every listed glossary must contain a dictionary for the requested language pair.

If source_lang is omitted, DeepL detects the source language and every listed glossary must contain a dictionary for the detected language pair. A single glossary without a matching dictionary returns a 400 for the whole request.

Cannot be used together with glossary_id.

style_idstring

Specify the style rule list to use for the translation.

Important: The target language has to match the language of the style rule list. A list created for a root language (for example en) applies to that language and all of its variants (EN-GB, EN-US). A list created for a variant (for example en-GB) applies only when target_lang is that variant.

All model_type values are supported.

translation_memory_idstring uuid

A unique ID assigned to a translation memory.

translation_memory_thresholdinteger

The minimum matching percentage required for a translation memory segment to be applied (recommended to be 75% or higher). A value below 50 is treated as 50.

custom_instructionsstring[]

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.

style_profile_idstring uuid

Translate with a style profile: its glossaries, style rule lists and translation memories through one ID. The profile is applied per text once the source language is known: the glossaries with a dictionary for the text's language pair, the style rule list for the target language, and the translation memories whose source language matches the text. A component that does not fit a text's language pair is left out for that text; this is not an error.

Cannot be combined with glossary_id, glossary_ids, style_id, translation_memory_id, translation_memory_threshold or custom_instructions. A request that combines them is rejected with 400 Bad Request. A style profile that does not exist or that your account cannot access is rejected with 404 Not Found.

tag_handling'xml' | 'html'

Sets which kind of tags should be handled. Options currently available:

  • xml
  • html
tag_handling_version'v2' | 'v1'

Sets which version of the tag handling algorithm should be used. Options currently available:

  • v1: Traditional algorithm (currently the default, will become deprecated in the future).
  • v2: Improved algorithm released in October 2025 (will become the default in the future).
outline_detectionboolean

Disable the automatic detection of XML structure 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.

enable_beta_languagesboolean

This parameter is maintained for backward compatibility and has no effect.

non_splitting_tagsstring[]

Comma-separated list of XML tags which never split sentences.

splitting_tagsstring[]

Comma-separated list of XML tags which always cause splits.

ignore_tagsstring[]

Comma-separated list of XML tags that indicate text not to be translated.

Example request

{
  "text": [
    "Hello, World!"
  ],
  "source_lang": "EN",
  "target_lang": "DE",
  "context": "This is context.",
  "split_sentences": "1",
  "formality": "prefer_more",
  "glossary_id": "def3a26b-3e84-45b3-84ae-0c0aaf3525f7",
  "glossary_ids": [
    "def3a26b-3e84-45b3-84ae-0c0aaf3525f7"
  ],
  "style_id": "7ff9bfd6-cd85-4190-8503-d6215a321519",
  "translation_memory_id": "a74d88fb-ed2a-4943-a664-a4512398b994",
  "translation_memory_threshold": 75,
  "custom_instructions": [
    "Use a friendly, diplomatic tone"
  ],
  "style_profile_id": "3f1c9d0e-7a24-4b58-9c31-8f0e5d2a1b47",
  "tag_handling": "html",
  "non_splitting_tags": [
    "non_splitting_tag"
  ],
  "splitting_tags": [
    "splitting_tag"
  ],
  "ignore_tags": [
    "ignore_tag"
  ]
}

Response

The translate function returns a JSON representation of the translations in the order the text parameters have been specified.

Example response

{
  "translations": [
    {
      "detected_source_language": "EN",
      "text": "Hallo, Welt!",
      "billed_characters": 42,
      "model_type_used": "quality_optimized",
      "tag_handling_version": "v2"
    }
  ]
}

Changes

    • info

      added the new optional header request parameter X-DeepL-Reporting-Tag

    • info

      added the new optional request property (media type: application/json)

    • info

      added the new optional request property (media type: application/x-www-form-urlencoded)

    • info

      added the new 1 enum value to the request property (media type: application/x-www-form-urlencoded)

    • info

      added the media type application/json for the response with the status

    • info

      added the media type application/json for the response with the status

    • info

      added the media type application/json for the response with the status