tenant_id as a query parameter, that ID will be used. If not provided, the service generates a new tenant_id and returns it.
Examples
- API Request
- TypeScript
- Python (Sync)
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_idthat doesn’t exist, Cortex automatically creates that sub-tenant - First Upload Triggers Creation: The first API call with a new
sub_tenant_idwill 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.Reserved Keywords
The following keywords are reserved and cannot be used as keys intenant_metadata_schema:
source_idsource_titlesource_urlsource_typesource_collectionsource_ownersource_collaboratorsource_upload_timesource_last_updated_timechunk_idchunk_uuidchunk_contentdocument_metadatabase_metadatalayoutdescription
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_unitinstead ofbusinessUnit - Be descriptive:
data_classification_levelinstead 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
Note:
- The
tenant_metadata_schemafield 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_idvia query - Generates a new
tenant_idif none is provided - Creates and persists the tenant
- Returns the final
tenant_idand 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_idand 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
Body
application/json
Example: