Content

Use the Content API to create content templates that can be sent in pushes and managed in the Airship dashboard.

Create content template

Create a new content template.

Jump to examples ↓

POST /api/content/templates

Security:

Request body:

A single content template object.

  • Content-Type: application/json

    A reusable template containing fields for a message type. Can be referenced by its UUID or a customer-defined external ID.

Responses

  • 201

    The template was created.

    • Location string

      The URI for the template, used for later updates or sends.

    • Content-Type: application/vnd.urbanairship+json; version=3
      OBJECT PROPERTIES
      • ok booleanREQUIRED

        If true, the operation completed successfully and returns an expected response.

      • operation_id string

        A unique string identifying the operation, useful for reporting and troubleshooting.

        Format: uuid

        Example: ef625038-70a3-41f1-826f-57bc11dd625a

      • template_id string

        A unique string identifying the template, used to reference it when sending messages and in other operations.

        Format: uuid

        Example: 0f7704e9-5dc0-4f7d-9964-e89055701b0a

  • 400

    There was a parsing or validation error in the request. Bad Request errors typically include path and location in the response to help you find the cause of the error.

    • Content-Type: application/json

      Errors returned with 4xx responses. Errors include as much information as possible to help you understand the reason for the failure.

  • 401

    Authentication information (the app key and secret or bearer token) was either incorrect or missing.

    • Content-Type: text/plain

      Errors returned with 4xx responses. Errors include as much information as possible to help you understand the reason for the failure.

Examples

Example create email content template with snippet and feed references

POST /api/content/templates HTTP/1.1
Authorization: Basic <master authorization string>
Accept: application/vnd.urbanairship+json; version=3
Content-Type: application/json

{
    "external_id": "welcome_message",
    "name": "Welcome Message",
    "description": "Our welcome message",
    "type": "email",
    "content": {
        "subject": "Welcome!",
        "html_body": "<html><body>Hi, {{first_name}}! {{>footer}}</body></html>",
        "plaintext_body": "Hi, {{first_name}}!"
    },
    "snippet_references": {
        "snippets": [
          {
            "name": "footer"
          }
        ]
    },
    "feed_references": {
        "feeds": [
          {
            "name": "featured_product"
          }
        ]
    }
}
HTTP/1.1 201 Created
Location: https://go.urbanairship.com/api/content/templates/ef34a8d9-0ad7-491c-86b0-aea74da15161
Content-Type: application/vnd.urbanairship+json; version=3

{
    "ok" : true,
    "operation_id" : "9ce808c8-7176-45dc-b79e-44aa74249a5a",
    "template_id": "ef34a8d9-0ad7-491c-86b0-aea74da15161"
}

Create or update content template by external ID

Create or update a content template by its external ID.

Jump to examples ↓

PUT /api/content/templates/external/{type}/{external_id}

Security:

Path parameters:

  • type stringREQUIRED
    The message type for the template.

    Possible values:

    • email
    • sms
    • open
    • app
    • web
    • message_center
  • external_id stringREQUIRED
    The customer-defined external ID of the template.

Request body:

A partially defined content template object.

  • Content-Type: application/json

    A reusable template containing fields for a message type. Can be referenced by its UUID or a customer-defined external ID.

Responses

  • 200

    Returned if the template has been successfully updated.

    • Content-Type: application/vnd.urbanairship+json; version=3
      OBJECT PROPERTIES
      • ok booleanREQUIRED

        If true, the operation completed successfully and returns an expected response.

      • operation_id string

        A unique string identifying the operation, useful for reporting and troubleshooting.

        Format: uuid

        Example: ef625038-70a3-41f1-826f-57bc11dd625a

  • 400

    There was a parsing or validation error in the request. Bad Request errors typically include path and location in the response to help you find the cause of the error.

    • Content-Type: application/json

      Errors returned with 4xx responses. Errors include as much information as possible to help you understand the reason for the failure.

  • 401

    Authentication information (the app key and secret or bearer token) was either incorrect or missing.

    • Content-Type: text/plain

      Errors returned with 4xx responses. Errors include as much information as possible to help you understand the reason for the failure.

Examples

Example update content template by external ID

PUT /api/content/templates/external/email/customer-defined-id HTTP/1.1
Authorization: Basic <master authorization string>
Accept: application/vnd.urbanairship+json; version=3
Content-Type: application/json

{
    "name": "Welcome Message",
    "description": "Our welcome message",
    "content": {
        "subject": "Welcome!",
        "html_body": "<html><body>Hi, {{first_name}}!</body></html>",
        "plaintext_body": "Hi, {{first_name}}!"
    }
}
HTTP/1.1 200 OK
Content-Type: application/vnd.urbanairship+json; version=3

{
    "ok" : true,
    "operation_id" : "9ce808c8-7176-45dc-b79e-44aa74249a5a"
}

Delete content template

Delete a content template.

Jump to examples ↓

DELETE /api/content/templates/{template_id}

Security:

Path parameters:

  • template_id stringREQUIRED
    The UUID of the template.

Responses

  • 200

    The template with the given ID has been successfully deleted.

    • Content-Type: application/vnd.urbanairship+json; version=3
      OBJECT PROPERTIES
      • ok booleanREQUIRED

        If true, the operation completed successfully and returns an expected response.

      • operation_id string

        A unique string identifying the operation, useful for reporting and troubleshooting.

        Format: uuid

        Example: ef625038-70a3-41f1-826f-57bc11dd625a

  • 401

    Authentication information (the app key and secret or bearer token) was either incorrect or missing.

    • Content-Type: text/plain

      Errors returned with 4xx responses. Errors include as much information as possible to help you understand the reason for the failure.

  • 404

    The requested resource doesn’t exist.

    • Content-Type: application/vnd.urbanairship+json

      Errors returned with 4xx responses. Errors include as much information as possible to help you understand the reason for the failure.

Examples

Example delete content template

DELETE /api/content/templates/ef34a8d9-0ad7-491c-86b0-aea74da15161 HTTP/1.1
Authorization: Basic <master authorization string>
Accept: application/vnd.urbanairship+json; version=3
HTTP/1.1 200 OK
Content-Type: application/vnd.urbanairship+json; version=3

{
    "ok" : true,
    "operation_id" : "9ce808c8-7176-45dc-b79e-44aa74249a5a"
}

Delete content template by external ID

Delete a content template.

Jump to examples ↓

DELETE /api/content/templates/external/{type}/{external_id}

Security:

Path parameters:

  • type stringREQUIRED
    The message type for the template.

    Possible values:

    • email
    • sms
    • open
    • app
    • web
    • message_center
  • external_id stringREQUIRED
    The customer-defined external ID of the template.

Responses

  • 200

    The template with the given external ID has been successfully deleted.

    • Content-Type: application/vnd.urbanairship+json; version=3
      OBJECT PROPERTIES
      • ok booleanREQUIRED

        If true, the operation completed successfully and returns an expected response.

      • operation_id string

        A unique string identifying the operation, useful for reporting and troubleshooting.

        Format: uuid

        Example: ef625038-70a3-41f1-826f-57bc11dd625a

  • 401

    Authentication information (the app key and secret or bearer token) was either incorrect or missing.

    • Content-Type: text/plain

      Errors returned with 4xx responses. Errors include as much information as possible to help you understand the reason for the failure.

  • 404

    The requested resource doesn’t exist.

    • Content-Type: application/vnd.urbanairship+json

      Errors returned with 4xx responses. Errors include as much information as possible to help you understand the reason for the failure.

Examples

Example delete content template by external ID

DELETE /api/content/templates/external/email/customer-defined-id HTTP/1.1
Authorization: Basic <master authorization string>
Accept: application/vnd.urbanairship+json; version=3
HTTP/1.1 200 OK
Content-Type: application/vnd.urbanairship+json; version=3

{
    "ok" : true,
    "operation_id" : "9ce808c8-7176-45dc-b79e-44aa74249a5a"
}

List content templates

List all existing content templates. Returns an array of content template objects in the content_templates attribute.

Jump to examples ↓

GET /api/content/templates

Security:

Query parameters:

  • page integer
    Specifies the desired page number. Defaults to 1.
  • page_size integer
    Specifies how many results to return per page.
  • sort string
    Specifies the name of the field you want to sort results by. Defaults to created_at.

    Possible values:

    • created_at
    • modified_at
  • order string
    Specifies the sort order as ascending (asc) or descending (desc). Defaults to asc.

    Possible values:

    • asc
    • desc

Responses

  • 200

    Returned on success, with the JSON representation of the content templates in the body of the response.

    • Content-Type: application/vnd.urbanairship+json; version=3
      OBJECT PROPERTIES
      • content_templates array

        An array of content template objects.

      • count integer

        The number of content templates in the current response. This is effectively the page size.

      • next_page string

        There might be more than one page of results for this listing. When present, use this URL to fetch the next batch of results.

        Format: url

      • ok booleanREQUIRED

        Success.

      • prev_page string

        Link to the previous page, if available.

        Format: url

      • total_count integer

        The total number of content templates.

  • 401

    Authentication information (the app key and secret or bearer token) was either incorrect or missing.

    • Content-Type: text/plain

      Errors returned with 4xx responses. Errors include as much information as possible to help you understand the reason for the failure.

Examples

Example list content templates

GET /api/content/templates HTTP/1.1
Authorization: Basic <master authorization string>
Accept: application/vnd.urbanairship+json; version=3
HTTP/1.1 200 OK
Content-Type: application/vnd.urbanairship+json; version=3

{
    "ok" : true,
    "count": 1,
    "total_count": 1,
    "content_templates": [
        {
          "id": "ef34a8d9-0ad7-491c-86b0-aea74da15161",
          "external_id": "welcome_message",
          "name": "Welcome Message",
          "description": "Our welcome message",
          "type": "email",
          "content": {
              "subject": "Welcome!",
              "html_body": "<html><body>Hi, {{first_name}}!</body></html>",
              "plaintext_body": "Hi, {{first_name}}!"
          },
          "created_at": "2020-08-17T11:10:02Z",
          "modified_at": "2020-08-17T11:10:02Z"
      }
    ],
    "next_page": null,
    "prev_page": null
}

Look up a content template

Fetch a single content template using UUID.

Jump to examples ↓

GET /api/content/templates/{template_id}

Security:

Path parameters:

  • template_id stringREQUIRED
    The UUID of the template.

Responses

  • 200

    Returned on success, with the JSON representation of the template in the body of the response.

    • Content-Type: application/vnd.urbanairship+json; version=3
      OBJECT PROPERTIES
      • content_template object<Content template object>

        A reusable template containing fields for a message type. Can be referenced by its UUID or a customer-defined external ID.

      • ok booleanREQUIRED

        If true, the operation completed successfully and returns an expected response.

  • 401

    Authentication information (the app key and secret or bearer token) was either incorrect or missing.

    • Content-Type: text/plain

      Errors returned with 4xx responses. Errors include as much information as possible to help you understand the reason for the failure.

  • 404

    The requested resource doesn’t exist.

    • Content-Type: application/vnd.urbanairship+json

      Errors returned with 4xx responses. Errors include as much information as possible to help you understand the reason for the failure.

Examples

Example look up content template

GET /api/content/templates/ef34a8d9-0ad7-491c-86b0-aea74da15161 HTTP/1.1
Authorization: Basic <master authorization string>
Accept: application/vnd.urbanairship+json; version=3
HTTP/1.1 200 OK
Content-Type: application/vnd.urbanairship+json; version=3

{
  "ok" : true,
  "content_template":  {
    "id": "ef34a8d9-0ad7-491c-86b0-aea74da15161",
    "external_id": "welcome_message",
    "name": "Welcome Message",
    "description": "Our welcome message",
    "type": "email",
    "content": {
        "subject": "Welcome!",
        "html_body": "<html><body>Hi, {{first_name}}! {{>footer}}</body></html>",
        "plaintext_body": "Hi, {{first_name}}!"
    },
    "created_at": "2020-08-17T11:10:02Z",
    "modified_at": "2020-08-17T11:10:02Z",
    "snippets": [
      {
        "name": "footer"
      }
    ]
  }
}

Look up a content template by external ID

Fetch a single content template using external ID.

Jump to examples ↓

GET /api/content/templates/external/{type}/{external_id}

Security:

Path parameters:

  • type stringREQUIRED
    The message type for the template.

    Possible values:

    • email
    • sms
    • open
    • app
    • web
    • message_center
  • external_id stringREQUIRED
    The customer-defined external ID of the template.

Responses

  • 200

    Returned on success, with the JSON representation of the template in the body of the response.

    • Content-Type: application/vnd.urbanairship+json; version=3
      OBJECT PROPERTIES
      • content_template object<Content template object>

        A reusable template containing fields for a message type. Can be referenced by its UUID or a customer-defined external ID.

      • ok booleanREQUIRED

        If true, the operation completed successfully and returns an expected response.

  • 401

    Authentication information (the app key and secret or bearer token) was either incorrect or missing.

    • Content-Type: text/plain

      Errors returned with 4xx responses. Errors include as much information as possible to help you understand the reason for the failure.

  • 404

    The requested resource doesn’t exist.

    • Content-Type: application/vnd.urbanairship+json

      Errors returned with 4xx responses. Errors include as much information as possible to help you understand the reason for the failure.

Examples

Example look up content template by external ID

GET /api/content/templates/external/email/customer-defined-id HTTP/1.1
Authorization: Basic <master authorization string>
Accept: application/vnd.urbanairship+json; version=3
HTTP/1.1 200 OK
Content-Type: application/vnd.urbanairship+json; version=3

{
  "ok" : true,
  "content_template":  {
    "id": "ef34a8d9-0ad7-491c-86b0-aea74da15161",
    "external_id": "customer-defined-id",
    "name": "Welcome Message",
    "description": "Our welcome message",
    "type": "email",
    "content": {
        "subject": "Welcome!",
        "html_body": "<html><body>Hi, {{first_name}}! {{>footer}}</body></html>",
        "plaintext_body": "Hi, {{first_name}}!"
    },
    "created_at": "2020-08-17T11:10:02Z",
    "modified_at": "2020-08-17T11:10:02Z",
    "snippets": [
      {
        "name": "footer"
      }
    ]
  }
}

Update content template

Update a content template.

Jump to examples ↓

PUT /api/content/templates/{template_id}

Security:

Path parameters:

  • template_id stringREQUIRED
    The UUID of the template.

Request body:

A partially defined content template object.

  • Content-Type: application/json

    A reusable template containing fields for a message type. Can be referenced by its UUID or a customer-defined external ID.

Responses

  • 200

    Returned if the template has been successfully updated.

    • Content-Type: application/vnd.urbanairship+json; version=3
      OBJECT PROPERTIES
      • ok booleanREQUIRED

        If true, the operation completed successfully and returns an expected response.

      • operation_id string

        A unique string identifying the operation, useful for reporting and troubleshooting.

        Format: uuid

        Example: ef625038-70a3-41f1-826f-57bc11dd625a

  • 400

    There was a parsing or validation error in the request. Bad Request errors typically include path and location in the response to help you find the cause of the error.

    • Content-Type: application/json

      Errors returned with 4xx responses. Errors include as much information as possible to help you understand the reason for the failure.

  • 401

    Authentication information (the app key and secret or bearer token) was either incorrect or missing.

    • Content-Type: text/plain

      Errors returned with 4xx responses. Errors include as much information as possible to help you understand the reason for the failure.

Examples

Example update content template

PUT /api/content/templates/ef34a8d9-0ad7-491c-86b0-aea74da15161 HTTP/1.1
Authorization: Basic <master authorization string>
Accept: application/vnd.urbanairship+json; version=3
Content-Type: application/json

{
    "name": "Welcome Message",
    "description": "Our welcome message",
    "content": {
        "subject": "Welcome!",
        "html_body": "<html><body>Hi, {{first_name}}!</body></html>",
        "plaintext_body": "Hi, {{first_name}}!"
    }
}
HTTP/1.1 200 OK
Content-Type: application/vnd.urbanairship+json; version=3

{
    "ok" : true,
    "operation_id" : "9ce808c8-7176-45dc-b79e-44aa74249a5a"
}