Confluence KB Integration

Confluence KB Integration

Index your Confluence Cloud space into TR-AI's knowledge base using the REST API v2.

Note:TR-AI indexes Confluence Cloud using the REST API v2 with HTTP Basic auth (email + API token). Confluence Server / Data Center is not supported.

Credentials required

FieldWhere to find it
Base URLYour Atlassian site URL — e.g. https://yoursite.atlassian.net
EmailYour Atlassian account email address
API Tokenhttps://id.atlassian.com/manage-profile/security/api-tokens → Create API token
Space KeyConfluence → Space Settings → Space Details → Space Key (e.g. ENG or KB)
Tip:The API token is a Confluence Cloud API token — not your Atlassian account password. Create one at https://id.atlassian.com/manage-profile/security/api-tokens.

Step 1 — Create an API token

  1. 1
    Open API token management
    Go to https://id.atlassian.com/manage-profile/security/api-tokens and click Create API token.
  2. 2
    Name and copy the token
    Give 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=1 to 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

ErrorCauseFix
401 UnauthorizedWrong email or API tokenCheck email address and regenerate the API token
403 ForbiddenToken lacks permission to read the spaceEnsure the Atlassian account has View permission on the space
Space not foundWrong Space KeyCheck 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:

Re-index API
POST /api/admin/reindex
Content-Type: application/json

{ "trialAccountId": 123 }