- Create API Template Source Payload
The request body for creating an API template source.
Describes a knowledge base's REST API so that Intercom can import its content. On each sync, Intercom:
- Sends a
GETrequest tobase_urlandtree.path, and reads the list of nodes attree.nodesin the JSON response, followingtree.childreninto nested nodes. - Creates a folder for each node that matches
tree.folder_if, or that has children whentree.folder_if_has_childrenistrue. - For each node that matches
tree.content_if, sends aGETrequest tobase_urlanditem.path, and imports the page using the fields set inmapping.
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.treewith 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
404for. - A redirect isn't followed, and fails the sync.
- During a sync, when the vendor answers
429, Intercom waits for the time in itsRetry-Afterheader and then retries. If the vendor keeps answering429, the sync fails.
{ "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" }
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.
{ "space_id": "help-center" }
{ "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" }