Multi-Tenancy

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

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 log, thread, orupsert 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

Last updated