Skip to main content

AI Assistants - Create Thread

Endpoint

/i/ai-assistants/create-thread

Enterprise Only
This API is available exclusively in Countly Enterprise.

Overview

Creates a fresh thread for the authenticated member and app.
If an existing thread is present for the same member/app, it is deleted first.

Authentication

Authentication Methods:

  • API Key (parameter): api_key=YOUR_API_KEY
  • Auth Token (parameter): auth_token=YOUR_AUTH_TOKEN
  • Auth Token (header): countly-token: YOUR_AUTH_TOKEN

Permissions

  • Requires an authenticated Countly user.

Request Parameters

ParameterTypeRequiredDescription
api_keyStringYes (or auth_token)API key authentication
auth_tokenStringYes (or api_key)Auth token authentication
app_idStringYesApp ID for thread scope

Response

Success Response

{
"_id": "65a7c1e6f1c2a40001abc123",
"appId": "64afe321d5f9b2f77cb2c8ed",
"memberId": "64b0a2a0f1c2a40001def456",
"createdOn": "2026-02-15T10:30:00.000Z",
"messages": []
}

Response Fields

FieldTypeDescription
_idStringNew thread ID
appIdStringApp ID tied to thread
memberIdStringThread owner member ID
createdOnStringThread creation timestamp
messagesArrayThread messages (empty on creation)

Error Responses

  • HTTP 400 - Invalid parameters:
{
"result": "Invalid parameters: <details>"
}
  • HTTP 400 - Missing auth parameters:
{
"result": "Missing parameter \"api_key\" or \"auth_token\""
}
  • HTTP 401 - User/auth validation failed:
{
"result": "User does not exist"
}
  • HTTP 500 - Creation failed:
{
"result": "Thread couldn't be created"
}

Behavior/Processing

  1. Validates user authentication.
  2. Validates required input (app_id).
  3. Deletes existing member/app thread (if present).
  4. Creates and returns a new thread.

Database Collections

CollectionUsed forData touched by this endpoint
countly.ai_assistants_threadsEndpoint data sourceStores endpoint-related records this endpoint reads or modifies.

Examples

Example: Create a fresh thread

curl "https://your-server.com/i/ai-assistants/create-thread?api_key=YOUR_API_KEY&app_id=YOUR_APP_ID"

Ⓔ Enterprise

This feature is part of Countly Enterprise.

Get Access:

Already a Customer? Use support portal if you have any questions.

Last Updated

2026-02-15

Last Updated

2026-02-16