code field matching the HTTP status and a descriptive message field.
Error Response Format
All error responses follow this structure:HTTP Status Codes
200 OK
Successful translation request. The response includes the fullDeepLXTranslationResult object with translated text and alternatives.
400 Bad Request
The request was malformed or contained invalid parameters.When does 400 occur?
When does 400 occur?
Source:
service/service.go:121-126, service/service.go:166-170, service/service.go:233-237A 400 error is returned when:- The
tag_handlingparameter is provided but is not"html"or"xml" - The request body cannot be parsed as valid JSON
- Required fields are missing from the request payload (e.g.,
textortarget_langin/v2/translate)
401 Unauthorized
Authentication failed or required credentials are missing.When does 401 occur?
When does 401 occur?
Source:
service/service.go:50-56, service/service.go:179-190Authentication errors occur when:- Invalid access token - When the server is configured with a
token, requests must provide a matching token via:- Query parameter:
?token=YOUR_TOKEN - Header:
Authorization: Bearer YOUR_TOKEN - Header:
Authorization: DeepL-Auth-Key YOUR_TOKEN
- Query parameter:
- Missing dl_session - The
/v1/translatePro endpoint requires adl_sessioncookie, provided via:- Configuration file
- HTTP
Cookieheader:Cookie: dl_session=YOUR_SESSION
- Free account on Pro endpoint - If the
dl_sessioncontains a period (.), it indicates a free DeepL account, which cannot be used with the Pro endpoint.
404 Not Found
The requested endpoint does not exist, or no text was provided for translation.When does 404 occur?
When does 404 occur?
Source:
translate/translate.go:112-117, service/service.go:267-272404 errors occur when:- The
textfield in the request is empty or missing - An undefined API endpoint is accessed (caught by the
NoRoutehandler)
The root endpoint (
/) returns 200 with a welcome message and GitHub link. Only undefined paths trigger the 404 “Path not found” error.429 Too Many Requests
The request rate limit has been exceeded and the IP address has been temporarily blocked by DeepL.When does 429 occur?
When does 429 occur?
Source:
translate/translate.go:78-80This error occurs when:- DeepL’s rate limiting detects too many requests from the same IP address
- The upstream DeepL API returns HTTP 429
- This is a temporary block that typically resolves after some time
503 Service Unavailable
The translation request failed due to upstream service issues or invalid responses.When does 503 occur?
When does 503 occur?
Source:
translate/translate.go:154-158, translate/translate.go:163-167, translate/translate.go:172-176Service unavailable errors occur when:- The request to DeepL’s API fails (network error, timeout, non-200 status)
- The response body cannot be read or decompressed
- The DeepL API returns an empty
textsarray - The main translation text is empty in the response
Error Handling Best Practices
Retry Strategy
Recommended retry strategy:
- Retry on
429(rate limit) and503(service unavailable) - Use exponential backoff (1s, 2s, 4s, etc.)
- Do NOT retry on
400,401, or404(client errors that won’t resolve with retrying) - Maximum of 3-5 retry attempts
Debugging Tips
Enable verbose logging
Enable verbose logging
DeepLX uses the standard Go
log package. To see detailed logs including fatal errors:Test endpoints with curl
Test endpoints with curl
