This recipe shows how to attach a custom reporting tag to translate requests using each official DeepL client library. For an overview of what custom reporting tags are, how they’re stored, and how to query their usage, see How to Use Custom Reporting Tags.Documentation Index
Fetch the complete documentation index at: https://deepl-c950b784-add-custom-tags-cookbook.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Ruby is omitted from the snippets below because the
deepl-rb library does not yet expose custom HTTP headers on translate requests. Support is in the works.Recommended pattern: one client per tag
All five client libraries shown below let you attach custom HTTP headers when constructing aDeepLClient. The simplest way to tag your requests is to construct one DeepLClient per tag value, configure it with X-DeepL-Reporting-Tag once, and reuse it for every request that should carry that tag.
This pattern works the same way across Python, Node.js, Java, .NET, and PHP. Each DeepLClient instance owns its own HTTP connection pool, so keep instances around and reuse them rather than constructing a new client per request.
Code snippets
The snippets below all send the same translate request ("Welcome to your dashboard." → DE) and tag it as team-billing. Replace YOUR_AUTH_KEY with your DeepL API authentication key.
- Python
- Node.js
- Java
- .NET
- PHP
client.headers as a public dictionary. Setting the key after construction merges with the library-managed Authorization and User-Agent headers.Tagging across many values
The one-client-per-tag pattern works well when your tag dimension is bounded: teams, products, or a handful of business units. If you need to tag with high-cardinality values, such as a unique tag per end customer, holding aDeepLClient instance for every value isn’t practical.
Today, none of the client libraries expose per-request custom headers through their public translate methods. The HTTP client layers in deepl-node, deepl-python, and deepl-php already support per-request header injection internally, so the foundation is in place. The Java and .NET libraries support only per-instance headers.
Updates to extend per-request custom-header support across the client libraries are planned. Until those updates land, the per-instance pattern above is the supported path.
Next steps
- Concepts and limits: Read How to Use Custom Reporting Tags for the validation rules, naming guidance, and the relationship between tags and API keys.
- Query tagged usage: See the Get custom tag usage analytics reference.