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.

Jump to examples ↓

OBJECT PROPERTIES
  • audience objectREQUIRED
    One 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 notification specifies a template.

    • OBJECT PROPERTIES
  • device_types array[string]REQUIRED

    The platform you want to send notifications to.

  • notification objectREQUIRED
    OBJECT PROPERTIES
    • mms objectREQUIRED

      A platform override for MMS messages; device_types must be set to mms. A notification with a platform override that does not match your device_types will result in a 400 error.

      One of
      • Provides the content for a push to MMS channels. If sms is in the device_type array, 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_types set to mms. 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:

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.

Jump to examples ↓

OBJECT PROPERTIES
  • audience objectREQUIRED
    One 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_language for email channels). All other fields represent variables if notification specifies a template.

    • OBJECT PROPERTIES
  • 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 alert notification or a platform override matching the value in device types. A notification with a platform override that does not match your device_types will result in a 400 error.

    OBJECT PROPERTIES
    • email object

      You can either provide the standard object that you would provide when performing a /api/push to an email platform, or you can provide some of the email platform override fields along with an inline template.

      One of
      • Notification fields specific to email messages. This object is required when email is specified in the payload’s device_types field.

      • 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:

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>.

Jump to examples ↓

OBJECT PROPERTIES
  • audience objectREQUIRED
    One 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
  • 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 alert notification or a platform override matching the value in device types. A notification with a platform override that does not match your device_types will result in a 400 error.

    OBJECT PROPERTIES
    • open::open_platform_name object<Open channel overrides with template>

      Use a template with an open channel-specific message. You can reference a template by ID, or use {{handlebars}} directly in your message.

Used in:

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.

Jump to examples ↓

OBJECT PROPERTIES
  • audience objectREQUIRED
    One 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 notification specifies a template.

    • OBJECT PROPERTIES
  • 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 alert notification or a platform override matching the value in device types. A notification with a platform override that does not match your device_types will result in a 400 error.

    OBJECT PROPERTIES
    • sms object
      One of
      • Provides override options when sms is one of the device_types specified 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:

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"]
  }
}