# Advanced Campaign Features

### How to send a campaign with more advanced settings

```http
POST https://api.cm.com/messages/v1/accounts/{accountId}/messages
```

<swagger method="post" path="/messages/v1/accounts/{accountId}/messages" ></swagger>

Example post body:

```json
{
    "body": "Hello {{1}}, this is an advanced test campaign. This can contain a link => [[url:http://www.cm.com]] or CM Pages [[page:b99f6d4f-243a-11e7-9742-005056b0187a]] or OptOut instructions [[optout]]",
    "ignoreUnsubscribes" : false,
    "scheduledAtUtc": "2018-08-15T13:09:43.715Z",
    "recipients": [
                    { "group": "b99f6d4f-243a-11e7-9742-005056b0187a" },
                    { "contact": "0b7bf29a-2439-11e7-9742-005056b0187a" },
                    { "msisdn": "+31627142592", "data": { "1": "John", "3": "Doe", "5":"john.doe@cm.nl","6": "CM.com" } }
                  ],
    "senders": ["TEST"],
    "countrySpecificSenders": {
        "NL": "CM.com",
        "BE": "0032496448785",
        "UK": "88882"
    },
    "spread": {
        "timeFrames": [
            {
                "days": [
                    "Mon",
                    "Tue",
                    "Wed",
                    "Thu",
                    "Fri",
                    "Sat",
                    "Sun"
                ],
                "startTime": "09:00",
                "endTime": "12:00"
            },
            {
                "days": [
                    "Mon",
                    "Tue",
                    "Wed",
                    "Thu",
                    "Fri",
                    "Sat",
                    "Sun"
                ],
                "startTime": "13:00",
                "endTime": "17:30"
            }
        ],
        "until" : "2019-03-14T15:00:26.9932482Z"
    },
    "options": {
        "urlShortenerDomainId": "0b7bf29a-2439-11e7-9742-005056b0187b"
    }
}
```

***scheduledAtUtc :*** defines when the campaign will be sent, timezone is UTC, please make sure you adjust your time before supplying values.

**\*Data tags like** \* <code ng-non-bindable>{{1}}</code> are placeholders for custom data retrieved from Addressbook or msisdn data.

***Links*** enclosed in double square brackets like <code>\[\[url:<http://www.cm.com>]]</code> will be converted into shortlinks like <code><https://cm.to/sH012tL></code> which are 22 characters long.

***CM Pages*** tags are enclosed in double square brackets, starts with page: and includes page the related page guid. They are also translated into shortlinks (22 chars).

***Optout tag*** inserts optout instructions per recipient, if recipient's country has a predefined shortcode for STOP messages it will translate into ***STOP shortcode*** otherwise it will translated into an optout link like <https://NO-S.MS/OptOut>

***ignoreUnsubscribes :*** By default Campaigns API filters recipients using the Unsubscribes list in Addressbook. If this setting is set to true, unsubscribes will not be filtered.

***Msisdn with data :*** It is possible to add a data dictionary to msisdn recipients so data tags in the body can be rendered also for msisdn recipients.

***Senders :*** Specifies the default sender to use unless a specific sender is defined for recipients country in ***countrySpecificSenders*** setting

***spread :*** Spread until setting makes sure that messages are delivered in batches over a certain amount of time between scheduled time and spread until setting. Value must be in ***UTC***

***timeFrames :*** Defines the allowed days and time periods where the messages are allowed to be sent.

***options :*** Holds an object with extra options.

* ***urlShortenerDomainId :*** Currently only holds a Guid to a custom domain, which refers to a domain created in the [branded links app](https://www.cm.com/app/branded-links/). Short URLs will then be created with this domain instead of with the cm.to domain.

<span class="cm-icon cm-icon-warning" aria-hidden="true"></span> Time frame startTime and endTime values must be in ***UTC***

***

<span class="cm-icon cm-icon-information" aria-hidden="true"></span> Below are the list of default data tags, if you have other custom fields defined in addressbook/msisdn data, you have to use relevant custom field ids.

| Name         | FieldId | Tag |
| ------------ | ------- | --- |
| FirstName    | 1       | 1   |
| Insertion    | 2       | 2   |
| LastName     | 3       | 3   |
| PhoneNumber  | 4       | 4   |
| EmailAddress | 5       | 5   |
| Company      | 6       | 6   |