Multitenancy
Learn how to organize and manage data for multiple tenants in SourceSync.
Overview
SourceSync supports multitenancy through three primary mechanisms:
- Native Tenant Support: Using
X-Tenant-ID
header for automatic tenant isolation - Namespaces: For complete data isolation between tenants
- Metadata: For flexible tenant-specific organization within namespaces
Choosing Your Approach
Native Tenant Support (Recommended)
Best for organizations that need:
- Automatic tenant isolation without infrastructure changes
- Simple tenant management with header-based control
- Flexible scaling across tenants
- Cost-effective multi-tenant deployments
Implementation:
-
Add the
X-Tenant-ID
header to your API requests:curl -X POST https://api.sourcesync.ai/v1/ingest/text \ -H "Authorization: Bearer $RAGAAS_API_KEY" \ -H "X-Tenant-ID: tenant-123" \ -H "Content-Type: application/json" \ -d '{ "namespaceId": "shared-namespace", "ingestConfig": { "source": "TEXT", "config": { "text": "Document content..." } } }'
-
Documents are automatically isolated by tenant:
- Each document is tagged with the tenant ID
- Search and retrieval automatically scoped to tenant
- No cross-tenant data access possible
-
Benefits:
- No need for separate infrastructure per tenant
- Automatic tenant isolation in shared namespaces
- Simplified tenant management
- Cost-effective scaling
Namespace-Based Isolation
Best for organizations that need:
- Complete data isolation between tenants
- Separate infrastructure per tenant
- Independent scaling and billing
- Compliance with data residency
Not suitable when:
- Content sharing between tenants is required
- Cost optimization is priority
- Managing many small tenants
Metadata-Based Organization
Best for organizations that need:
- Shared infrastructure across tenants
- Flexible content sharing
- Cost-effective solution
- Simple tenant management
Not suitable when:
- Strict data isolation is required
- Compliance requires separate infrastructure
Implementation
Using Namespaces
Create a dedicated namespace for each tenant:
curl -X POST https://api.sourcesync.ai/v1/namespaces \
-H "Authorization: Bearer $RAGAAS_API_KEY" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"name": "tenant1-production",
"fileStorageConfig": {
"provider": "S3",
"bucket": "tenant1-docs",
"region": "us-east-1",
"credentials": {
"accessKeyId": "...",
"secretAccessKey": "..."
}
},
"vectorStorageConfig": {
"provider": "PINECONE",
"apiKey": "...",
"indexHost": "tenant1.pinecone.io"
},
"embeddingModelConfig": {
"provider": "OPENAI",
"model": "text-embedding-3-small",
"apiKey": "..."
}
}'
Using Metadata
Add tenant information during document ingestion:
curl -X POST https://api.sourcesync.ai/v1/ingest/text \
-H "Authorization: Bearer $RAGAAS_API_KEY" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"namespaceId": "shared-namespace",
"ingestConfig": {
"source": "TEXT",
"config": {
"text": "Company policy document...",
"metadata": {
"tenantId": "tenant-123",
"department": "hr",
"accessLevel": "internal",
"region": "us-west"
}
}
}
}'
Filter content by tenant metadata:
curl -X POST https://api.sourcesync.ai/v1/search \
-H "Authorization: Bearer $RAGAAS_API_KEY" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"query": "company policy",
"namespaceId": "shared-namespace",
"filter": {
"metadata": {
"tenantId": "tenant-123",
"accessLevel": "internal"
}
}
}'
Examples
Document Search with Tenant Isolation
Search documents within a tenant's scope:
curl -X POST https://api.sourcesync.ai/v1/search \
-H "Authorization: Bearer $RAGAAS_API_KEY" \
-H "X-Tenant-ID: tenant-123" \
-H "Content-Type: application/json" \
-d '{
"query": "company policies",
"namespaceId": "shared-namespace",
"topK": 10,
"filter": {
"metadata": {
"status": "published"
}
}
}'
Document Management with Tenant Isolation
List documents for a specific tenant:
curl -X POST https://api.sourcesync.ai/v1/documents \
-H "Authorization: Bearer $RAGAAS_API_KEY" \
-H "X-Tenant-ID: tenant-123" \
-H "Content-Type: application/json" \
-d '{
"namespaceId": "shared-namespace",
"filterConfig": {
"documentTypes": ["PDF", "DOCX"],
"metadata": {
"status": "published"
}
},
"pagination": {
"pageSize": 10
}
}'
Best Practices
-
Organization
- Use clear naming conventions (e.g.,
{tenant}-{environment}
) - Define consistent metadata schema
- Separate production and non-production environments
- Use clear naming conventions (e.g.,
-
Security
- Implement tenant validation in your application
- Use metadata for access control
- Consider regulatory requirements
-
Performance
- Monitor resource usage per namespace
- Use appropriate metadata indexing
- Consider tenant size when choosing approach
Tenant ID Format
-
Use consistent, URL-safe tenant identifiers:
- Alphanumeric characters
- Hyphens and underscores
- Lowercase recommended
- Example:
tenant-123
,org-456-dept-789
-
Keep tenant IDs short but meaningful:
- Include organization identifier
- Add sub-organization if needed