Free setup on annual plans

Sign up today!

Translations

API Reference: Translations endpoints

Two AI helpers for text and language: translate a text into another language, and guess the most likely language of a place from its country, state and city. Both answer with plain text, store nothing and run on the customer’s own OpenAI API key.

Endpoints

  • POST /api/Translations/translate
    Access: Bearer JWT
    Translate sourceText into the language targetLang. Returns the translation as plain text.
  • GET /api/Translations/detect-language-ai
    Access: Bearer JWT
    Guess the main language spoken at a location. Query: country, state and city. Returns an ISO 639-3 language code such as nld as plain text.

The texts of the chat window per language are managed per channel, see the Channels page.

Translate

Request body

  • sourceText (string, required)
    The text to translate. Plain text or HTML; there is no fixed size limit.
  • targetLang (string, required)
    The target language as an ISO 639 code of 2 or 3 letters, for example nl, fr, deu or Eng; a regional code such as nl-BE also works. The code is not validated: an unknown code is passed to the model as it is.

Behaviour

  • The model is the customer’s default text translation model. When none is set, or it is not active or not suitable for translation, AnswerPal’s default translation model is used.
  • The whole text is translated, without summary or explanation. Names, numbers, amounts, dates, e-mail addresses, URLs and codes stay as written; line breaks, lists and HTML tags are kept. Text that is already in the target language stays as it is.
  • The answer is the translation only, with surrounding spaces removed. Without an Accept header it comes as text/plain; with Accept: application/json as a JSON string.
  • When the translation would be cut off by the model’s output limit, the call fails with 500 instead of returning a partial translation. Split very long texts.
POST /api/Translations/translate
Authorization: Bearer <token>
Content-Type: application/json

{
  "sourceText": "Thank you for your message. Your order 2026-001234 ships on Monday.",
  "targetLang": "nl"
}
200 OK
Content-Type: text/plain; charset=utf-8

Bedankt voor je bericht. Je bestelling 2026-001234 wordt maandag verzonden.
POST /api/Translations/translate
Accept: application/json

200 OK
Content-Type: application/json; charset=utf-8

"Bedankt voor je bericht. Je bestelling 2026-001234 wordt maandag verzonden."

Detect language

Query parameters

  • country (string, required)
    For example Belgium or BE.
  • state (string, required)
    State, province or region.
  • city (string, required)

All three must be present and not empty; a missing one gives 400.

Behaviour

  • AnswerPal’s general AI model is asked for the most likely main language of the place, as an ISO 639-3 code (3 letters, for example nld, fra or deu). When it is not sure, it answers eng.
  • The answer is the model’s text with surrounding spaces removed; it is not checked against a list of codes. Check the value before you use it.
  • This call does not use the customer’s translation model.
GET /api/Translations/detect-language-ai?country=Belgium&state=Wallonia&city=Namur
Authorization: Bearer <token>
200 OK
Content-Type: text/plain; charset=utf-8

fra

Access and status codes

Every signed-in user of the customer can call these endpoints. The calls use the OpenAI API key of the customer in the token, so they count towards that customer’s OpenAI usage.

  • 200 OK
    The translation or the language code.
  • 400 Bad Request
    A missing or empty sourceText, targetLang, country, state or city, or no OpenAI API key configured for the customer (the text No valid OpenAI API key configured for this customer.).
  • 404 Not Found
    Translate only: the customer in the token does not exist.
  • 500 Internal Server Error
    The AI call failed, or the translation was cut off. The answer is a short text such as An error occurred during translation.
  • 503 Service Unavailable
    Translate only: no translation model is available.

FAQ

ISO 639 codes of 2 or 3 letters, such as nl, nld, fr or fra; case does not matter. The model gets the English name of the language. An unknown code is not refused, so check your codes.

No. Both endpoints only return text; no message, draft or other data is changed.

The default text translation model set for the customer, or AnswerPal's default translation model when none is set. The language detection always uses AnswerPal's general model.

Both calls run on the customer's own OpenAI API key. Configure the key for the customer first.

Need more help?

Table of Contents

AnswerPal: AI-powered customer service solutions to elevate your support and communication effortlessly.

Contact

For all support, sales, and partnership inquiries, email us at info@answerpal.eu

AnswerPal
Bisschoppenhoflaan 380
2100 Antwerp
Belgium

+32.36416685

BE 0862.692.858