The translation endpoints let you translate text using AI (powered by Meta’s M2M-100 model via Workers AI). Translations are cached to avoid redundant processing.
Translate text
Translates one or more strings into a target language.
Request body:
A single string or an array of strings to translate. Maximum 200 strings per request.
BCP 47 language code of the target language (e.g., "es", "fr", "pt")
BCP 47 language code of the source language. If omitted, the source is detected automatically.
Example — translate a single string:
curl -X POST https://app.credentialsportal.com/api/translate \
-H "Authorization: Bearer ck_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"text": "Welcome to Credentials Portal",
"target": "es"
}'
Response:
{
"translated": "Bienvenido al Portal de Credenciales"
}
Example — translate multiple strings:
curl -X POST https://app.credentialsportal.com/api/translate \
-H "Authorization: Bearer ck_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"text": ["Hello", "Goodbye", "Thank you"],
"target": "fr"
}'
Response:
{
"translated": ["Bonjour", "Au revoir", "Merci"]
}
List supported languages
GET /api/translate/languages
Returns a list of all supported languages with their BCP 47 language codes and display names.
Example:
curl https://app.credentialsportal.com/api/translate/languages \
-H "Authorization: Bearer ck_your_api_key"
Response:
[
{ "code": "en", "name": "English" },
{ "code": "es", "name": "Spanish" },
{ "code": "fr", "name": "French" },
{ "code": "pt", "name": "Portuguese" },
{ "code": "de", "name": "German" },
{ "code": "zh", "name": "Chinese" },
"..."
]
90+ languages are supported. Use the /api/translate/languages endpoint to get the complete list.
Translation in messages
Message translation happens automatically — when a user reads a conversation, each message is translated into their language on the fly. You don’t need to call the translation endpoint yourself for messaging.
The POST /api/translate endpoint is useful for translating other content — such as custom field values, course names, or external data you’re importing.