# Messaging Channels

To support Messaging Channels for Identities you must enable [Infobip CDP Extension](https://docs.orangepill.cloud/extensions/infobip-people-cdp). Messging Channel for Users are supported by default.

{% hint style="info" %}
Messeges to Users are always sent from Orangepill, while messages to Persons are sent from your Infobip account.
{% endhint %}

## Send SMS

Use [v1/apps/message/sms](https://api.orangepill.cloud/openapi/ui#/v1.apps.message/post_v1_apps_message__channel_)  APi call to send SMS message. The Message is sent to the phone number set in the `to` field

{% hint style="info" %}
You can use this APi call to send an SMS message to a recipient that's not on-boarded on the Orangepill platform.
{% endhint %}

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

```shell

curl --location --request POST 'https://api.orangepill.cloud/v1/apps/message/sms' \
--header 'x-api-key: AXVubzpwQDU1dzByYM==' \
--header 'idempotency-key: 27373fabc392933deffda' \
--header 'Content-Type: application/json' \
--data-raw '{
    "to":"38598123456",
    "content":{
      "text":  "My text message",
    }
}'
```

{% endtab %}
{% endtabs %}

in response you will get message processing status.&#x20;

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

```json
{
    "messages": [
        {
            "messageId": "3919977727444335893722",
            "status": {
                "groupId": 1,
                "groupName": "PENDING",
                "id": 26,
                "name": "PENDING_ACCEPTED",
                "description": "Message sent to next instance"
            },
            "destination": "38598123456"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Send WhatsApp

Use [v1/apps/message/whatsapp](https://api.orangepill.cloud/openapi/ui#/v1.apps.message/post_v1_apps_message__channel_)  APi call to send a WhatsApp message. The Message is sent to phone number set in the `to` field

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

```shell

curl --location --request POST 'https://api.orangepill.cloud/v1/apps/message/whatsapp' \
--header 'x-api-key: AXVubzpwQDU1dzByYM==' \
--header 'idempotency-key: 27373fabc392933deffda' \
--header 'Content-Type: application/json' \
--data-raw '{
    "to":"38598123456",
    "content":{
        "templateName": "transaction_successful_v5_es",
        "templateData": {
            "body": {
                "placeholders": [
                    "DataPlan 100MB Daily (24 Hours)"
                ]
            }
        },
        "language": "es"
    }
}'
```

{% endtab %}
{% endtabs %}

in response you will get message processing status.&#x20;

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

```json
{
    "messages": [
        {
            "messageId": "3919977727444335893722",
            "status": {
                "groupId": 1,
                "groupName": "PENDING",
                "id": 26,
                "name": "PENDING_ACCEPTED",
                "description": "Message sent to next instance"
            },
            "destination": "38598123456"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Send Email

Use [v1/apps/message/email](https://api.orangepill.cloud/openapi/ui#/v1.apps.message/post_v1_apps_message__channel_)  APi call to send a email message. The Email is sent to the address set in the `to` field

{% hint style="info" %}
You can send email messages in text ot html body format. If both parameters are set, message is sent in html format.
{% endhint %}

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

```shell

curl --location --request POST 'https://api.orangepill.cloud/apps/message/email' \
--header 'x-api-key: AXVubzpwQDU1dzByYM==' \
--header 'idempotency-key: 27373fabc392933deffda' \
--header 'Content-Type: application/json' \
--data-raw '{
    "to":"user@orangepill.cc",
    "content": {
        "subject": "This is a test subject",
        "html": "<b>This is test html email message</b>",
        "text": "This is test text email message"
    }
}'
```

{% endtab %}
{% endtabs %}

in response you will get message processing status.&#x20;

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

```json
{
    "messages": [
        {
            "messageId": "3919977727444335893722",
            "status": {
                "groupId": 1,
                "groupName": "PENDING",
                "id": 26,
                "name": "PENDING_ACCEPTED",
                "description": "Message sent to next instance"
            },
            "destination": "user@orangepill.cc"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Send SMS to User

Use [/v1/users/{id}/message/sms](https://api.orangepill.cloud/openapi/ui#/v1.users/post_v1_users__id__message__channel_) APi call to send an SMS message. The Message is sent to the phone number set in the `channel.sms` field of [User](https://docs.orangepill.cloud/orangepill-api/identities-and-users) object.

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

```shell

curl --location --request POST 'https://api.orangepill.cloud/v1/users/634b56217f6a7b0be52dffbd/message/sms' \
--header 'x-api-key: AXVubzpwQDU1dzByYM==' \
--header 'idempotency-key: 27373fabc392933deffda' \
--header 'Content-Type: application/json' \
--data-raw '{
    "content": {
        "text": "This is test SMS message"
    }
}'
```

{% endtab %}
{% endtabs %}

in response you will get message processing status.&#x20;

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

```json
{
    "messages": [
        {
            "messageId": "3919977727444335893722",
            "status": {
                "groupId": 1,
                "groupName": "PENDING",
                "id": 26,
                "name": "PENDING_ACCEPTED",
                "description": "Message sent to next instance"
            },
            "destination": "38598123456"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Send WhatsApp to User

{% hint style="info" %}
You cannot send WhatsApp message to User unless User has interacted with Orangepill bot on WhatsApp number 447860088593.
{% endhint %}

Use [/v1/users/{id}/message/whatsapp](https://api.orangepill.cloud/openapi/ui#/v1.users/post_v1_users__id__message__channel_) APi call to a WhatsApp message. The Message is sent to the phone number set in `channel.whatsapp` field of the [User](https://docs.orangepill.cloud/orangepill-api/identities-and-users) object.

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

```shell

curl --location --request POST 'https://api.orangepill.cloud/v1/users/634b56217f6a7b0be52dffbd/message/whatsapp' \
--header 'x-api-key: AXVubzpwQDU1dzByYM==' \
--header 'idempotency-key: 27373fabc392933deffda' \
--header 'Content-Type: application/json' \
--data-raw '{
    "content": {
        "templateName": "transaction_successful_v5_es",
        "templateData": {
            "body": {
                "placeholders": [
                    "DataPlan 100MB Daily (24 Hours)"
                ]
            }
        },
        "language": "es"
    }
}'
```

{% endtab %}
{% endtabs %}

in response you will get message processing status.&#x20;

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

```json
{
    "messages": [
        {
            "messageId": "3919977727444335893722",
            "status": {
                "groupId": 1,
                "groupName": "PENDING",
                "id": 26,
                "name": "PENDING_ACCEPTED",
                "description": "Message sent to next instance"
            },
            "destination": "38598123456"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Send Email to User

Use [/v1/users/{id}/message/email](https://api.orangepill.cloud/openapi/ui#/v1.users/post_v1_users__id__message__channel_) APi call to send an email message. Email is sent to the address set in the `channel.email` field of the [User](https://docs.orangepill.cloud/orangepill-api/identities-and-users) object.

{% hint style="info" %}
You can send email messages in text ot html body format. If both parameters are set, message is sent in html format.
{% endhint %}

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

```shell

curl --location --request POST 'https://api.orangepill.cloud/v1/users/634b56217f6a7b0be52dffbd/message/email' \
--header 'x-api-key: AXVubzpwQDU1dzByYM==' \
--header 'idempotency-key: 27373fabc392933deffda' \
--header 'Content-Type: application/json' \
--data-raw '{
    "content": {
        "subject": "This is a test subject",
        "html": "<b>This is test html email message</b>",
        "text": "This is test text email message"
    }
}'
```

{% endtab %}
{% endtabs %}

in response you will get message processing status.&#x20;

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

```json
{
    "messages": [
        {
            "messageId": "3919977727444335893722",
            "status": {
                "groupId": 1,
                "groupName": "PENDING",
                "id": 26,
                "name": "PENDING_ACCEPTED",
                "description": "Message sent to next instance"
            },
            "destination": "38598123456"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
To be able to send SMS, WhatsApp and Email messages to [Persons](https://docs.orangepill.cloud/orangepill-api/persons-and-companies) channel must be configured in your Infobip account.
{% endhint %}

## Send SMS to Person

Use [/v1/identities/{id}/person/message/sms](https://api.orangepill.cloud/openapi/ui#/v1.identities/post_v1_identities__id__person_message__channel_) APi call to send an SMS message. The Message is sent to the phone number set in `person.contactInformation.phone[0].number` field of [Identity](https://docs.orangepill.cloud/orangepill-api/identities-and-users) object.

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

```shell

curl --location --request POST 'https://api.orangepill.cloud/v1/identities/634b56217f6a7b0be52dffbd/person/message/sms' \
--header 'x-api-key: AXVubzpwQDU1dzByYM==' \
--header 'idempotency-key: 27373fabc392933deffda' \
--header 'Content-Type: application/json' \
--data-raw '{
    "content": {
        "text": "This is test SMS message"
    }
}'
```

{% endtab %}
{% endtabs %}

in response you will get message processing status.&#x20;

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

```json
{
    "messages": [
        {
            "messageId": "3919977727444335893722",
            "status": {
                "groupId": 1,
                "groupName": "PENDING",
                "id": 26,
                "name": "PENDING_ACCEPTED",
                "description": "Message sent to next instance"
            },
            "destination": "38598123456"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Send WhatsApp to Person

{% hint style="info" %}
You cannot send WhatsApp message to User unless User has interacted with WhatsApp number configured in your Infobip account..
{% endhint %}

Use [/v1/identities/{id}/person/message/whatsapp](https://api.orangepill.cloud/openapi/ui#/v1.identities/post_v1_identities__id__person_message__channel_) APi call to send a WhatsApp message. The Message is sent to phone number set in `person.contactInformation.phone[0].number` field of [Identity](https://docs.orangepill.cloud/orangepill-api/identities-and-users) object.

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

```shell

curl --location --request POST 'https://api.orangepill.cloud/v1/identities/634b56217f6a7b0be52dffbd/person/message/whatsapp' \
--header 'x-api-key: AXVubzpwQDU1dzByYM==' \
--header 'idempotency-key: 27373fabc392933deffda' \
--header 'Content-Type: application/json' \
--data-raw '{
    "content": {
        "templateName": "transaction_successful_v5_es",
        "templateData": {
            "body": {
                "placeholders": [
                    "DataPlan 100MB Daily (24 Hours)"
                ]
            }
        },
        "language": "es"
    }
}'
```

{% endtab %}
{% endtabs %}

in response you will get message processing status.&#x20;

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

```json
{
    "messages": [
        {
            "messageId": "3919977727444335893722",
            "status": {
                "groupId": 1,
                "groupName": "PENDING",
                "id": 26,
                "name": "PENDING_ACCEPTED",
                "description": "Message sent to next instance"
            },
            "destination": "38598123456"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Send Email to Person

Use [/v1/identities/{id}/person/message/email](https://api.orangepill.cloud/openapi/ui#/v1.identities/post_v1_identities__id__person_message__channel_) APi call to send an email message. The email is sent to the address set in `person.contactInformation.email[0].address` field of the [Identity](https://docs.orangepill.cloud/orangepill-api/identities-and-users) object.

{% hint style="info" %}
You can send email messages in text ot html body format. If both parameters are set, message is sent in html format.
{% endhint %}

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

```shell

curl --location --request POST 'https://api.orangepill.cloud/v1/identities/634b56217f6a7b0be52dffbd/person/message/sms' \
--header 'x-api-key: AXVubzpwQDU1dzByYM==' \
--header 'idempotency-key: 27373fabc392933deffda' \
--header 'Content-Type: application/json' \
--data-raw '{
    "content": {
        "subject": "This is a test subject",
        "html": "<b>This is test html email message</b>",
        "text": "This is test text email message"
    }
}'
```

{% endtab %}
{% endtabs %}

in response you will get message processing status.&#x20;

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

```json
{
    "messages": [
        {
            "messageId": "3919977727444335893722",
            "status": {
                "groupId": 1,
                "groupName": "PENDING",
                "id": 26,
                "name": "PENDING_ACCEPTED",
                "description": "Message sent to next instance"
            },
            "destination": "38598123456"
        }
    ]
}
```

{% endtab %}
{% endtabs %}
