Confluence KB Integration
Index your Confluence Cloud space into TR-AI's knowledge base using the REST API v2.
Credentials required
| Field | Where to find it |
|---|---|
| Base URL | Your Atlassian site URL — e.g. https://yoursite.atlassian.net |
| Your Atlassian account email address | |
| API Token | https://id.atlassian.com/manage-profile/security/api-tokens → Create API token |
| Space Key | Confluence → Space Settings → Space Details → Space Key (e.g. ENG or KB) |
https://id.atlassian.com/manage-profile/security/api-tokens.Step 1 — Create an API token
- 1Open API token managementGo to https://id.atlassian.com/manage-profile/security/api-tokens and click Create API token.
- 2Name and copy the tokenGive it a label (e.g. TR-AI KB indexer) and copy the token value — it is shown only once.
Step 2 — Find your Space Key
In Confluence, go to your space → Space Settings → Space Details. The Space Key is the short identifier (e.g. ENG, KB, SUPPORT). It appears in the URL when browsing the space: https://yoursite.atlassian.net/wiki/spaces/{SPACEKEY}/pages.
Step 3 — Enter credentials in TR-AI
In your TR-AI Dashboard, open the Knowledge Base section and select Confluence. Enter your Base URL, Email, API Token, and Space Key. Click Verify & Index. TR-AI will:
- Call
GET /wiki/api/v2/spaces?keys={spaceKey}&limit=1to verify credentials and confirm the space exists. - Cursor-paginate all pages in the space (250 per page).
- Fetch each page body in parallel (concurrency 6) using
GET /wiki/api/v2/pages/{id}?body-format=storage. - Convert Confluence storage XML to plain text and chunk it for embedding.
How TR-AI fetches pages
Page discovery
TR-AI uses cursor-based pagination on GET /wiki/api/v2/spaces/{spaceKey}/pages with limit=250&status=current. It follows the _links.next cursor until all pages are discovered — there is no hard cap.
Content extraction
Page bodies are fetched in storage format (Confluence's XHTML-based storage format). TR-AI strips the XML to plain text, handling:
- Structured macros (
ac:structured-macro) — inner text preserved. - Block elements (
p,h1–h6,li,tr,td) → newlines. - HTML entities (
&,<,>,) → decoded. - Pages with fewer than 20 characters after stripping are skipped.
Credential verification errors
| Error | Cause | Fix |
|---|---|---|
| 401 Unauthorized | Wrong email or API token | Check email address and regenerate the API token |
| 403 Forbidden | Token lacks permission to read the space | Ensure the Atlassian account has View permission on the space |
| Space not found | Wrong Space Key | Check Space Settings → Space Details → Space Key |
Re-indexing
To re-index after updating your Confluence space, click Re-index in the TR-AI Dashboard. You can also trigger a re-index via the API:
POST /api/admin/reindex
Content-Type: application/json
{ "trialAccountId": 123 }