> For the complete documentation index, see [llms.txt](https://www.docpartner.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.docpartner.dev/en/api/voice-partner/send-a-voice-sms.md).

# Send a Voice SMS

This request is used to send a Voice SMS to a mobile phone

## URL

<mark style="color:green;">`POST`</mark> `https://api.voicepartner.fr/v1/tts/send`

{% hint style="warning" %}
Limit: 2000 requests per hour
{% endhint %}

#### **Required Parameters**

<table data-full-width="false"><thead><tr><th width="232">Name</th><th>Value</th></tr></thead><tbody><tr><td><code>apiKey</code></td><td><a href="https://my.voicepartner.fr/app/api">Your API key</a></td></tr><tr><td><code>text</code></td><td>Text of the voice message. <a href="#pause-between-words">A pause between words is possible</a>.</td></tr><tr><td><code>tokenAudio</code></td><td>Identifier of the audio file; the "text" parameter will not be taken into account</td></tr><tr><td><code>lang</code></td><td>The language the message is sent in</td></tr><tr><td><code>phoneNumbers</code></td><td><p>Recipients' mobile phone numbers.<br>To send multiple messages, the numbers must be separated by commas.<br>They can be:</p><ul><li>in national format (06xxxxxxxx) or international format (+336xxxxxxxx), for French numbers.</li></ul></td></tr></tbody></table>

#### **Optional Parameters**

<table><thead><tr><th width="262">Name</th><th>Value</th></tr></thead><tbody><tr><td><code>speechRate</code></td><td>The speech rate of the message. Only effective when using text. The supported range is from 0.5 (slowed down speech) to 2 (sped up speech). Values below 0.5 will be replaced with 0.5 and values above 2 will be replaced with 2. The default speed is 1.</td></tr><tr><td><code>notifyUrl</code></td><td>Callback URL for the status of the sent voice SMS, sent as POST in JSON format</td></tr><tr><td><code>scheduledDate</code></td><td>Send date of the message, in <code>YYYY-mm-dd H:m:00</code> format (e.g. <code>2021-02-02 14:15:00</code>). Only set this if you want the SMS to be sent later.</td></tr><tr><td><code>audioComplementary</code></td><td>Identifier of the audio file that will be dropped if the recipient does not answer.</td></tr></tbody></table>

#### Pause between words

{% hint style="info" %}
It is possible to add pauses between words and extend the duration of the voice message by using the comma «,».\
For example, if you want a 3-second pause after each word, the text parameter should look like this: «one ,,,,,, two ,,,,,, three ,,,,,,». Each comma creates a **0.5-second pause**.
{% endhint %}

#### Requests

{% tabs %}
{% tab title="PHP" %}

```php
<?php

// Enable error display for debugging
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// The API URL to send the voice message
$url = 'http://api.voicepartner.fr/v1/tts/send';

// The data to send as JSON
$data = [
    'apiKey' => 'YOUR_API_KEY',         // Replace with your actual API key
    'phoneNumbers' => '06XXXXXXXX',     // Replace with the actual phone number(s)
    'text' => 'My first test',          // Replace with the text you want to convert to speech
    // 'speed' => '1',                  // Optional: Speech rate
    // 'notifyUrl' => 'http://...',     // Optional: Notification URL
    // 'scheduledDate' => 'YYYY-mm-dd H:i:00', // Optional: Scheduled send date
];

// Encode the data as JSON
$data_json = json_encode($data);

// Initialize cURL
$curl = curl_init($url);

// Configure cURL options to send JSON
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_json);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Cache-Control: no-cache'
));

// Execute the cURL request and store the response
$response = curl_exec($curl);

// Check whether an error occurred during the request
if (curl_errno($curl)) {
    echo 'cURL Error: ' . curl_error($curl);
} else {
    // Display the response
    echo 'Response: ' . $response;
}

// Close the cURL session
curl_close($curl);
```

{% endtab %}

{% tab title="VB.net" %}

```vbnet
Imports System.Net.Http
Imports System.Threading.Tasks
Imports Newtonsoft.Json
Imports System.Text

Public Class SendVoiceSms
    Private Const Url As String = "http://api.voicepartner.fr/v1/tts/send"

    Public Shared Async Function SendSmsVocalAsync() As Task
        Using client As New HttpClient()
            ' Replace these values with your own
            Dim apiKey As String = "YOUR_API_KEY"
            Dim phoneNumbers As String = "06XXXXXXXX"
            Dim text As String = "My first test"
            ' ... other parameters if needed

            Dim data = New With {
                .apiKey = apiKey,
                .phoneNumbers = phoneNumbers,
                .text = text
            }

            Dim jsonContent = JsonConvert.SerializeObject(data)
            Using content As New StringContent(jsonContent, Encoding.UTF8, "application/json")
                Try
                    Dim response = Await client.PostAsync(Url, content)
                    Dim responseContent = Await response.Content.ReadAsStringAsync()

                    If response.IsSuccessStatusCode Then
                        Console.WriteLine(responseContent)
                    Else
                        Console.WriteLine($"Request error: {response.StatusCode}")
                        Console.WriteLine($"Content: {responseContent}")
                    End If
                Catch ex As Exception
                    Console.WriteLine($"Exception: {ex.Message}")
                End Try
            End Using
        End Using
    End Function
End Class
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

# Enable error display for debugging
# In Python, errors are displayed by default when they occur.

# The API URL to send the voice message
url = 'http://api.voicepartner.fr/v1/tts/send'

# The data to send as JSON
data = {
    'apiKey': 'YOUR_API_KEY',  # Replace with your actual API key
    'phoneNumbers': '06XXXXXXXX',  # Replace with the actual phone number(s)
    'text': 'My first test',  # Replace with the text you want to convert to speech
    # 'speed': '1',  # Optional: Speech rate
    # 'notifyUrl': 'http://...',  # Optional: Notification URL
    # 'scheduledDate': 'YYYY-mm-dd H:i:00',  # Optional: Scheduled send date
}

# Encode the data as JSON
data_json = json.dumps(data)

# Configure HTTP headers
headers = {
    'Content-Type': 'application/json',
    'Cache-Control': 'no-cache'
}

# Execute the POST request with the JSON data
response = requests.post(url, data=data_json, headers=headers)

# Check whether an error occurred during the request
if response.status_code != 200:
    print(f'cURL Error: {response.status_code}')
else:
    # Display the response
    print(f'Response: {response.text}')
```

{% endtab %}

{% tab title="cURL" %}

```
curl -X POST 'http://api.voicepartner.fr/v1/tts/send' \
     -H 'Content-Type: application/json' \
     -H 'Cache-Control: no-cache' \
     -d '{
          "apiKey": "YOUR_API_KEY",
          "phoneNumbers": "06XXXXXXXX",
          "text": "My first test"
          // "speed": "1", // Optional
          // "notifyUrl": "http://...", // Optional
          // "scheduledDate": "YYYY-mm-dd H:i:00" // Optional
         }'
```

{% endtab %}

{% tab title="Nodejs" %}

```javascript
const axios = require('axios');

// The API URL to send the voice message
const url = 'http://api.voicepartner.fr/v1/tts/send';

// The data to send as JSON
const data = {
    apiKey: 'YOUR_API_KEY',
    phoneNumbers: '06XXXXXXXX',
    text: 'My first test'
    // ... other parameters if needed
};

axios.post(url, data)
    .then(response => {
        console.log(response.data);
    })
    .catch(error => {
        console.error('Request error:', error);
    });
```

{% endtab %}

{% tab title="JAVA" %}

```java
package com.example.API;

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse.BodyHandlers;

public class SendVoiceSms {
    public static void main(String[] args) {
        // The API URL
        String apiUrl = "https://api.voicepartner.fr/v1/tts/send";

        // The data to send as JSON
        String json = """
                {
                    "apiKey": "YOUR_API_KEY",
                    "phoneNumbers": "06XXXXXXXX",
                    "text": "My first test",
                    "speechRate": "1",
                    "notifyUrl": "http://example.com/notify",
                }
                """;

        // Create an HttpClient instance
        HttpClient client = HttpClient.newHttpClient();

        // Build the request
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(apiUrl))
                .header("Content-Type", "application/json")
                .POST(BodyPublishers.ofString(json))
                .build();

        // Send the request asynchronously
        client.sendAsync(request, BodyHandlers.ofString())
                .thenApply(response -> response) // Return the whole response object
                .thenAccept(response -> {
                    // Now you can call methods on the HttpResponse object
                    System.out.println("Status Code: " + response.statusCode());
                    System.out.println("Response: " + response.body());
                })
                .exceptionally(e -> {
                    e.printStackTrace(); // Print the stack trace in case of error
                    return null;
                })
                .join(); // Wait for the asynchronous operation to finish
    }
}
```

{% endtab %}

{% tab title="GO" %}

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)

type SmsData struct {
	ApiKey        string   `json:"apiKey"`
	Text          string   `json:"text"`
	PhoneNumbers  string   `json:"phoneNumbers"`
	Lang          *string  `json:"lang,omitempty"`          // Optional: Language of the SMS
	SpeechRate    *float64 `json:"speechRate,omitempty"`    // Optional: Rate of the speech
	NotifyUrl     *string  `json:"notifyUrl,omitempty"`     // Optional: Notification URL
	ScheduledDate *string  `json:"scheduledDate,omitempty"` // Optional: Scheduled date and time
}

func main() {
	url := "http://api.voicepartner.fr/v1/tts/send"
	//lang := "fr"
	//speechRate := 1.0
	//notifyUrl := "https://yourdomain.com/notify"
	//scheduledDate := "2024-04-12 14:30:00" // Example format: 'yyyy-MM-dd HH:mm:ss'

	data := SmsData{
		ApiKey:       "YOUR_API_KEY",
		Text:         "Your text here",
		PhoneNumbers: "06XXXXXXXX",
		//Lang:         &lang,                  // Uncomment to use
		//SpeechRate:   &speechRate,            // Uncomment to use
		//NotifyUrl:    &notifyUrl,             // Uncomment to use
		//ScheduledDate: &scheduledDate,        // Uncomment to use
	}

	payloadBytes, err := json.Marshal(data)
	if err != nil {
		fmt.Printf("Error: %s\n", err.Error())
		return
	}
	body := bytes.NewReader(payloadBytes)

	req, err := http.NewRequest("POST", url, body)
	if err != nil {
		fmt.Printf("Error: %s\n", err.Error())
		return
	}
	req.Header.Set("Content-Type", "application/json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		fmt.Printf("Error: %s\n", err.Error())
		return
	}
	defer resp.Body.Close()

	respBody, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		fmt.Printf("Error: %s\n", err.Error())
		return
	}

	fmt.Printf("Response: %s\n", string(respBody))
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
using Newtonsoft.Json;
using System.Text;

public class SendVoiceSms
{
    public static async Task Main()
    {
        var url = "http://api.voicepartner.fr/v1/tts/send";
        //var scheduledDate = "2024-04-12 10:30:00"; // Format 'yyyy-MM-dd HH:mm:ss'

        var data = new
        {
            apiKey = "YOUR_API_KEY",
            text = "Your text here",
            phoneNumbers = "06XXXXXXXX",
            // Add other optional parameters if needed
            //speechRate = 1.0, // The default speed is 1
            //notifyUrl = "https://yourdomain.com/notify",
            //scheduledDate
        };

        using (var client = new HttpClient())
        {
            try
            {
                var json = JsonConvert.SerializeObject(data);
                var content = new StringContent(json, Encoding.UTF8, "application/json");
                var response = await client.PostAsync(url, content);
                var responseContent = await response.Content.ReadAsStringAsync();
                Console.WriteLine("Response: " + responseContent);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### **Response**

{% tabs %}
{% tab title="json" %}

```json
{
    "success": true,
    "campaignId": "Ff1tbu0lax",
    "cost": xxx,
    "currency": "EUR",
    "nbSms": 1,
    "lang": "en",
    "duration": 6.3,
    "detail": {
        "33": {
            "nbSms": 1,
            "cost_unity": xxx,
            "cost": xxx,
            "country_code": "fr",
            "duration": 6.3
        }
    }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://www.docpartner.dev/en/api/voice-partner/send-a-voice-sms.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
