Translate Email
Translate email subject and HTML body content in a single request. The subject is translated using standard text translation, while the email body is translated using HTML translation to preserve all HTML tags and structure.
Endpoint
POST /v2/translate/emailHeaders
X-API-KEY string (required)
: Your API key for authentication
Content-Type string (required)
: Must be application/json
Request Parameters
Body Parameters
subject string (required)
: Email subject line to translate (1-5000 characters)
email_body string (required)
: Email body HTML content to translate (1-150000 characters)
source string (required)
: Source language code (e.g., "en", "fr") or "auto" for auto-detection
target string (required)
: Target language code (e.g., "en", "fr")
Example Request
curl https://api.translateplus.io/v2/translate/email \
-H "X-API-KEY: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"subject": "Welcome to our service",
"email_body": "<p>Thank you for signing up!</p><p>We'\''re excited to have you.</p>",
"source": "en",
"target": "fr"
}'Response
Success Response (200 OK)
{
"subject": "Bienvenue dans notre service",
"html_body": "<p>Merci de vous être inscrit!</p><p>Nous sommes ravis de vous avoir.</p>"
}Response Fields
subject string
: Translated email subject
html_body string
: Translated email body HTML content with all tags preserved
Features
- Parallel Processing: Subject and body are translated concurrently for faster response times
- HTML Preservation: All HTML tags, attributes, and structure in the email body are preserved
- Single Request: Translate both subject and body in one API call
- Consistent Translation: Both parts use the same source and target languages
Credits
This endpoint requires variable credits depending on the email content:
- Subject: 1 credit (fixed)
- Email Body: 1 credit per text node in the HTML (variable)
- Each text segment in the HTML body counts as one text node
- Example:
<p>Hello</p><p>World</p>has 2 text nodes = 2 credits - Example:
<p>Hello <b>World</b></p>has 2 text nodes = 2 credits
Total Credits = 1 (subject) + number of text nodes in email body
The number of credits for the email body depends on the HTML structure. Each text segment between HTML tags counts as one text node and requires 1 credit.
Error Responses
400 Bad Request
Invalid request parameters:
{
"detail": "Invalid request"
}402 Payment Required
Insufficient credits:
{
"detail": "Insufficient credits. You have 0 credit(s) remaining, but this request requires X credit(s). Please upgrade your plan to continue using the API."
}Note: The required credits depend on the number of text nodes in the email body HTML. The error message will show the actual number of credits needed.
403 Forbidden
Invalid API key:
{
"detail": "Invalid API key. Please verify your API key is valid."
}429 Too Many Requests
Rate limit exceeded:
{
"detail": "Rate limit exceeded. Please try again later."
}500 Internal Server Error
Internal server error:
{
"detail": "Internal server error"
}