---
title: "Sending SMS messages with the OVHcloud API in C#"
description: "Find out how to send SMS messages with the OVHcloud RESTful API in C#: create your API credentials, connect to the API, and send your first SMS"
url: https://docs.ovhcloud.com/en/guides/web-cloud/messaging/sms/sending-via-api-c
lang: en
lastUpdated: 2026-06-15
---
# Sending SMS messages with the OVHcloud API in C#

:::info
OVHcloud SMS offers are only available in the following countries: France, the United Kingdom, Ireland, Spain, Italy and Poland.
:::

## Objective

SMS messages are widely used to broadcast practical information, track the status of an order or a transactional process, be alerted to an unusual event, or remind people of appointments. This guide details the method for sending a first SMS with the OVHcloud API in C#.

**Find out how to send SMS messages with the OVHcloud RESTful API in C#.**

## Requirements

- A C# development environment.
- An OVHcloud account with SMS credits.
- A validated SMS sender.

## Instructions

### Calls to the API

We will implement the web service call directly in the code. For the sake of readability and simplicity, the API consumption part is neither factored out nor fully implemented (JSON deserialisation, etc.).

To implement the web service call, we recommend reading our guide on [getting started with the OVHcloud APIs](/en/guides/manage-and-operate/api/first-steps.md).

In this guide, we will call two methods:

- List of active SMS services:


[🇪🇺GET/sms](https://eu.api.ovh.com/console/?section=/sms&branch=v1#get-/sms)

- Send SMS messages:


[🇪🇺POST/sms/{serviceName}/jobs](https://eu.api.ovh.com/console/?section=/sms&branch=v1#post-/sms/-serviceName-/jobs)

### Creating credentials

API credentials are required to consume the SMS API; they are created individually to identify the application that will send SMS messages. The lifetime of these credentials is configurable.

Create your Script credentials (all keys at once) on this page: [https://auth.eu.ovhcloud.com/api/createToken](https://auth.eu.ovhcloud.com/api/createToken).

:::info
The following URL lets you automatically obtain the correct rights for this guide: [https://auth.eu.ovhcloud.com/api/createToken?GET=/sms/\&GET=/sms/_/jobs\&POST=/sms/_/jobs](https://auth.eu.ovhcloud.com/api/createToken?GET=/sms/\&GET=/sms/*/jobs\&POST=/sms/*/jobs).
:::

![creating the tokens](/images/web-cloud/messaging/sms/envoyer-des-sms-avec-lapi-ovh-en-c/sms-tokens-01.png)
In this simple example, we retrieve the rights to access the account information, the ability to view pending sends, and the ability to send SMS messages.

- GET /sms/
- GET/sms/\*/jobs
- POST /sms/\*/jobs

The asterisk (\*) enables calls to these methods for all your SMS accounts; you can restrict the calls to a single account if you manage several SMS accounts on your OVHcloud account.

Click `Create
` to retrieve the credentials for your script:
- Application Key (identifies your application)
- Application Secret (authenticates your application)
- Consumer Key (authorises the application to access the chosen methods)

![retrieving the tokens](/images/web-cloud/messaging/sms/envoyer-des-sms-avec-lapi-ovh-en-c/sms-tokens-02.png)
The environment is ready, the credentials are created, and you are ready to code your first API call.

### Basic connection to the API: retrieving the SMS account

We will now test the connection to the API by simply displaying the serviceName:

```bash
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Security.Cryptography;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            getSmsAccount();
        }

        //SHA1 calculation
        public static string HashSHA1(string sInputString)
        {
            SHA1 sha = new SHA1.Create();
            byte[] bHash = sha.ComputeHash(Encoding.UTF8.GetBytes(sInputString));
            StringBuilder sBuilder = new StringBuilder();

            for (int i = 0; i < bHash.Length; i++)
            {
                sBuilder.Append(bHash[i].ToString("x2"));
            }

            return sBuilder.ToString();
        }

        private static void getSmsAccount()
        {
            String AK = "your_app_key";
            String AS = "your_app_secret";
            String CK = "your_consumer_key";
            
            //Parameters of the called method
            String METHOD = "GET";
            String QUERY = "https://eu.api.ovh.com/1.0/sms/";
            String BODY = "";

            Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
            String TSTAMP = (unixTimestamp).ToString();

            //Signature calculation
            String signature = "$1$" + HashSHA1(AS + "+" + CK + "+" + METHOD + "+" + QUERY + "+" + BODY + "+" + TSTAMP);
            Console.WriteLine(signature);

            //Creating the request
            HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(QUERY);
            req.Method = METHOD;
            req.ContentType = "application/json";
            req.Headers.Add("X-Ovh-Application:" + AK);
            req.Headers.Add("X-Ovh-Consumer:" + CK);
            req.Headers.Add("X-Ovh-Signature:" + signature);
            req.Headers.Add("X-Ovh-Timestamp:" + TSTAMP);

            try
            {
                //Retrieving the call result
                HttpWebResponse myHttpWebResponse = (HttpWebResponse)req.GetResponse();
                using (var respStream = myHttpWebResponse.GetResponseStream())
                {
                    var reader = new StreamReader(respStream);
                    String result = reader.ReadToEnd().Trim();
                    Console.WriteLine(result);

                }
                myHttpWebResponse.Close();

            }
            //Exception handling
            catch (WebException e)
            {
                Console.WriteLine("Error : ");
                using (WebResponse response = e.Response)
                using (Stream data = ((HttpWebResponse)response).GetResponseStream())
                using (var reader = new StreamReader(data))
                {                
                     Console.WriteLine(reader.ReadToEnd());
                }
            }
        }
    }
}
```

When you launch this C# application, you should retrieve the list of your SMS accounts. We also display first the calculated signature of the request.

```bash
$1$c190e3e8d22399d11dcba599f782f9e11a016727
["sms-XX0000-1"]
```

### Sending the first SMS

To send SMS messages, we use the POST jobs method:


[🇪🇺POST/sms/{serviceName}/jobs](https://eu.api.ovh.com/console/?section=/sms&branch=v1#post-/sms/-serviceName-/jobs)

:::info
SMS response (short number via `senderForResponse`) is available in France only.
:::

The senderForResponse parameter allows you to use a short number, which lets you send SMS messages directly without having to create a sender (e.g. your name).
Short numbers also make it possible to receive responses from the people who received the SMS, which can be useful for a satisfaction survey, a voting application, a game, etc.

```bash
private void sendSms()
        {
            String AK = "your_app_key";
            String AS = "your_app_secret";
            String CK = "your_consumer_key";

            //Parameters of the called method
            String ServiceName = "sms-XX00000-1";
            String METHOD = "POST";
            String QUERY = "https://eu.api.ovh.com/1.0/sms/"+ServiceName+"/jobs";
            String BODY =@"{ ""charset"": ""UTF-8"", ""receivers"": [ ""+33660000000"" ], ""message"": ""Test SMS OVH"", ""priority"": ""high"",  ""senderForResponse"": true, ""sender"": ""YOURSENDER""}";

            Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
            String TSTAMP = (unixTimestamp).ToString();
            

            String signature = "$1$" + HashSHA1(AS + "+" + CK + "+" + METHOD + "+" + QUERY + "+" + BODY + "+" + TSTAMP);
            Console.WriteLine(signature);

            //Creating the request
            HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(QUERY);
            req.Method = METHOD;
            req.ContentType = "application/json";
            req.Headers.Add("X-Ovh-Application:"+ AK);
            req.Headers.Add("X-Ovh-Consumer:" + CK);
            req.Headers.Add("X-Ovh-Signature:"+ signature);
            req.Headers.Add("X-Ovh-Timestamp:" + TSTAMP);
       
            //Writing the BODY parameters
            using (System.IO.Stream s = req.GetRequestStream())
            {
                using (System.IO.StreamWriter sw = new System.IO.StreamWriter(s))
                    sw.Write(BODY);
            }

            try
            {
                //Retrieving the call result
                HttpWebResponse myHttpWebResponse = (HttpWebResponse)req.GetResponse();
                String[] l = null;
                using (var respStream = myHttpWebResponse.GetResponseStream())
                {
                    var reader = new StreamReader(respStream);
                    String result = reader.ReadToEnd().Trim();
                    Console.WriteLine(result);
                                  
                } 
                myHttpWebResponse.Close();
                
            }
            catch (WebException e)
            {
                Console.WriteLine("Error : ");
                Console.WriteLine("Error : ");
                using (WebResponse response = e.Response)
                using (Stream data = ((HttpWebResponse)response).GetResponseStream())
                using (var reader = new StreamReader(data))
                {                
                     Console.WriteLine(reader.ReadToEnd());
                }
            }
        }
```

Here is the type of response expected:

```bash
$1$e591c367cebc15b1fe7f9a50d792602824a52e78
{"totalCreditsRemoved":1,"invalidReceivers":[],"ids":[27814656],"validReceivers":["+33600000000"]}
```

We get a response with 1 credit consumed for a valid number. The default message includes the STOP message that allows recipients to unsubscribe.
You can disable the STOP via the `noStopClause` parameter. Note that with the STOP, you cannot send SMS messages between 8pm and 8am.

## Go further

The [API console](https://api.ovh.com/console/?section=%2Fsms\&branch=v1) will let you discover other methods to facilitate the integration of services such as: SMS responses, bulk sending with a CSV file, mail merge, delivery receipt tracking, etc.

Talk to our [community of users](https://community.ovhcloud.com/).
