Mansa Platform Docs

Translate

Translate text from one supported language to another. Send `Authorization: Bearer` with your Mansa API key.

POST/v1/translate

Request example

curl --fail-with-body "$MANSA_API_BASE_URL/v1/translate" \
  -H "Authorization: Bearer $MANSA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "text": "Good morning",
  "from": "English",
  "to": "Swahili",
  "tone": "natural"
}'

Output

{
  "context": "ok",
  "data": {
    "translation": "Habari za asubuhi"
  }
}

The main endpoint for translating text between supported languages. Send the full language name, such as English and Swahili. Codes such as en and sw also work.

Authenticate with a Mansa API key in the Authorization header. See Authentication.

Request parameters

Send either text (single string) or segments (sync multi-segment), not both.

ParameterTypeRequiredDescription
textstringYes*Text to translate (*when not using segments)
segmentsarrayYes*Objects with text (required) and optional id. Sync only, maximum 10 segments (*when not using text)
fromstringYesSource language name or code. Auto-detect is not supported.
tostringYesTarget language name or code
tonestringNoTranslation register: precise, natural (default when omitted), expressive, or formal
contextstringNoOptional hints that clarify ambiguities (for example, "This phrase is from a medical document")
glossaryarrayNoInline glossary for this request: [{"term": "hello", "translation": "hujambo"}]

Response

Single-string requests return data.translation:

{
  "context": "ok",
  "data": {
    "translation": "Habari za asubuhi"
  }
}

Sync segments requests return data.segments (and optional from / to):

{
  "context": "ok",
  "data": {
    "segments": [
      {
        "text": "Hello",
        "translated_text": "Hujambo",
        "id": "1"
      }
    ],
    "from": "English",
    "to": "Swahili"
  }
}

Sync vs async

Use caseAPILimit
Single stringPOST /v1/translate with textOne segment
Up to 10 strings, immediate resultsPOST /v1/translate with segments10 segments
11–100 strings, poll for resultsBatch translation100 segments per job
Files (DOCX, TXT, CSV, XLSX)Document translation1,100 segments per file

Document translation

For files, use the async Document translation API. Upload a file, poll job status, and download the translated document.

Batch translation

For more than 10 short strings, use Batch translation. Send up to 100 segments in one async job and poll until results are ready.

Multiple segments

Use segments when you need up to 10 translations in one synchronous response. Each optional id is echoed in the response.

curl --fail-with-body "$MANSA_API_BASE_URL/v1/translate" \
  -H "Authorization: Bearer $MANSA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "from": "English",
  "to": "Swahili",
  "segments": [
    {
      "id": "1",
      "text": "Hello"
    },
    {
      "id": "2",
      "text": "How are you?"
    }
  ]
}'

Output

{
  "context": "ok",
  "data": {
    "segments": [
      {
        "id": "1",
        "text": "Hello",
        "translated_text": "Hujambo"
      },
      {
        "id": "2",
        "text": "How are you?",
        "translated_text": "Habari yako?"
      }
    ],
    "from": "English",
    "to": "Swahili"
  }
}

Glossary

Pass inline glossary entries to prefer specific term translations for this request. Saved glossary IDs (glossaryId) are not supported on the public API; send glossary inline or use Batch translation for the same inline shape on async jobs.

curl --fail-with-body "$MANSA_API_BASE_URL/v1/translate" \
  -H "Authorization: Bearer $MANSA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "text": "Hello",
  "from": "English",
  "to": "Swahili",
  "glossary": [
    {
      "term": "hello",
      "translation": "hujambo"
    }
  ]
}'

Output

{
  "context": "ok",
  "data": {
    "translation": "Hujambo"
  }
}

Tone

Use tone when you need a specific register. Omit it for the default natural style.

curl --fail-with-body "$MANSA_API_BASE_URL/v1/translate" \
  -H "Authorization: Bearer $MANSA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "text": "Please send the invoice today.",
  "from": "English",
  "to": "Yoruba",
  "tone": "formal"
}'

Output

{
  "context": "ok",
  "data": {
    "translation": "Jọwọ fi ìwé àjọ-owó ránṣẹ lónìí."
  }
}

Context

Pass context when a word could mean more than one thing.

curl --fail-with-body "$MANSA_API_BASE_URL/v1/translate" \
  -H "Authorization: Bearer $MANSA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "text": "The bank is closed.",
  "from": "English",
  "to": "Hausa",
  "tone": "precise",
  "context": "A river bank, not a financial institution."
}'

Output

{
  "context": "ok",
  "data": {
    "translation": "Gabar kogin ta rufe."
  }
}

Service status

GET /v1/translate/status returns { "status": "ok" } when the translation backend is available. Requires the same Bearer authentication as other /v1 endpoints.

curl --fail-with-body "$MANSA_API_BASE_URL/v1/translate/status" \
  -H "Authorization: Bearer $MANSA_API_KEY"

Output

{
  "context": "ok",
  "data": {
    "status": "ok"
  }
}

Supported languages

Stable languages

LanguageCodeLanguageCode
EnglishenSwahilisw
ArabicarAfrikaansaf
AmharicamHausaha
IgboigSomaliso
XhosaxhZuluzu
YorubayoKinyarwandarw
ShonasnTswanatn
ChichewanyLugandalg
MalagasymgOromoom
SesothostSepedinso
Tsongats

Beta languages

LanguageCodeLanguageCode
KirundirnNdebele (South)nr
SwatissTigrinyati
TwiakEweee
LingalalnKikongokg
BambarabmBembabem

Stable languages support translation between one another. Beta coverage is primarily available between English and the beta language.

Errors and billing

Unsupported languages and tones return invalid_request. Insufficient Mansa Credits return insufficient_credit. Successful translations debit Mansa Credits according to source character count (including all segment text when using segments). The rate is $0.10 per 1K characters ($100 per 1M) — see Pricing.