tenant_id
as a query parameter, that ID will be used. If not provided, the service generates a new tenant_id
and returns it.
Hit the
Try it
button to try this API now in our playground. It’s the best way to check the full request and response in one place, customize your parameters, and generate ready-to-use code snippets.Sample Request:
Important: When a tenant is created, Cortex automatically creates a DEFAULT sub-tenant that acts as a global space for that tenant. Any documents ingested or API calls made with the
tenant_id
but without specifying a sub_tenant_id
will automatically reference this default sub-tenant.Creating Additional Sub-Tenants
No Separate API Required: Cortex doesn’t require a separate API call to create additional sub-tenants. Sub-tenants are created automatically when you first use a newsub_tenant_id
that doesn’t exist yet.
How Sub-Tenant Creation Works
- Automatic Creation: When you upload content with a
sub_tenant_id
that doesn’t exist, Cortex automatically creates that sub-tenant - First Upload Triggers Creation: The first API call with a new
sub_tenant_id
will create the sub-tenant and then process your content - Immediate Availability: Once created, the sub-tenant is immediately available for all subsequent operations
Sub-Tenant ID Best Practices
For B2C Applications (Individual Users):Naming Convention: Use consistent prefixes like
user_
, dept_
, or project_
to make the purpose of each sub-tenant clear. Avoid special characters and keep names descriptive but concise.Important: Tenant metadata keys are immutable once set during tenant creation. Choose your keys carefully as they cannot be modified later. Document metadata remains fully flexible and can be set per document during upload.
Reserved Keywords
The following keywords are reserved and cannot be used as keys intenant_metadata_schema
:
source_id
source_title
source_url
source_type
source_collection
source_owner
source_collaborator
source_upload_time
source_last_updated_time
chunk_id
chunk_uuid
chunk_content
document_metadata
base_metadata
layout
description
Metadata Schema Structure
Each schema object in thetenant_metadata_schema
array should specify:
- key: The metadata field name (immutable once set)
- type: Data type (see supported types below)
- searchable: Whether this field can be used in search queries
- filterable: Whether this field can be used for filtering
Supported Metadata Types
Cortex supports a comprehensive range of data types for metadata fields:Primitive Types
Type | Description | Example Values | Use Cases |
---|---|---|---|
string | Text data | "Engineering" , "SOC2" , "confidential" | Categorical data, identifiers, labels |
number | Numeric values | 5 , 100.5 , 2024 | Quantitative metrics, versions, priorities |
boolean | True/false values | true , false | Binary flags, status indicators |
date | Date/time values | "2024-01-15T10:30:00Z" | Temporal data, audit trails |
Complex Types
Type | Description | Example Values | Use Cases |
---|---|---|---|
object | Structured data | {"city": "SF", "country": "USA"} | Hierarchical relationships, nested data |
array | Multiple values | ["security", "api", "compliance"] | Multi-value attributes, tags, categories |
Searchable vs Filterable Flags
Understanding the difference betweensearchable
and filterable
is crucial for optimal metadata design:
1. Searchable Fields
- Purpose: Fields that can be used in semantic search queries and QnA operations
- Behavior: Content is indexed for AI-powered search and question answering
- Use When: You want users to find documents by asking questions about these fields
- Example:
"Which documents are from the Engineering department?"
- Purpose: Fields that can be used for precise filtering and exact matching
- Behavior: Content is indexed for fast exact-match filtering operations
- Use When: You want to narrow down results with precise criteria
- Example:
department = "Engineering" AND status = "active"
Comprehensive Examples
Enterprise Setup - Multi-Department OrganizationMetadata Best Practices
1. Naming Conventions- Use snake_case:
business_unit
instead ofbusinessUnit
- Be descriptive:
data_classification_level
instead ofclassification
- Use consistent prefixes:
compliance_*
,security_*
,business_*
- Strings: For categorical data, identifiers, and labels
- Numbers: For quantitative metrics, versions, and priorities
- Booleans: For binary flags and status indicators
- Dates: For temporal data and audit trails
- Arrays: For multi-value fields like tags and categories
- Objects: For structured, hierarchical data
- Make searchable: Fields users will ask questions about
- Make filterable: Fields used for precise result narrowing
- Combine both: For fields used in both semantic search and filtering
- Filterable only: For sensitive data or exact-match requirements
- Limit total fields: Keep metadata schema focused and purposeful
- Use appropriate types: Choose the most specific type for your data
- Consider query patterns: Design for your most common use cases
- Plan for growth: Design schema to accommodate future needs
How Metadata Works in Practice
Once you’ve defined your tenant metadata schema, here’s how it works with your documents:Document Upload with Metadata
When you upload documents, you’ll provide both tenant and document metadata:Query Examples
With the metadata schema defined above, users can perform sophisticated queries:Semantic Search (Searchable Fields)
- Searches through
department
(searchable: true) - Searches through
compliance_framework
(searchable: true) - Searches through document content and titles
Precise Filtering (Filterable Fields)
- Exact match on
department
(filterable: true) - Exact match on
data_classification
(filterable: true) - Exact match on
is_confidential
(filterable: true)
Combined Queries
- Semantic search for “SOC2 compliance” (searchable fields)
- Precise filter:
business_unit = "Product"
(filterable: true)
Real-World Use Cases
1. Legal Document Management
Schema: Practice area, client ID, confidentiality level, jurisdiction Query: “Find all corporate law documents for client ACME that are not confidential” Filter:practice_area = "corporate_law" AND client_id = "ACME" AND confidentiality_level != "confidential"
2. Engineering Documentation
Schema: Product line, team, component, priority, tags Query: “Show me all high-priority API documentation from the backend team” Filter:product_line = "API" AND team = "backend" AND priority >= 4
3. HR Document Management
Schema: Department, employee type, salary band, status Query: “Find all active full-time employees in the Engineering department” Filter:department = "Engineering" AND employee_type = "full_time" AND status = "active"
Metadata Inheritance
All documents in your tenant automatically inherit the tenant metadata schema you define. This means:- Consistency: Every document will have the same tenant metadata structure
- Compliance: Organizational policies are enforced across all documents
- Queryability: You can always filter and search by tenant-level attributes
- Scalability: New documents automatically follow your established schema
Migration and Updates
Schema Immutability: Once you create a tenant with a metadata schema, the keys cannot be changed. However, you can:
- Add new fields to document metadata (fully flexible)
- Update values for existing tenant metadata fields
- Create new sub-tenants with different schemas if needed
Note:
- The
tenant_metadata_schema
field in the request body is optional but recommended for enterprise setups. It defines immutable tenant-level metadata keys that will apply to all documents in this tenant.- For more detailed information about metadata usage, filtering, and querying, see our Metadata documentation.
Sample Response
Functionality
- Accepts an optional
tenant_id
via query - Generates a new
tenant_id
if none is provided - Creates and persists the tenant
- Returns the final
tenant_id
and a confirmation message
Note: If your use case is to directly upload and search embeddings (without document/text ingestion), use the dedicated embeddings-tenant endpoint instead:/embeddings/create_tenant
. This setssub_tenant_id = tenant_id
and prepares the tenant for embeddings-first workloads.
Error Responses
All endpoints return consistent error responses following the standard format. For detailed error information, see our Error Responses documentation.Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Query Parameters
Unique identifier for the tenant/organization
Example:
"tenant_1234"
Example:
"<str>"
Body
application/json
Example:
[
{
"key": "department",
"type": "string",
"searchable": true,
"filterable": true
},
{
"key": "compliance_framework",
"type": "string",
"searchable": true,
"filterable": false
},
{
"key": "data_classification",
"type": "string",
"searchable": false,
"filterable": true
}
]
Response
Successful Response
Current status of the tenant creation process
Example:
"created"
Unique identifier assigned to the new tenant
Example:
"tenant_1234"
Indicates whether the tenant creation was successful
Example:
true
Response message describing the creation result