Close

Content API

The Content API is useful when there is an existing content management system in-house that can be integrated with Omniata Engagement tools. This approach is most effective when the campaigns have a significant amount of different types of content.

You will need an authorization token from your account settings page found at Profile -> Profile Info to use the Content API. The token is a 20 digits hash, you can generate your token at any time.

Content: get

Lists the content created in the Application.

Request Definition

The API URL is assigned per organization. We use “{orgname}” as an example, when testing use your organization’s assigned subdomain name defined in the Omniata panel.

GET https://{orgname}.panel.omniata.com/data_models/{applicationId}/content.json

Parameters

Use the following parameters to list content:

Name Example Description
applicationId 123 Identifies the application within the organization. The Application Id can be found in the Omniata URL preceding the Application’s name.

Response

If successful the returned answer is a JSON structure with the list of contents in the application.

Example request:

$ curl -H 'Authorization: Token token="987AbcAbc987Abc123Ab"'
"http://{orgname}.panel.omniata.com/data_models/4/content.json"

Example response:

[
  {
    "content_type_id": 17,
    "created_at": "2015-12-23T20:41:55.860Z",
    "created_by_id": 634,
    "data_model_id": 4,
    "id": 37,
    "json": "{\r\n \"aps\": {\r\n  \"alert\": \"<%= LK( table => 'localization_app_1', key => {text_code => 'welcome_01'}, value => LK( table => 'country_languages', key => {country_code => $user_state->{'country'} || 'US'}, value => 'locale') ) %>\"\r\n }\r\n}",
    "key": "768bd1",
    "name": "mj content",
    "updated_at": "2015-12-23T20:43:15.681Z",
    "updated_by_id": 634,
    "url": null
  },
  {
    "content_type_id": 1,
    "created_at": "2015-08-21T10:44:46.515Z",
    "created_by_id": 720,
    "data_model_id": 4,
    "id": 1,
    "json": "{ \"alert\": {  \"title\": \"Hello world!\",  \"body\": \"Greetings from Omniata Schools\" }}",
    "key": "om-lxpw1k",
    "name": "Push Notification Greeting for iOS",
    "updated_at": "2015-08-21T10:44:46.515Z",
    "updated_by_id": 720,
    "url": null
  }
]

Content: post

Enables the creation of new content.

Request Definition

The API URL is assigned per organization. We use “{orgname}” as an example, when testing use your organization’s assigned subdomain name defined in the Omniata panel.

POST https://{orgname}.panel.omniata.com/data_models/{applicationId}/content.json

Parameters

Use the following parameters to create new content:

Name Example Description
applicationId 123 Identifies the application within the organization. The Application Id can be found in the Omniata URL preceding the Application’s name.
content[name] Promo A1 Name of the content.
content[tag_list] xpromo, ios, december Comma-separated list of descriptive tags. Used for filtering and searching.
content[content_type_machine_name] generic_display System name of the content type. The Content Type system names can be found in the Content Types menu of your Engagement dashboard.
content[json] {“hello”: “world”} JSON structure with values for the content.

Response

If successful the returned answer is a JSON structure with the details of created content.

Example request:

$ curl -H 'Authorization: Token token="987AbcAbc987Abc123Ab"' -X POST -d "content[name]=Promo A1" -d "content[tag_list]=xpromo,ios" -d "content[content_type_machine_name]=generic_display" -d 'content[json]={"hello": "world"}' "http://{orgname}.panel.omniata.com/data_models/4/content.json"

Example response:

{
  "content_type_id": 16,
  "created_at": "2017-03-27T14:42:31.370Z",
  "created_by_id": 634,
  "data_model_id": 4,
  "id": 53,
  "json": "{\"hello\": \"world\"}",
  "key": "om-ks3sil",
  "name": "Promo A1",
  "test_push_path": "/data_models/4-test/content/53-promo-a1/push_notifications/new",
  "updated_at": "2017-03-27T14:42:31.370Z",
  "updated_by_id": 634,
  "url": null
}

Content: put

Updates the content specified.

Request Definition

The API URL is assigned per organization. We use “{orgname}” as an example, when testing use your organization’s assigned subdomain name defined in the Omniata panel.

PUT https://{orgname}.panel.omniata.com/data_models/{applicationId}/content/{contentId}.json

Parameters

Use the following parameters to update content:

Name Example Description
applicationId 123 Identifies the application within the organization. The Application Id can be found in the Omniata URL preceding the Application’s name.
contentId 99 Unique identifier of a content within an organization. The field “key” has the same purpose.
content[name] Promo A1 Name of the content.
content[tag_list] xpromo, ios, december Comma-separated list of descriptive tags. Used for filtering and searching.
content[content_type_machine_name] generic_display System name of the content type. The Content Type system names can be found in the Content Types menu of your Engagement dashboard.
content[json] {“hello”: “world”} JSON structure with values for the content.

Response

If successful the returned answer is a JSON structure with the list of contents in the application.

Example request:

$ curl -H 'Authorization: Token token="987AbcAbc987Abc123Ab"' -X PUT -d "content[name]=Promo Albatroz 1" -d "content[tag_list]=xpromo,ios,android" "http://{orgname}.panel.omniata.com/data_models/4/content/53.json"

Example response:

{
  "content_type_id": 16,
  "created_at": "2017-03-27T14:42:31.370Z",
  "created_by_id": 634,
  "data_model_id": 4,
  "id": 53,
  "json": "{\"hello\": \"world\"}",
  "key": "om-ks3sil",
  "name": "Promo Albatroz 1",
  "test_push_path": "/data_models/4-test/content/53-promo-albatroz-1/push_notifications/new",
  "updated_at": "2017-03-27T15:11:55.549Z",
  "updated_by_id": 634,
  "url": null
}

Content: delete

Deletes the content specified.

Request Definition

The API URL is assigned per organization. We use “{orgname}” as an example, when testing use your organization’s assigned subdomain name defined in the Omniata panel.

DELETE https://{orgname}.panel.omniata.com/data_models/{applicationId}/content/{contentId}.json

Parameters

Use the following parameters to update content:

Name Example Description
applicationId 123 Identifies the application within the organization. The Application Id can be found in the Omniata URL preceding the Application’s name.
contentId 99 Unique identifier of a content within an organization. The field “key” has the same purpose.

Response

If successful the returned answer a HTTP 204 code.

Example request:

$ curl -H 'Authorization: Token token="987AbcAbc987Abc123Ab"' -X DELETE "http://{orgname}.panel.omniata.com/data_models/4/content/53.json"

Example response:

Status: 204 No Content

This article was last updated on March 30, 2017 15:32. If you didn't find your answer here, search for another article or contact our support to get in touch.