Skip to content

Create API Template Source Payload

The request body for creating an API template source.

templateobject(API Template)required

Describes a knowledge base's REST API so that Intercom can import its content. On each sync, Intercom:

  1. Sends a GET request to base_url and tree.path, and reads the list of nodes at tree.nodes in the JSON response, following tree.children into nested nodes.
  2. Creates a folder for each node that matches tree.folder_if, or that has children when tree.folder_if_has_children is true.
  3. For each node that matches tree.content_if, sends a GET request to base_url and item.path, and imports the page using the fields set in mapping.

Imported content goes into a Knowledge Hub folder named after name.

Placeholders. In base_url, tree.path and tree.query values, {name} is replaced with the value of the variable name. In item.path and item.query values, {name} can also be a node_values name. A query value of exactly {token} is replaced with the source's auth_token. A value filled into base_url or a path can only use letters, digits, ., _ and -, and can't be only dots. A node value that's blank, or that's filled into a path and doesn't meet this rule, fails the sync.

Checks. When the template fails a check, creating the source returns a 422 parameter_invalid error whose field names the template field and whose message names the check. For example, the field is template.base_url and the message is base_url fails the not_https check. Each field below lists its checks. A tree response over 25 MB isn't a check: it fails on template.tree with the message <name>'s tree response is too large: over the 25 MB cap.

Limits.

  • Intercom sends one tree request per sync, so the tree response must list every node. Paging isn't supported.
  • The tree response can be at most 25 MB. When you create the source, a larger response fails on template.tree with the message <name>'s tree response is too large: over the 25 MB cap.
  • A tree can have at most 50,000 nodes, or the sync fails. Nodes nested more than 12 levels deep are skipped.
  • An item response over 10 MB is skipped, as is an item the vendor returns 404 for.
  • A redirect isn't followed, and fails the sync.
  • During a sync, when the vendor answers 429, Intercom waits for the time in its Retry-After header and then retries. If the vendor keeps answering 429, the sync fails.
Example:
{ "name": "Example Docs", "base_url": "https://api.example.com/v1", "variables": [ "space_id" ], "auth": { "header": "Authorization", "value": "Bearer {token}" }, "tree": { "path": "/spaces/{space_id}/pages", "query": { … }, "nodes": [ … ], "children": "pages", "folder_if": [ … ], "folder_if_has_children": true, "content_if": [ … ] }, "item": { "path": "/spaces/{space_id}/pages/{page_id}", "node_values": { … } }, "mapping": { "id": [ … ], "title": [ … ], "body": [ … ], "updated_at": [ … ] }, "body_format": "html" }
variablesobject

A value for each name in the template's variables, required when the template declares variables. Values can only use letters, digits, ., _ and -, and can't be only dots. Values for names the template doesn't declare are ignored.

Example:
{ "space_id": "help-center" }
auth_tokenstringrequired

The API token for the knowledge base, sent as set in template.auth. It can only use printable ASCII characters. Intercom checks it by sending the template's tree request before saving the source. It's never returned.

Example:"vendor-api-token"
{ "template": { "name": "Example Docs", "base_url": "https://api.example.com/v1", "variables": [ … ], "auth": { … }, "tree": { … }, "item": { … }, "mapping": { … }, "body_format": "html" }, "variables": { "space_id": "help-center" }, "auth_token": "vendor-api-token" }