Skip to main content

Create content block

Enterprise

This endpoint is part of Countly Enterprise. To get access, contact sales or compare versions. Existing customers can reach the support portal with questions.

Endpoint​

/i/content/save

Overview​

Creates a new content block document.

Authentication​

Pass api_key or auth_token as a query parameter, or send countly-token as a header. See Authentication.

Permissions​

  • Required permission: Create on the content feature

Request Parameters​

ParameterTypeRequiredDescription
api_keyStringYes (or auth_token)API key for authentication
auth_tokenStringYes (or api_key)Auth token for authentication
app_idStringYesApplication identifier
typeStringYesContent block type
blocksStringYesJSON stringified array of block objects
detailsStringYesJSON stringified object with block metadata

details object keys used by server: created, creatorId, favorite, title. For create flow, server overwrites details.created with current timestamp.

Examples​

Example 1: Minimal Create Request​

/i/content/save?api_key=YOUR_API_KEY&app_id=5be987d7b93798516eb5289a&type=modal&blocks=<JSON_STRING>&details=<JSON_STRING>

blocks object before stringifying:

[
{
"layout": "modal",
"elements": {
"title": {
"text": "Welcome"
}
}
}
]

details object before stringifying:

{
"title": "Welcome Modal",
"creatorId": "5d4472152de8f07336f3b100",
"favorite": false,
"created": 0
}

Example 2: Multi-Block Create Request​

/i/content/save?api_key=YOUR_API_KEY&app_id=5be987d7b93798516eb5289a&type=survey&blocks=<JSON_STRING>&details=<JSON_STRING>

blocks object before stringifying:

[
{
"layout": "survey",
"placement": {
"small": {
"position": "center",
"heightMultiplier": 1,
"fullScreenOverride": true
}
},
"elements": {
"steps": {
"step_1": {
"elements": {
"title": {
"text": "How satisfied are you?",
"translations": {
"en": "How satisfied are you?",
"es": "¿Qué tan satisfecho estás?"
}
}
}
}
}
}
}
]

Response​

Success Response​

{
"status": "Success",
"contentId": "507f1f77bcf86cd799439011"
}

Response Fields​

FieldTypeDescription
statusStringOperation status
contentIdStringCreated content block ObjectID

Error Responses​

HTTP StatusResponse
400JSON parsing error or "Invalid request"
400Validation/processing error message (e.message)
500"Error"

Behavior​

  1. Parses blocks and details from JSON strings.
  2. Builds document with app/type/blocks/details.
  3. Sets details.updated = Date.now and details.created = Date.now for new record.
  4. Inserts into countly.content_blocks.
Implementation details

Database Collections

CollectionUsed forData touched by this endpoint
countly.content_blocksEndpoint data source** - Content block definitions