Context.ai
  • What is Context.ai?
  • List of Trackable Metrics
  • Product Analytics
    • Overview
    • Topic Categorisation
      • LLM Topics
    • User Engagement Tracking
    • Foreign Language Support
    • PII Filtering
    • Custom Metadata Filtering
    • Backfill Analytics Data
    • Custom Events
    • API Ingestion Methods
      • Log Conversation
      • [deprecated] Upsert Conversation
      • Thread Conversation
      • Patch Thread Message
      • API Resources
        • Chat Message
        • [deprecated] Tool Message
        • Custom Event
        • Metadata
        • Conversation
        • Thread
    • Embedded API
      • Multi-Tenancy
      • Conversations
        • Series Data
  • Integrations
    • Getting Started
    • Python SDK
    • Javascript SDK
    • LangChain Plugin
    • Haystack Plugin
    • Authorization
Powered by GitBook
On this page
  • Ingestion
  • Consuming Analytics
  • Example

Was this helpful?

  1. Product Analytics
  2. Embedded API

Multi-Tenancy

Details on how to support ingestion and analytics for multiple sub-organizations from a single Context.ai account.

PreviousEmbedded APINextConversations

Last updated 1 year ago

Was this helpful?

For embedded integrations, Context.ai supports ingesting and producing analytics that are scoped to to subtenants via a single integration. This means you can use the same API key to support generating analytics for multiple sub-accounts, with guaranteed isolation between your users.

Ingestion

To support multi-tenant ingestion, include a unique tenant_id field within each , , or request. The tenant ID can be any string under 40 characters, but must remain fixed across the lifetime of the tenant. You are responsible for generating and storing the unique identifier for each sub-account.

{
  "conversation": {
    "messages": [ ... ],
    "metadata": {
      "model": "gpt-3.5-turbo-16k",
      "user_id": "2947451"
    },
  },
  
  // This field should be set to a string that uniquely identifies the
  // tenant associated with this ingestion request.
  "tenant_id": "my_unique_customer_id_123"
}

Consuming Analytics

When using multi-tenant ingestion, analytics can also be consumed on a per-tenant basis. This means that all metrics and analysis will be specifically scoped each unique team_id.

To consume analytics for a sub-tenant, pass same tenant ID as a URL query parameter in all GET requests.

Example

A request to the below URL will fetch all conversations under the tenant with ID jGaCfkiPj2Zdhr3tIg21L.

GET https://api.context.ai/api/v1/conversations?tenant_id=jGaCfkiPj2Zdhr3tIg21L
log
thread
upsert