Skip to main content

Txt2Voice API (1.0.0)

Download OpenAPI specification:Download

Spirius Support: support@spirius.com License: Proprietary

Txt2Voice API

Text-to-speech delivered as phone calls. Submit a text message and a recipient phone number. The service converts the text to natural-sounding speech and delivers it as an automated voice call.

Base URL

All endpoints are relative to:

https://api.spirius.com/txt2voice

Features

  • Natural-sounding speech in 43 languages across 45 BCP 47 tags (English and Portuguese each have two regional variants)
  • Automatic translation: text written in another language is spoken in the selected language (e.g. Swedish text with language: de is read in German)
  • Delivery style controlled with plain-language instructions; no markup needed
  • Male or female voice selection via the gender field
  • Message status queries: GET /v1/messages/{transaction_id}
  • Automatic reattempts on unanswered or busy calls (final delivery report after the last attempt. Allow around 5 minutes before treating a message as undelivered)
  • Optional voicemail detection (machine_detection, default off): playback waits for an answering-machine greeting to end so the recorded message is complete; adds a few seconds of delay after a human answers
  • Delivery report webhooks with retry
  • Simple HTTP endpoint for easy integration

Caller ID

The caller ID (sender) shown to the recipient is resolved from the first available of these, in priority order:

  1. The sender field in the request.
  2. The account's configured default sender.
  3. The Spirius default sender ID.

So a request that sends no sender and whose account has no configured default falls back to the Spirius default sender ID. Caller IDs are phone numbers in strict E.164 format. Client-specific caller IDs (the request sender and the account's configured default) must be registered with Spirius before use; the Spirius default sender ID is always available and needs no registration. A request with an unregistered sender is rejected immediately (HTTP 422 on the REST API, request=false on the Simple HTTP interface) with instructions. To register a number, contact Spirius support. Alphanumeric SMS sender IDs cannot be used for voice calls. For calls to Swedish destinations, the caller ID must additionally be a number provisioned through Spirius (Swedish anti-spoofing regulation); contact support to set one up.

Voice Instructions (REST)

The REST endpoint does not use SSML or prosody markup. Instead, pass an optional instructions field describing in plain language how the text should be spoken:

{
  "to": "+46701234567",
  "text": "Välkommen till Spirius! Vi ser fram emot att hjälpa dig.",
  "language": "sv",
  "instructions": "Läs med en varm och välkomnande röst."
}

More examples:

A one-time code, read slowly and clearly:

{
  "to": "+46701234567",
  "text": "Din pin kod är 7 9 5 2",
  "language": "sv",
  "instructions": "Read the code slowly and clearly."
}

A service alert:

{
  "to": "+46701234567",
  "text": "This is an alert. Your server is unreachable.",
  "language": "en-US",
  "instructions": "Speak in a professional tone."
}

The instructions may be written in any language and are interpreted independently of the message language; they shape how the message is spoken and are not read aloud. Put the words you want spoken in text; keep instructions to delivery guidance only. For the most reliable results we recommend writing instructions in English or in the message's spoken language.

Keep instructions simple and focused on delivery, as in the examples above. A single clear direction works best; stacking several emotional cues tends to push the voice too far and sound unnatural. Start from a tested phrasing and experiment from there.

Reading Numbers and Codes

How you separate numbers controls how they are read.

One digit at a time (codes, PINs). Separate the digits with spaces:

  • "Your code is 4 7 1 1""four, seven, one, one"
  • "Your code is 4711" (no separators) → "four thousand seven hundred eleven"

Mixing single and multi-digit numbers. Separate every value with a comma and a space. A space alone is enough when every value is a single digit, but with multi-digit values a comma is needed so they are read as whole numbers rather than individual digits. Comma-and-space always works, so prefer it:

  • "2, 4, 98, 25""two, four, ninety-eight, twenty-five"

Decimal numbers. Always use a dot as the decimal separator; it is read correctly regardless of the selected language (a comma would be treated as a value separator instead):

  • "2.50, 7.95, 4.55""two point five zero, seven point nine five, four point five five"

Supported Languages

The REST language field takes a BCP 47 tag. English and Portuguese require the regional variant (en-US/en-GB, pt-PT/pt-BR); every other language uses the bare tag. Codes are case-insensitive and the default is en-GB.

language selects the spoken language. Text written in a different language is automatically translated to it before it is spoken — for example "Välkommen till Spirius" with language: de is read in German ("Willkommen bei Spirius").

Automatic translation can be imperfect and may reword, alter, or drop details — including digits. For messages that must be delivered exactly — PIN codes, one-time passwords, reference numbers — write the text in the intended spoken language and set language to match, so the wording and numbers are preserved. Translation is a convenience for free-form text, not a guarantee of accuracy.

Code Language
af Afrikaans
ar Arabic
bg Bulgarian
bn Bengali
ca Catalan
cs Czech
da Danish
de German
el Greek
en-GB English (UK)
en-US English (US)
es Spanish
et Estonian
fi Finnish
fr French
gu Gujarati
he Hebrew
hi Hindi
hr Croatian
hu Hungarian
id Indonesian
it Italian
ja Japanese
ko Korean
lt Lithuanian
lv Latvian
mr Marathi
ms Malay
nl Dutch
no Norwegian
pl Polish
pt-BR Portuguese (Brazil)
pt-PT Portuguese (Portugal)
ro Romanian
ru Russian
sk Slovak
sl Slovenian
sv Swedish
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
vi Vietnamese
zh Chinese

Authentication

The account must have the Txt2Voice API permission enabled.

  • POST /v1/messages (REST): HTTP Basic Auth (Authorization header).
  • GET /v1/sendtts (Simple HTTP): credentials via User and Pass query parameters.

Message Flow

  1. Submit message via POST /v1/messages or GET /v1/sendtts
  2. Receive 202 Accepted with a TransactionId
  3. Service generates audio, initiates phone call
  4. On call completion, delivery report sent to configured webhook URL

Unanswered or busy calls are automatically reattempted (2 reattempts at 2-minute intervals); the delivery report is sent once, after the final attempt.

Message Status

GET /v1/messages/{transaction_id} returns the current state of a transaction (Basic auth, same credentials as sending):

{
  "transaction_id": "fa7a2ada-d3d4-4c93-a125-fec9ecd84f92",
  "status": "completed",
  "created": "2026-07-13T09:36:08Z",
  "duration_seconds": 24,
  "failure_code": null
}

status is accepted (in progress, including the retry window), completed (delivered; duration_seconds set) or failed (failure_code set: 1 = call could not be delivered, 5 = internal error). Unknown transaction ids return 404.

Simple HTTP Interface (legacy)

GET /v1/sendtts is the drop-in replacement for the previous Txt2Voice service; existing integrations only change the host name. New integrations should use POST /v1/messages instead; this interface exists for migration and will eventually be deprecated.

Query parameters (all values URI-encoded; names are case sensitive):

Parameter Required Description
User yes Account username.
Pass yes Account password.
To yes Recipient MSISDN. International format with + (e.g. +46701234567); 00-prefixed international and 0-prefixed Swedish national numbers are also accepted.
Msg yes The message text. May contain <break time='100ms'/> pause markup and <prosody> tags from the previous service; they are honored. Malformed XML is rejected with 400.
Lang no Language code, one of: SE, NO, DK, FI, EN, DE, FR, ES, IT, NL, PT, BR, PL, RU, GR. Default EN.
From no Caller ID (same rules as the REST sender: registered E.164 number). Defaults to the account's configured sender.
ExternalReferenceId no Client reference echoed in delivery reports.

Success response (HTTP 202):

request=true&TransactionId=fa7a2ada-d3d4-4c93-a125-fec9ecd84f92

Failure response (HTTP 200 with request=false, or HTTP 400 for malformed parameters):

request=false&error=Unsupported language: XX

Examples:

GET /txt2voice/v1/sendtts?User=myuser&Pass=mypassword&To=%2B46701234567&Msg=Hello+world
GET /txt2voice/v1/sendtts?User=myuser&Pass=mypassword&To=%2B46701234567&Lang=SE&Msg=Din+kod+%C3%A4r+4+7+2+9

The second example sends "Din kod är" followed by the digits 4 7 2 9. Writing digits with spaces between them makes the voice read them one by one.

Delivery Reports

Reports are delivered via HTTP GET to the account's configured DLR URL with query parameters TransactionId, Result, StatusCode, ProgressTime (listened seconds), Sequence (always end, the final report), and ExternalReferenceId. The format is identical to the previous Txt2Voice service:

Result=1&StatusCode=1&Sequence=end&TransactionId=fa7a2ada-d3d4-4c93-a125-fec9ecd84f92&ProgressTime=24
Result StatusCode Meaning
1 1 Message delivered.
2 1 Message could not be delivered (no answer after all attempts, busy, rejected).
2 5 Internal error.

If the DLR URL is temporarily unreachable, delivery is retried for a limited period; if it stays unreachable, delivery is suspended and the reports are no longer sent (you can still query each transaction's outcome with GET /v1/messages/{transaction_id}). Keep your DLR endpoint reachable and returning a 2xx status. For an unanswered call the report arrives after the last call reattempt (up to ~5 minutes after submission).

Health

Health Check

Responses

Response samples

Content type
application/json
{
  • "status": "ok"
}

Send Message (REST)

Send Message

Authorizations:
HTTPBasic
Request Body schema: application/json
required
to
required
string

Destination phone number in strict E.164 format, e.g. +46701234567.

text
required
string [ 1 .. 5000 ] characters

The text to speak.

Numbers and codes: digits separated by spaces are read out one by one. 4 7 1 1 is spoken as "four, seven, one, one", while 4711 is spoken as "four thousand seven hundred eleven". No pause or delay markup is needed between digits.

SSML is not supported; use instructions to control delivery style.

language
string
Default: "en-GB"
Enum: "sv" "no" "da" "fi" "en-GB" "en-US" "de" "fr" … 37 more

Spoken language as a BCP 47 tag (sv, da, de, en-US, pt-BR). 43 languages are supported through 45 tags: English (en-US, en-GB) and Portuguese (pt-PT, pt-BR) require the regional variant; all other languages use the bare tag. Case-insensitive. Defaults to en-GB. Text written in another language is automatically translated to this language before it is spoken; translation can be imperfect, so for exact content such as PIN codes send the text already in this language. See the Supported Languages table in the API overview for the full list of codes and names.

string or null

Optional natural-language delivery instructions for the speech engine, describing how the text should be spoken. Instructions shape delivery only and are not read aloud; put the words to be spoken in text. For the most reliable results, write instructions in English or in the message's spoken language.

Examples:

  • "Read with a warm, welcoming tone."
  • "Speak slowly and clearly, as if dictating to someone taking notes."
  • "Sound cheerful and energetic."
  • "Use a calm, reassuring voice."
  • "Whisper."

This replaces SSML/prosody markup: instead of <prosody rate="slow">, write "Read slowly."

Any of
<= 500 characters
string <= 500 characters

Optional natural-language delivery instructions for the speech engine, describing how the text should be spoken. Instructions shape delivery only and are not read aloud; put the words to be spoken in text. For the most reliable results, write instructions in English or in the message's spoken language.

Examples:

  • "Read with a warm, welcoming tone."
  • "Speak slowly and clearly, as if dictating to someone taking notes."
  • "Sound cheerful and energetic."
  • "Use a calm, reassuring voice."
  • "Whisper."

This replaces SSML/prosody markup: instead of <prosody rate="slow">, write "Read slowly."

string or null

Voice for the spoken message: male or female. When omitted, a male voice is used.

Any of
string
Enum: "male" "female"

Voice gender selectable on the REST API (/v1/messages).

string or null

Caller ID shown to the recipient, in strict E.164 format (e.g. +46701234567). The number must be registered with Spirius before use. Requests with an unregistered sender are rejected immediately (422) with instructions. When omitted, the account's configured default sender is used, or the service default caller ID if the account has none. Alphanumeric SMS sender IDs cannot be used for voice calls.

Any of
string

Caller ID shown to the recipient, in strict E.164 format (e.g. +46701234567). The number must be registered with Spirius before use. Requests with an unregistered sender are rejected immediately (422) with instructions. When omitted, the account's configured default sender is used, or the service default caller ID if the account has none. Alphanumeric SMS sender IDs cannot be used for voice calls.

integer or null

How many times the message audio is played during the call. Defaults to 3 times.

Any of
[ 1 .. 10 ]
integer [ 1 .. 10 ]

How many times the message audio is played during the call. Defaults to 3 times.

string or null

Client-supplied reference echoed back in delivery reports.

Any of
string

Client-supplied reference echoed back in delivery reports.

machine_detection
boolean
Default: false

Optional answering-machine detection. Enabled, the call waits out an answering-machine greeting so the message lands intact on the recording. This adds a few seconds of delay after a human answers and requires the callee to speak when answering. Disabled (the default), playback starts immediately when the call is answered.

Responses

Request samples

Content type
application/json
{
  • "instructions": "Read slowly and clearly, with a calm tone.",
  • "language": "en-US",
  • "text": "Your verification code is 4 7 1 1.",
  • "to": "+46701234567"
}

Response samples

Content type
application/json
{
  • "transaction_id": "string",
  • "status": "accepted"
}

Message Status

Get message status

Returns the current state of a transaction: accepted (in progress, including automatic reattempts), completed (delivered) or failed. Unknown transaction ids return 404.

Authorizations:
HTTPBasic
path Parameters
transaction_id
required
string (Transaction Id)

Responses

Response samples

Content type
application/json
{
  • "transaction_id": "string",
  • "status": "string",
  • "created": "2019-08-24T14:15:22Z",
  • "duration_seconds": 0,
  • "failure_code": 0
}

Send Message (Simple HTTP)

Send a voice message (legacy interface)

Drop-in replacement for the previous Txt2Voice service — existing integrations only change the host name. Responds with request=true&TransactionId=... on success and request=false&error=... on failure. New integrations should use POST /messages.

query Parameters
User
required
string (User)

Account username.

Pass
required
string (Pass)

Account password.

To
required
string (To)

Recipient MSISDN. International format with + (e.g. +46701234567); 00-prefixed international and 0-prefixed Swedish national numbers are also accepted.

Msg
required
string (Msg)

The message text. <break time='100ms'/> pause markup and <prosody> tags from the previous service are honored; malformed XML is rejected with 400.

Lang
string (Lang)
Default: "EN"

Language code: SE, NO, DK, FI, EN, DE, FR, ES, IT, NL, PT, BR, PL, RU, GR. Default EN.

From (string) or From (null) (From)

Caller ID — a registered E.164 number. Defaults to the account's configured sender.

Externalreferenceid (string) or Externalreferenceid (null) (Externalreferenceid)

Client reference echoed in delivery reports.

Responses

Response samples

Content type
application/json
{
  • "detail": [
    ]
}