Create and Send
Objects and samples for /create-and-send
endpoints. A full object can contain parts of schedule, template, audience, and platform override objects (for email, sms, or open:: platforms).
The notification payload for Create and Send objects supports both
stored and inline templates. Using inline templates, you can define and
populate variables to personalize notifications to your new channels.
Create and Send MMS notification
The payload for a Create and Send operation that sends a multimedia payload (MMS) to SMS channels. When sending an MMS payload, device_types must be set to mms.
- audience objectREQUIREDOne of
- SMS audience for Create and Send payloads object
The SMS information and opt-in parameters for the audience you want to send to. Unknown MSISDNs are registered as new channels.
OBJECT PROPERTIES- create_and_send array[object]REQUIRED
Each object in the array represents an MSISDN you want to send to. Unknown MSISDNs are registered as new channels. Channel registration fields are prefixed with
ua_and have the same requirements as the SMS channel registration endpoint.All other fields represent variables if
notificationspecifies atemplate.
- OBJECT PROPERTIES
- bulk_id stringREQUIRED
A unique string obtained from the Create bulk send audience operation to target an audience for bulk sending.
- device_types array[string]REQUIRED
The platform you want to send notifications to.
- notification objectREQUIREDOBJECT PROPERTIES
- mms objectREQUIRED
A platform override for MMS messages;
One ofdevice_typesmust be set tomms. A notification with a platform override that does not match yourdevice_typeswill result in a 400 error.Provides the content for a push to MMS channels. If
smsis in thedevice_typearray, your request may include this object. It cannot be combined with an SMS Platform Override as a single push can only include either an SMS or MMS payload.Template and notification overrides for a Create and Send payload with
device_typesset tomms. With a template, you can provide and populate variables and conditional statements based on those variables. Conditionals begin with{{#operator}}and end with{{/operator}}. For more information, see Handlebars.
Used in:
- Create and Send a message
- Schedule a Create and Send message
- Schedule message with bulk ID
- Validate Create and Send payload
Examples
Example Create and Send for MMS without template
{
"audience": {
"create_and_send": [
{
"ua_msisdn": "15558675309",
"ua_sender": "15551234567",
"ua_opted_in": "2020-11-11T18:45:30",
}
]
},
"device_types": [
"mms"
],
"notification": {
"mms": {
"fallback_text": "Delivery failed, but you should still check this out.",
"subject" : "Hey, thanks for subscribing!",
"slides": [
{
"text": "Check this out!",
"media": {
"url": "https://i.example.com/1t466Om.jpg",
"content_type": "image/jpeg",
"content_length": 52918
}
}
]
}
}
}
Create and Send to email channels
The payload for a Create and Send operation to email channels. When sending to email channels, device_types must be set to email.
- audience objectREQUIREDOne of
- Email audience for Create and Send payloads object
The email addresses and opt-in agreements for the audience you want to send to. Unknown addresses are registered as new channels.
OBJECT PROPERTIES- create_and_send array[object]REQUIRED
Each object in the array represents an email address you want to send to. Unknown addresses are registered as new channels. Channel registration fields are prefixed with
ua_and have the same requirements as the email registration endpoint.You cannot provide optional channel registration fields using this endpoint (like
locale_languagefor email channels). All other fields represent variables ifnotificationspecifies atemplate.
- OBJECT PROPERTIES
- bulk_id stringREQUIRED
A unique string obtained from the Create bulk send audience operation to target an audience for bulk sending.
- campaigns object<Campaigns object>
An object specifying custom campaign categories related to the notification.
- device_types array[string]REQUIRED
The platform you want to send notifications to.
- notification objectREQUIRED
An
OBJECT PROPERTIESalertnotification or a platform override matching the value indevice types. A notification with a platform override that does not match yourdevice_typeswill result in a 400 error.- email object
You can either provide the standard object that you would provide when performing a
One of/api/pushto an email platform, or you can provide some of the email platform override fields along with an inline template.Notification fields specific to email messages. This object is required when
emailis specified in the payload’sdevice_typesfield.Notification fields specific to email messages with an inline template for use in a Create and Send payload. Using a template enables you to provide and populate variables in your notification. You can also add conditional statements based on those variables, determining message text that to send to each member of your audience. Conditionals begin with
{{#operator}}and end with{{/operator}}. For more information, see Handlebars.
Used in:
- Create and Send a message
- Schedule a Create and Send message
- Schedule message with bulk ID
- Validate Create and Send payload
Examples
Example object
{
"audience": {
"create_and_send" : [
{
"ua_address": "new@example.com",
"ua_commercial_opted_in": "2020-11-29T10:34:22"
},
{
"ua_address" : "ben@example.com",
"ua_commercial_opted_out": "2020-11-29T12:45:10"
},
{
"ua_address" : "mary@example.com",
"ua_email_suppression_state": "BOUNCE"
}
]
},
"device_types" : [ "email" ],
"notification" : {
"email": {
"subject": "Welcome to the Winter Sale! ",
"html_body": "<h1>Seasons Greetings</h1><p>Check out our winter deals!</p><p><a data-ua-unsubscribe=\"1\" title=\"unsubscribe\" href=\"http://unsubscribe.urbanairship.com/email/success.html\">Unsubscribe</a></p>",
"plaintext_body": "Greetings! Check out our latest winter deals! [[ua-unsubscribe href=\"http://unsubscribe.urbanairship.com/email/success.html\"]]",
"message_type": "transactional",
"sender_name": "Airship",
"sender_address": "team@airship.com",
"reply_to": "no-reply@airship.com",
"click_tracking": false,
"open_tracking": false,
"attachments": [
{
"id": "0e10a6b9-725c-4f6b-9af2-9ef5b31328c0",
},
{
"id": "5503b5fe-ed69-4609-bef6-6fef0e6e428f"
}
]
}
},
"campaigns": {
"categories": ["winter sale", "west coast"]
}
}
Create and Send to open channels
The payload for a Create and Send operation to open channels. When sending to open channels, the device_type must be set to open::<open_channel_name>.
- audience objectREQUIREDOne of
- Open audience for Create and Send payloads object
The Open channel addresses and opt-in information for the audience you want to send to. Unknown addresses are registered as new channels.
OBJECT PROPERTIES- create_and_send array[object]REQUIRED
Each object in the array represents an Open channel address you want to send to. Unknown addresses are registered as new channels. Channel registration fields are prefixed with
ua_and have the same requirements as open channel registration.
- OBJECT PROPERTIES
- bulk_id stringREQUIRED
A unique string obtained from the Create bulk send audience operation to target an audience for bulk sending.
- campaigns object<Campaigns object>
An object specifying custom campaign categories related to the notification.
- device_types array[string]REQUIRED
The platform you want to send notifications to.
- notification objectREQUIRED
An
OBJECT PROPERTIESalertnotification or a platform override matching the value indevice types. A notification with a platform override that does not match yourdevice_typeswill result in a 400 error.- open::open_platform_name object<Open channel overrides with template>
Use a
templatewith an open channel-specific message. You can reference a template by ID, or use{{handlebars}}directly in your message.
Used in:
- Create and Send a message
- Schedule a Create and Send message
- Schedule message with bulk ID
- Validate Create and Send payload
Examples
Example object
{
"audience" : {
"create_and_send": [
{
"ua_address" : "36d5a261-0454-40f5-b952-942c4b2b0f22",
"name": "Perry"
}
]
},
"device_types" : [ "open::smart_fridge" ],
"notification" : {
"open::smart_fridge": {
"alert" : "Hey {{name}}, you're out of ice cream!"
}
},
"campaigns": {
"categories": ["needs_ice_cream", "cookies_and_cream"]
}
}
Create and Send to SMS channels
The payload for a Create and Send operation to SMS channels. When sending to SMS channels, device_types must be set to sms.
- audience objectREQUIREDOne of
- SMS audience for Create and Send payloads object
The SMS information and opt-in parameters for the audience you want to send to. Unknown MSISDNs are registered as new channels.
OBJECT PROPERTIES- create_and_send array[object]REQUIRED
Each object in the array represents an MSISDN you want to send to. Unknown MSISDNs are registered as new channels. Channel registration fields are prefixed with
ua_and have the same requirements as the SMS channel registration endpoint.All other fields represent variables if
notificationspecifies atemplate.
- OBJECT PROPERTIES
- bulk_id stringREQUIRED
A unique string obtained from the Create bulk send audience operation to target an audience for bulk sending.
- campaigns object<Campaigns object>
An object specifying custom campaign categories related to the notification.
- device_types array[string]REQUIRED
The platform you want to send notifications to.
- notification objectREQUIRED
An
OBJECT PROPERTIESalertnotification or a platform override matching the value indevice types. A notification with a platform override that does not match yourdevice_typeswill result in a 400 error.- sms objectOne of
Provides override options when
smsis one of thedevice_typesspecified in the payload.Notification fields specific to SMS messages with an inline template for use in a Create and Send payload. Using a template enables you to provide and populate variables in your notification. You can also add conditional statements based on those variables, determining message text that to send to each member of your audience. Conditionals begin with
{{#operator}}and end with{{/operator}}. For more information, see Handlebars.
Used in:
- Create and Send a message
- Schedule a Create and Send message
- Schedule message with bulk ID
- Validate Create and Send payload
Examples
Example object
{
"audience": {
"create_and_send" : [
{
"ua_msisdn": "15558675309",
"ua_sender": "12345",
"ua_opted_in": "2020-11-11T18:45:30"
}
]
},
"device_types" : [ "sms" ],
"notification" : {
"sms": {
"alert": "Check out our winter sale! https://www.example.com/amazingly/long/url-that-I-want-to-shorten",
"expiry": 172800,
"shorten_links": true
}
},
"campaigns": {
"categories": ["winter sale", "west coast"]
}
}