> ## Documentation Index
> Fetch the complete documentation index at: https://developers.deepl.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Translate text using a translation memory

> Learn how to retrieve your translation memories and use them in translation requests

## About translation memories

Translation memories store and reuse previously created translations. When you translate with a translation memory, your source text is compared against the translation memory's segments. If a segment is similar enough, the stored translation is applied instead of generating a new one.

## What you'll learn

In this tutorial, we'll retrieve the translation memories on your account, use one in a translation request, and adjust the matching threshold to control how closely source text must match a stored segment.

## Before you begin

You'll need:

* A DeepL API authentication key
* At least one translation memory uploaded to your account via the DeepL UI
* A terminal or HTTP client for making API requests
* Approximately 10 minutes

### Example translation memory

In this tutorial, we'll use a translation memory called "Greetings" that contains German-to-English translations. One of its segments looks like this:

| Source (DE) | Translation (EN) |
| ----------- | ---------------- |
| Hallo Welt! | Hello everyone!  |

Notice that the translation memory specifies a custom translation — "Hello everyone!" instead of the literal "Hello world!". When we send matching source text to the API with this translation memory, DeepL will reuse the stored translation instead of generating its own.

## Step 1: List your translation memories

First, let's retrieve the translation memories on your account so we can find the one we want to use.

```sh theme={null}
curl -X GET 'https://api.deepl.com/v3/translation_memories' \
--header 'Authorization: DeepL-Auth-Key [yourAuthKey]'
```

**Expected output:**

```json theme={null}
{
  "translation_memories": [
    {
      "translation_memory_id": "a74d88fb-ed2a-4943-a664-a4512398b994",
      "name": "Greetings",
      "source_language": "de",
      "target_languages": ["en"],
      "segment_count": 42
    }
  ],
  "total_count": 1
}
```

Notice the `translation_memory_id` — this is what we'll pass to the translate endpoint. Also note the `source_language` and `target_languages` fields, which tell us this translation memory translates from German to English.

<Info>
  If you see an empty list, make sure you've uploaded at least one translation memory via the [DeepL translation memory page](https://www.deepl.com/translation-memory).
</Info>

## Step 2: Translate text with a translation memory

Now let's use that translation memory in a translation request. Add the `translation_memory_id` parameter to your call to the [text translation endpoint](/api-reference/translate/request-translation#body-translation-memory-id).

```sh theme={null}
curl -X POST 'https://api.deepl.com/v2/translate' \
--header 'Authorization: DeepL-Auth-Key [yourAuthKey]' \
--header 'Content-Type: application/json' \
--data '{
  "text": [
    "Hallo Welt!"
  ],
  "target_lang": "EN",
  "translation_memory_id": "a74d88fb-ed2a-4943-a664-a4512398b994"
}'
```

**Expected output:**

```json theme={null}
{
  "translations": [
    {
      "detected_source_language": "DE",
      "text": "Hello everyone!"
    }
  ]
}
```

The result is "Hello everyone!" — the custom translation from our translation memory — rather than the default "Hello world!" that DeepL would produce without it.

Notice that we didn't need to specify `source_lang` — language auto-detection still works when using a translation memory.

## Step 3: Adjust the matching threshold

By default, a stored segment is applied when it matches at least **75%** of the source text. This means translation memory segments can match even when the source text isn't identical — which is useful for catching typos and minor variations.

Let's see this in action. Imagine we make a typo and send "Halloo Welt!" instead of "Hallo Welt!":

```sh theme={null}
curl -X POST 'https://api.deepl.com/v2/translate' \
--header 'Authorization: DeepL-Auth-Key [yourAuthKey]' \
--header 'Content-Type: application/json' \
--data '{
  "text": [
    "Halloo Welt!"
  ],
  "target_lang": "EN",
  "translation_memory_id": "a74d88fb-ed2a-4943-a664-a4512398b994"
}'
```

**Expected output:**

```json theme={null}
{
  "translations": [
    {
      "detected_source_language": "DE",
      "text": "Hello everyone!"
    }
  ]
}
```

With the default threshold of `75`, "Halloo Welt!" is close enough to "Hallo Welt!" that the translation memory segment still applies, and we get our custom translation "Hello everyone!".

Now let's raise the threshold to `100` so only exact matches are used:

```sh theme={null}
curl -X POST 'https://api.deepl.com/v2/translate' \
--header 'Authorization: DeepL-Auth-Key [yourAuthKey]' \
--header 'Content-Type: application/json' \
--data '{
  "text": [
    "Halloo Welt!"
  ],
  "target_lang": "EN",
  "translation_memory_id": "a74d88fb-ed2a-4943-a664-a4512398b994",
  "translation_memory_threshold": 100
}'
```

**Expected output:**

```json theme={null}
{
  "translations": [
    {
      "detected_source_language": "DE",
      "text": "Hello world!"
    }
  ]
}
```

With a threshold of `100`, "Halloo Welt!" is no longer an exact match for "Hallo Welt!", so the translation memory segment is not applied. DeepL falls back to its default translation: "Hello world!".

## What you've accomplished

You've learned how to:

* Retrieve the translation memories on your account
* Use a translation memory in a translation request
* Control the matching threshold to tune how closely source text must match a stored segment

## See also

* [List translation memories](/api-reference/translation-memory/list-translation-memories) — API reference
* [Text translation endpoint](/api-reference/translate/request-translation#body-translation-memory-id) — `translation_memory_id` and `translation_memory_threshold` parameter reference
* [Supported languages](/docs/getting-started/supported-languages) — check which languages support translation memories
