> 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/voice-message/upload-a-voice-message.md).

# Upload a Voice Message

Uploading a voice message (VMS) is available via the API. Uploading works for both landlines and mobiles. It is important to note that the behavior is different.

{% hint style="info" %}
As a reminder, on a mobile number the message is dropped directly on voicemail, whereas on a landline number, the phone rings and the message is only dropped if the recipient does not answer.
{% endhint %}

## URL

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

{% hint style="warning" %}
Limit: 5 requests per minute and 500 numbers max per request
{% 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>tokenAudio</code></td><td>Identifier of the audio file</td></tr><tr><td><code>emailForNotification</code></td><td>The end-of-campaign notification will be sent to this email address</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>sender</code></td><td>Mobile phone number that can be called back. This number must first be validated on the <a href="https://my.voicepartner.fr">my.voicepartner.fr</a> platform.</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 drops to be sent later.</td></tr><tr><td><code>notifyUrl</code></td><td>Callback URL for the campaign status, sent as GET</td></tr></tbody></table>

#### Requests

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

```php
<?php

// API URL to send the POST request to
$url = 'https://api.voicepartner.fr/v1/campaign/send';

// The data to send as JSON
$data = [
    'apiKey'            => 'YOUR_API_KEY', // Replace with your actual API key
    'tokenAudio'        => 'TOKEN_AUDIO',  // Replace with the actual audio token
    'emailForNotification' => 'email@example.com', // Replace with the desired notification email
    'phoneNumbers'      => '06xxxxxxxx',   // Replace with the actual phone number(s), comma-separated if needed
    // Add other optional parameters if needed
    // 'sender'         => 'YourNumber', // Optional
    // 'scheduledDate'  => 'YYYY-mm-dd H:i:s', // Optional
    // 'notifyUrl'      => 'https://your.notify.url', // Optional
];

// 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

Public Class UploadVoiceMessage
    Private Const ApiUrl As String = "https://api.voicepartner.fr/v1/campaign/send"
    Private Const ApiKey As String = "YOUR_API_KEY"
    Private Const TokenAudio As String = "YOUR_TOKEN_AUDIO"
    Private Const EmailForNotification As String = "your@mail.com"
    Private Const PhoneNumbers As String = "06XXXXXXXX"

    Public Shared Async Function SendCampaignAsync() As Task
        Using client As New HttpClient()
            Dim payload = New With {
                .apiKey = ApiKey,
                .tokenAudio = TokenAudio,
                .emailForNotification = EmailForNotification,
                .phoneNumbers = PhoneNumbers
            }
            Dim content = New StringContent(JsonConvert.SerializeObject(payload), Text.Encoding.UTF8, "application/json")

            Try
                Dim response = Await client.PostAsync(ApiUrl, content)
                If response.IsSuccessStatusCode Then
                    Dim responseContent = Await response.Content.ReadAsStringAsync()
                    ' Handle success
                    Console.WriteLine(responseContent)
                Else
                    ' Handle failure
                    Console.WriteLine($"Error: {response.StatusCode}")
                End If
            Catch ex As Exception
                ' Handle error
                Console.WriteLine($"Exception: {ex.Message}")
            End Try
        End Using
    End Function
End Class
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

# API URL to send the POST request to
url = 'https://api.voicepartner.fr/v1/campaign/send'

# The data to send as JSON
data = {
    'apiKey': 'YOUR_API_KEY',  # Replace with your actual API key
    'tokenAudio': 'TOKEN_AUDIO',  # Replace with the actual audio token
    'emailForNotification': 'email@example.com',  # Replace with the desired notification email
    'phoneNumbers': '06xxxxxxxx',  # Replace with the actual phone number(s)
    # Add other optional parameters if needed
    # 'sender': 'YourNumber',  # Optional
    # 'scheduledDate': 'YYYY-mm-dd H:i:s',  # Optional
    # 'notifyUrl': 'https://your.notify.url',  # Optional
}

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

# Execute the POST request with the JSON data
response = requests.post(url, json=data, 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 'https://api.voicepartner.fr/v1/campaign/send' \
     -H 'Content-Type: application/json' \
     -d '{
          "apiKey": "YOUR_API_KEY",
          "tokenAudio": "TOKEN_AUDIO",
          "emailForNotification": "email@example.com",
          "phoneNumbers": "06xxxxxxxx"
          // ... other parameters if needed
         }'
```

{% endtab %}

{% tab title="Nodejs" %}

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

// API URL to send the POST request to
const url = 'https://api.voicepartner.fr/v1/campaign/send';

// The data to send as JSON
const data = {
    apiKey: 'YOUR_API_KEY',
    tokenAudio: 'TOKEN_AUDIO',
    emailForNotification: 'email@example.com',
    phoneNumbers: '06xxxxxxxx'
    // ... 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.HttpResponse;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse.BodyHandlers;
import java.util.concurrent.CompletableFuture;

public class UploadVoiceMessage {

    public static void main(String[] args) {
        String url = "https://api.voicepartner.fr/v1/campaign/send";
        String json = """
                {
                    "apiKey": "YOUR_API_KEY",
                    "tokenAudio": "tokenAudio",
                    "emailForNotification": "email@example.com",
                    "phoneNumbers": "06XXXXXXXX"
                     // ... other parameters if needed
                }
                """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Content-Type", "application/json")
                .POST(BodyPublishers.ofString(json))
                .build();

        CompletableFuture future = client.sendAsync(request, BodyHandlers.ofString())
                .thenApply(HttpResponse::body)
                .thenAccept(System.out::println)
                .exceptionally(e -> {
                    System.out.println("Request error: " + e.getMessage());
                    return null;
                });

        // Use CompletableFuture.allOf to wait for all futures to complete.
        CompletableFuture.allOf(future).join();
    }
}
```

{% endtab %}

{% tab title="GO" %}

```go
package main

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

type Message struct {
	ApiKey               string  `json:"apiKey"`
	TokenAudio           string  `json:"tokenAudio"`
	EmailForNotification string  `json:"emailForNotification"`
	PhoneNumbers         string  `json:"phoneNumbers"`
	ScheduledDate        *string `json:"scheduledDate,omitempty"` // Optional, use pointer to omit if nil
	Sender               *string `json:"sender,omitempty"`        // Optional, use pointer to omit if nil
	NotifyUrl            *string `json:"notifyUrl,omitempty"`     // Optional, use pointer to omit if nil
	// Additional fields can be added here
}

func main() {
	url := "https://api.voicepartner.fr/v1/campaign/send"
	//scheduledDate := "2024-04-12 14:30:00"       // Example Date and Time
	//sender := "YourNumber"                       // Example sender number
	//notifyUrl := "https://yourdomain.com/notify" // Example notification URL

	data := Message{
		ApiKey:               "YOUR_API_KEY",
		TokenAudio:           "TOKEN_AUDIO",
		EmailForNotification: "email@exemple.com",
		PhoneNumbers:         "06xxxxxxxx",
		//ScheduledDate:        &scheduledDate, // Uncomment to use
		//Sender:               &sender,        // Uncomment to use
		//NotifyUrl:            &notifyUrl,     // 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 UploadVoiceMessage
{
    public static async Task Main()
    {
        var url = "https://api.voicepartner.fr/v1/campaign/send";

        // Set the date and time manually here
        //var scheduledDate = "2024-04-12 14:30:00"; // Format 'yyyy-MM-dd HH:mm:ss'
        //var sender = "YourNumber"; // Replace with your validated phone number
        //var notifyUrl = "https://yourdomain.com/notify"; // Your notification URL

        var data = new
        {
            apiKey = "YOUR_API_KEY",
            tokenAudio = "TOKEN_AUDIO",
            emailForNotification = "email@example.com",
            phoneNumbers = "06xxxxxxxx",
            // Add other optional parameters if needed
            //scheduledDate,
            //sender, // Mobile phone number that can be called back
            //notifyUrl // Callback URL for the campaign status, sent as GET
        };

        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": "campaignId",
    "cost": 0.15,
    "currency": "EUR",
    "nbSms": 1,
    "audioFile": {
        "filename": "filename.wav",
        "size": "135.8Ko"
    },
    "detail": {
        "33": {
            "nbSms": 1,
            "cost_unity": 0.15,
            "cost": 0.15
        }
    }
}
```

{% 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/voice-message/upload-a-voice-message.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.
