Free setup on annual plans

Sign up today!

Translations

API Reference: Translations endpoints

The Translations API provides two authenticated AI-assisted text utilities: translate a plain text string to a requested language, and infer the most likely primary language for a location. Both routes use the authenticated customer’s configured OpenAI API key.

Current endpoints

Translate text

These endpoints are customer-scoped utility calls. They do not manage stored website translations or channel UI labels. Per-channel chat UI/message translations are covered by the Channels API through /api/ChannelTranslations and /api/Channels/{channelToken}/translations-by-token/{lang}.

  • POST /api/Translations/translate – Bearer JWT
    Translate one plain text value to the requested target language. Body fields are sourceText and targetLang. The current service uses gpt-4o-mini and returns the translated text as a plain string.
  • GET /api/Translations/detect-language-ai – Bearer JWT
    Infer a likely primary language from query parameters country, state and city. country is required; state and city are optional context. The current service asks for an ISO 639-3 language code.

Translate request body

POST /api/Translations/translate
Authorization: Bearer {token}
Content-Type: application/json

{
  "sourceText": "Thank you for your message.",
  "targetLang": "nld"
}

Request fields

TranslateRequest body

  • sourceText
    Required string. Empty or whitespace-only input returns 400 Bad Request.
  • targetLang
    Required language code passed to the translation engine. Prefer stable ISO codes such as nld, fra, deu or eng.

Language detection query

  • country
    Required country name or code. Missing or whitespace-only values return 400 Bad Request.
  • state, city
    Optional state/province and city context used to improve the language guess.

Translate response

Bedankt voor uw bericht.

Response and errors

Response format

  • POST /api/Translations/translate
    Returns 200 OK with the translated text as a plain string, not a JSON object.
  • GET /api/Translations/detect-language-ai
    Returns 200 OK with a language code string such as nld, fra or eng.

Access and errors

  • Bearer JWT
    Protected AnswerPal API endpoints use JWT Bearer authentication. There is no public anonymous translation route.
  • 400
    Returned when required input is missing or the authenticated customer has no OpenAI API key configured.
  • 404
    Returned by translation when the authenticated customer record cannot be found.
  • 500
    Returned when the AI translation or language-detection call fails unexpectedly.
POST /api/Translations/translate
Authorization: Bearer {token}
Content-Type: application/json

{
  "sourceText": "Thank you for your message.",
  "targetLang": "nld"
}
Bedankt voor uw bericht.
GET /api/Translations/detect-language-ai?country=Belgium&state=Flanders&city=Antwerp
Authorization: Bearer {token}
nld

Detect language

GET /api/Translations/detect-language-ai uses location context to infer the most likely primary language. The API requires country; state and city add context.

Detection query parameters

TranslateRequest body

  • sourceText
    Required string. Empty or whitespace-only input returns 400 Bad Request.
  • targetLang
    Required language code passed to the translation engine. Prefer stable ISO codes such as nld, fra, deu or eng.

Language detection query

  • country
    Required country name or code. Missing or whitespace-only values return 400 Bad Request.
  • state, city
    Optional state/province and city context used to improve the language guess.

Detection response

Request

GET /api/Translations/detect-language-ai?country=Belgium&state=Flanders&city=Antwerp
Authorization: Bearer {token}

Response

nld

Fields and behavior

TranslateRequest

TranslateRequest body

  • sourceText
    Required string. Empty or whitespace-only input returns 400 Bad Request.
  • targetLang
    Required language code passed to the translation engine. Prefer stable ISO codes such as nld, fra, deu or eng.

Language detection query

  • country
    Required country name or code. Missing or whitespace-only values return 400 Bad Request.
  • state, city
    Optional state/province and city context used to improve the language guess.

String responses

Response format

  • POST /api/Translations/translate
    Returns 200 OK with the translated text as a plain string, not a JSON object.
  • GET /api/Translations/detect-language-ai
    Returns 200 OK with a language code string such as nld, fra or eng.

Access and errors

  • Bearer JWT
    Protected AnswerPal API endpoints use JWT Bearer authentication. There is no public anonymous translation route.
  • 400
    Returned when required input is missing or the authenticated customer has no OpenAI API key configured.
  • 404
    Returned by translation when the authenticated customer record cannot be found.
  • 500
    Returned when the AI translation or language-detection call fails unexpectedly.

For stored per-channel UI/message translations such as chat titles, greetings, button text and escalation prompts, see the Channels API Reference. The current channel translation management routes are /api/ChannelTranslations, and public token-based retrieval uses /api/Channels/{channelToken}/translations-by-token/{lang}.

No. The Translations API translates an ad hoc plain text value or detects a likely language from location context. Stored chat UI/message translations are managed through the Channels API and /api/ChannelTranslations.

No public controller route currently exposes HTML translation. Use POST /api/Translations/translate for plain text and handle any HTML conversion in your integration.

The API loads the authenticated customer record and uses that customer's configured OpenAI API key. If no key is configured, the endpoint returns 400.

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