> For the complete documentation index, see [llms.txt](https://user.netmera.com/netmera-developer-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/sending-sms.md).

# Sending an SMS to a User

Add phone numbers to Netmera and send an SMS by notification key or by phone number.

This recipe shows how to add phone numbers to Netmera and send an SMS to a user, either with an SMS created in the Netmera panel or by phone number with the IYS message and recipient types.

## When to Use

This recipe fits one-to-one text messages that your system sends after an event, such as an order update or a verification message.

## Prerequisites

* REST API key of the application
* The `notificationKey` of an SMS notification created in the Netmera panel
* The external ID (`extId`) or the phone number of the recipient. Phone numbers must include the country code, for example `+90xxxxxxxxxx`.

## Step 1: Add the Phone Number to Netmera

If the recipient is not a Netmera user yet, upload the number with `addMsisdn`.

```bash
curl https://restapi.netmera.com/rest/3.0/addMsisdn \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-netmera-api-key: <API_KEY>' \
  --data '{
  "msisdnList": ["+90xxxxxxxxxx"]
}'
```

{% hint style="warning" %}
The country code is mandatory. Send numbers in the `+90xxxxxxxxxx` format.
{% endhint %}

If a user with the same MSISDN already exists, a new user is not created. A user created with `addMsisdn` has no installation ID. If the SDK later creates a user with the same MSISDN, the user created with `addMsisdn` is deleted, because the information from the SDK is considered primary.

**Expected result:** The number is available in Netmera as a recipient.

## Step 2: Send the SMS with a Notification Key

Call `sendNotification` with the `notificationKey` of the SMS created in the panel and the external ID of the user in `target.extId`.

```bash
curl https://restapi.netmera.com/rest/3.0/sendNotification \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-netmera-api-key: <API_KEY>' \
  --data '{
  "notificationKey": "3964",
  "target": {
    "extId": "user_1001"
  },
  "message": {
    "params": {}
  }
}'
```

**Expected result:** The request is sent with the key of the SMS created in the panel and the external ID of the recipient.

## Step 3: Send an SMS by Phone Number

To address the recipient by phone number, send the request to `sendEmailAndSms` with `SMS` in `platforms` and the number in `target.msisdn`.

```bash
curl https://restapi.netmera.com/rest/3.0/sendEmailAndSms \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-netmera-api-key: <API_KEY>' \
  --data '{
  "target": {
    "msisdn": "+90xxxxxxxxxx"
  },
  "platforms": ["SMS"],
  "title": "Order Update",
  "message": "Hello, your order is on its way.",
  "smsHeader": "NETMERA",
  "smsIysMessageType": "N",
  "smsIysRecipientType": "B"
}'
```

`smsIysMessageType` is `N` for a notification and `C` for a campaign. `smsIysRecipientType` is `B` for a personal recipient and `T` for a trader.

**Expected result:** The request is sent with the phone number, the SMS header, and the IYS types.

## Verification Checklist

* Phone numbers include the country code
* The `notificationKey` belongs to an SMS created in the Netmera panel
* `target` holds the external ID in `sendNotification` and the phone number in `sendEmailAndSms`
* `smsIysMessageType` and `smsIysRecipientType` are set to a documented value

## Related Pages

For the SMS request formats, see the SMS section of the [Notifications](/netmera-developer-guide/api-documentation/rest-api/notifications.md) page. For the IYS consent setup of your SMS provider, see the SMS Providers section of the integrations. To manage SMS permissions and number updates, see the [User & Device Management](/netmera-developer-guide/api-documentation/rest-api/user-and-device-management.md) page and the recipe [Managing Channel Permissions and Category Preferences](/netmera-developer-guide/api-documentation/recipes/managing-channel-and-category-preferences.md).


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/sending-sms.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
