# Expected Errors & Programming Languages

## **Expected Errors**

MM API is designed specifically for sending Marketing template messages. If you try to send any other message type - such as freeform, Authentication, Service, or Utility - you’ll receive an error response. These formats aren't supported in MM API.

It’s also important to note that MM API is a send-only API. It doesn’t support incoming messages from users. If your use case requires two-way communication, you’ll need to use the Cloud API alongside MM API on the same phone number to receive incoming messages and replies.&#x20;

***

#### **Using MM API to send normal text messages**

The expected error if we try to send a message which is not a Marketing template message is:

```json
{
    "detail": {
        "error": {
            "message": "(#100) Invalid parameter",
            "type": "OAuthException",
            "code": 100,
            "error_data": {
                "messaging_product": "whatsapp",
                "details": "Message must be a template message."
            },
            "fbtrace_id": "AS8UhxdPr7P7WMufJGTGVGU"
        }
    }
}
```

#### **Using MM API to send Authentication/Utility templates**

The expected error if we try to send a template message that is not a Marketing template message is:

```json
{
    "detail": {
        "error": {
            "message": "(#131055) Method not allowed",
            "type": "OAuthException",
            "code": 131055,
            "error_data": {
                "messaging_product": "whatsapp",
                "details": "Only marketing template messages are supported"
            },
            "fbtrace_id": "AacMONwqoqRZJidqSa1LDey"
        }
    }
}
```

#### **Not allowed to send messages using MM API**

The expected error if we try to send a MM API if the phone number is not activated for this API:

```json
{
    "detail": {
        "error": {
            "message":"(#200) You must accept the Marketing Messages Lite API terms to use the API."
            "type": "OAuthException",
            "code": 131055,
            "fbtrace_id": "AacMONwqoqRZJidqSa1LDey"
        }
    }
}
```

#### **Using the wrong D360-API-KEY**

If you use an invalid `D360-API-KEY`, the request will fail with an authentication error. This typically means the token is incorrect or missing.

```json
{ "error": "Invalid api token." }
```

***

## **Examples using multiple programming languages**

### 1. Postman Collection

Once you’re approved to join the program, you can download the Postman collection that includes both successful request examples and the expected error responses:

{% file src="<https://3527970750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4sMxKjL6eJRvZn6jeG-887967055%2Fuploads%2FWt57uWID40Cq0K2FK9BM%2FMM%20Lite.postman_collection.json?alt=media&token=c47c01d2-907f-493b-b9d8-d655e77f07c4>" %}

This collection is designed to help you quickly test and validate MM API behavior across a range of use cases.

**How to use:**

1. Import in Postman, the JSON file corresponding to a collection of requests with examples related with MM API.
2. Modify the collection variables, with the values you received from 360Dialog Team.

<figure><img src="https://3527970750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4sMxKjL6eJRvZn6jeG-887967055%2Fuploads%2FlQgWfAZzA7vui3bIpUdP%2Fimage.png?alt=media&#x26;token=c3c021a0-a427-4020-a40f-a89c43b7b9e4" alt=""><figcaption></figcaption></figure>

### 2. NodeJS (using request library)

<details>

<summary>Set current Webhook URL</summary>

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://waba-v2.360dialog.io/waba_webhook',
  'headers': {
    'Content-Type': 'application/json',
    'D360-API-KEY': '<token>'
  },
  body: JSON.stringify({
    "url": "https://webhook.site/d4d4df6d-ee02-4572-a021-bcc60836d1e7"
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

</details>

<details>

<summary>Send text message using Cloud API</summary>

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://waba-v2.360dialog.io/messages',
  'headers': {
    'Content-Type': 'application/json',
    'D360-API-KEY': '<token>'
  },
  body: JSON.stringify({
    "messaging_product": "whatsapp",
    "recipient_type": "individual",
    "to": "<phone_number>",
    "type": "text",
    "text": {
      "body": "This is a simple text msg send using cloud api"
    }
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

</details>

<details>

<summary>Send Marketing Template message using Cloud API</summary>

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://waba-v2.360dialog.io/messages',
  'headers': {
    'Content-Type': 'application/json',
    'D360-API-KEY': '<token>'
  },
  body: JSON.stringify({
    "messaging_product": "whatsapp",
    "recipient_type": "individual",
    "to": "<phone_number>",
    "type": "template",
    "template": {
      "name": "marketing_text_no_param",
      "language": {
        "policy": "deterministic",
        "code": "en"
      }
    }
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

</details>

<details>

<summary>Send Marketing Template message using MM API</summary>

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://waba-v2.360dialog.io/marketing_messages',
  'headers': {
    'Content-Type': 'application/json',
    'D360-API-KEY': '<token>'
  },
  body: JSON.stringify({
    "messaging_product": "whatsapp",
    "recipient_type": "individual",
    "to": "<phone_number>",
    "type": "template",
    "template": {
      "name": "marketing_text_no_param",
      "language": {
        "policy": "deterministic",
        "code": "en"
      }
    }
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

</details>

### 3. Python (using request library)

<details>

<summary>Set current Webhook URL</summary>

```javascript
import requests
import json

url = "https://waba-v2.360dialog.io/waba_webhook"

payload = json.dumps({
  "url": "https://webhook.site/d4d4df6d-ee02-4572-a021-bcc60836d1e7"
})
headers = {
  'Content-Type': 'application/json',
  'D360-API-KEY': '<token>'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

</details>

<details>

<summary>Send text message using Cloud API</summary>

```javascript
import requests
import json

url = "https://waba-v2.360dialog.io/messages"

payload = json.dumps({
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "<phone_number>",
  "type": "text",
  "text": {
    "body": "This is a simple text msg send using cloud api"
  }
})
headers = {
  'Content-Type': 'application/json',
  'D360-API-KEY': '<token>'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

</details>

<details>

<summary>Send Marketing Template message using Cloud API</summary>

```javascript
import requests
import json

url = "https://waba-v2.360dialog.io/messages"

payload = json.dumps({
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "<phone_number>",
  "type": "template",
  "template": {
    "name": "marketing_text_no_param",
    "language": {
      "policy": "deterministic",
      "code": "en"
    }
  }
})
headers = {
  'Content-Type': 'application/json',
  'D360-API-KEY': '<token>'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

</details>

<details>

<summary>Send Marketing Template message using MM API</summary>

```javascript
import requests
import json

url = "https://waba-v2.360dialog.io/marketing_messages"

payload = json.dumps({
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "<phone_number>",
  "type": "template",
  "template": {
    "name": "marketing_text_no_param",
    "language": {
      "policy": "deterministic",
      "code": "en"
    }
  }
})
headers = {
  'Content-Type': 'application/json',
  'D360-API-KEY': '<token>'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

</details>


---

# Agent Instructions: 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:

```
GET https://docs.360dialog.com/docs/resources/marketing-messages/expected-errors-and-programming-languages.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
