Creating documents
To inject an object with a specific content into a mobile application, create a document.
Requirements
- Create schema types for documents through API.
- Prepare the content you want to use in your documents. You can insert promotions, recommendations and other documents.
- If you want to use recommendations, make sure you have [configured AI recommendations](/docs/campaign/recommendations-v2/introduction-to-recommendation-campaigns/#requirements.
Procedure

-
Go to
Data Management > Documents > Add document.
-
Enter the name for your document. Automatically, the field with a slug is filled as well. A slug is an ID of the document.
-
To select the type of schema, unfold the dropdown list in the Type section. A schema defines the method of validating the data included in the document. To create a schema type, please refer to the API reference pages.
-
Optionally, to let other users know about the purpose of the document, write a short description.
-
Paste the JSON code.
Tip: You can use documents in Screen view campaigns in which you can define the audience to which the document is targeted. -
To complete the process, click the Save button.
Embedding content through the API
One of the options is to define a piece of application that shows a defined type of content (in this example, it is a promotion) retrieved through the API. As an effect, the users of the application are provided with a specific promotion with a defined background color.
slug: promo-api
{
"content-type": "promotions",
"background-color": "#123123",
"title": "Promotions",
"action": {
"data-schema": "promotions",
"uri": "https://api.snrapi.com/schema-service/proxy/promotions?type=GENERAL&sort=requireRedeemedPoints,asc"
}
}
Embedding content through the SDK
Alternatively, instead of using API endpoints, you can pass information about the SDK method you want to use and define the parameters of the method. Example below shows a call to the Client.getPromotions()
method:
slug: promo-sdk
{
"content-type": "promotions",
"background-color": "#123123",
"title": "Promotions",
"action": {
"method": "Client.getPromotions",
"type": "GENERAL",
"sort": "requireRedeemedPoints,asc"
}
}
Inserting content
You can also insert the details of a specific promotion and select the fields that are supposed to be sent back to your application.
slug: daily-promo
{
"content-type": "promotion",
"background-color": "#123321",
"title": "Offer of the day",
"promotion": "{% promotion fields=uuid,name,discountType,discountValue,code,params,tags,type,price,images,description,expireAt %} 3a3750b0-c00b-4c57-9c5f-d55652b417a0 {% endpromotion %}"
}
Using tags to retrieve content
The following example shows the retrieval of promotions from the Synerise API by means of tags.
- Create tags in Data Management > Tags.
- Create a document with (a
tagNames
argument in the uri):
slug: club
{
"content-type": "promotions",
"background-color": "#123123",
"description": "Club offers",
"title": "Special offers only for club members",
"action": {
"data-schema": "promotions",
"uri": "https://{SYNERISE_API_BASE_PATH}/v4/promotions/promotion/get-for-client?type=GENERAL&tagNames=club"
}
}
Final effect
The final effect of what has been done so far is a single slug: main
. The application users are provided with the content of each document referred to in the article when the document slug: main
is retrieved.
slug: main
{
"sections": [
{
"content": {
"color": "#ffffff",
"description": "Hello to our interactive documents demo",
"text": "bold"
},
"schema": "intro",
"slug": "welcome",
"uuid": "33f6fcd0-96e0-43f8-be40-0da733112c5f"
},
{
"content": {
"action": {
"data-schema": "promotions",
"uri": "https://api.snrapi.com/schema-service/proxy/promotions?tagNames=autumn-collection"
},
"section-background-color": "#123123",
"section-title": "Autumn Collection",
"section-type": "promotions"
},
"schema": "promotions",
"slug": "autumn-collection",
"uuid": "5b722719-66af-4c8f-a9ca-9e026d8157b2"
},
{
"content": {
"action": {
"method": "ContentWidget",
"slug": "recommendations"
},
"background-color": "#ffffff",
"section-type": "content-widget",
"title": "Best offers for you"
},
"schema": "content-widget",
"slug": "content-widget",
"uuid": "360dbd79-1972-40f0-bd48-db28c7b8c3a2"
},
{
"content": {
"action": {
"data-schema": "promotions",
"uri": "https://{SYNERISE_API_BASE_PATH}/v4/promotions/promotion/get-for-client?type=GENERAL&tagNames=club"
},
"background-color": "#123123",
"content-type": "promotions",
"description": "Club offers",
"title": "Special offers only for club members"
},
"schema": "promotions",
"slug": "club",
"uuid": "98f92187-603b-4c61-a45c-73cfe555fb06"
},
{
"content": {
"background-color": "#123321",
"content-type": "promotion",
"promotion": {
"code": "apple-promo",
"description": "Apple products 10% cheaper !!!",
"discountType": "PERCENT",
"discountValue": -10,
"expireAt": "2029-12-26T23:59:59.000Z",
"images": [
{
"type": "image",
"url": "https://www.snrcdn.net/upload/f2afa4d4d7af216196047d1f7f0613f22a50a8c8/default/origin/1537188695830-el-mbppro.png"
},
{
"type": "image",
"url": "https://www.snrcdn.net/upload/f2afa4d4d7af216196047d1f7f0613f22a50a8c8/default/origin/1537188692254-el-iphx.png"
},
{
"type": "image",
"url": "https://www.snrcdn.net/upload/f2afa4d4d7af216196047d1f7f0613f22a50a8c8/default/origin/1537188683527-el-ipadpro.png"
}
],
"name": "Apple products 10% cheaper",
"params": null,
"price": 0,
"tags": null,
"type": "MEMBERS_ONLY",
"uuid": "3a3750b0-c00b-4c57-9c5f-d55652b417a0"
},
"title": "Offer of the day"
},
"schema": "promotion",
"slug": "daily-promo",
"uuid": "2a45411a-f615-4aec-a303-8a772974621f"
},
{
"content": {
"action": {
"data-schema": "promotions",
"uri": "https://api.snrapi.com/schema-service/proxy/promotions?type=GENERAL&sort=requireRedeemedPoints,asc"
},
"background-color": "#123123",
"content-type": "promotions",
"title": "Promotions"
},
"schema": "promotions",
"slug": "promo-api",
"uuid": "11357ed3-94a2-4844-a8ce-c1ae119f25ab"
},
{
"content": {
"action": {
"method": "Client.getPromotions",
"sort": "requireRedeemedPoints,asc",
"type": "GENERAL"
},
"background-color": "#123123",
"content-type": "promotions",
"title": "Promotions"
},
"schema": "promotions",
"slug": "promo-sdk",
"uuid": "2836dab5-249b-4884-9bc5-c375960048eb"
}
],
"type": "sections-list"
}