tenant
Manage tenants within projects for multi-tenant isolation.
Synopsis
bash
pfy tenant <subcommand> [flags]Aliases: tn
Description
Tenants provide multi-tenant isolation within a project. Each tenant has separate data, configuration, and applications while sharing the same project infrastructure.
Subcommands
list- List all tenants in a projectcreate- Create a new tenant
tenant list
List all tenants within a specific project.
Usage
bash
pfy tenant list --project <project-slug> [flags]Flags
| Flag | Required | Description |
|---|---|---|
--project | Yes | Project slug to list tenants from |
Example
bash
pfy tenant list --project my-saasOutput:
Tenants:
- Development (dev): Development environment
- Staging (staging): Pre-production testing
- Production (prod): Live production environmentVerbose output:
bash
pfy --verbose tenant list --project my-saasConnecting to ProductifyFW manager...
Fetching tenants for project 'my-saas'...
Found 3 tenant(s)
Tenants:
- Development (dev): Development environment
ID: 11111111-2222-3333-4444-555555555555
- Staging (staging): Pre-production testing
ID: 22222222-3333-4444-5555-666666666666
- Production (prod): Live production environment
ID: 33333333-4444-5555-6666-777777777777tenant create
Create a new tenant within a project.
Usage
bash
pfy tenant create \
--project-id <id> \
--slug <slug> \
--name <name> \
[--description <desc>]Flags
| Flag | Required | Description |
|---|---|---|
--project-id | Yes | Project ID (not slug) |
--slug | Yes | Tenant slug (unique within project) |
--name | Yes | Tenant display name |
--description | No | Tenant description |
Examples
Basic creation:
bash
pfy tenant create \
--project-id 01234567-89ab-cdef-0123-456789abcdef \
--slug dev \
--name "Development"With description:
bash
pfy tenant create \
--project-id 01234567-89ab-cdef-0123-456789abcdef \
--slug prod \
--name "Production" \
--description "Live production environment with customer data"Output:
Tenant created successfully: Production (prod)Verbose output:
bash
pfy --verbose tenant create \
--project-id 01234567-89ab-cdef-0123-456789abcdef \
--slug prod \
--name "Production" \
--description "Live production environment"Connecting to ProductifyFW manager...
Creating tenant 'prod' in project ID '01234567-89ab-cdef-0123-456789abcdef'...
Tenant created successfully: Production (prod)
ID: 33333333-4444-5555-6666-777777777777GraphQL Operations
GetTenants
graphql
query GetTenants(
$projectSlug: String!
$filters: [FilterInput!]
$order: [OrderInput!]
$pagination: PaginationInput
) {
tenants(
projectSlug: $projectSlug
filters: $filters
order: $order
pagination: $pagination
) {
id
slug
name
description
}
}CreateTenant
graphql
mutation CreateTenant($projectId: ID!, $input: CreateTenantInput!) {
createTenant(projectId: $projectId, input: $input) {
id
slug
name
description
}
}Common Workflows
Create environment-based tenants
bash
# Get project ID
PROJECT_ID=$(pfy project get --slug my-project | grep "ID:" | awk '{print $2}')
# Create dev tenant
pfy tenant create \
--project-id $PROJECT_ID \
--slug dev \
--name "Development" \
--description "Development and testing"
# Create staging tenant
pfy tenant create \
--project-id $PROJECT_ID \
--slug staging \
--name "Staging" \
--description "Pre-production validation"
# Create prod tenant
pfy tenant create \
--project-id $PROJECT_ID \
--slug prod \
--name "Production" \
--description "Live customer environment"Create customer-based tenants
bash
PROJECT_ID="01234567-89ab-cdef-0123-456789abcdef"
# Create tenant for customer A
pfy tenant create \
--project-id $PROJECT_ID \
--slug customer-a \
--name "Customer A Corp" \
--description "SaaS instance for Customer A"
# Create tenant for customer B
pfy tenant create \
--project-id $PROJECT_ID \
--slug customer-b \
--name "Customer B Inc" \
--description "SaaS instance for Customer B"List tenants and create application
bash
# List tenants to find the right one
pfy tenant list --project my-project
# Get tenant ID from the list
TENANT_ID="33333333-4444-5555-6666-777777777777"
# Create application in that tenant
pfy application create \
--tenant-id $TENANT_ID \
--slug webapp \
--name "Web Application" \
--version "1.0.0"Best Practices
- Environment-based tenants - Use
dev,staging,prodfor environments - Customer-based tenants - Use customer identifiers for SaaS isolation
- Consistent slugs - Use lowercase, hyphen-separated slugs
- Descriptive names - Include purpose in descriptions
- Plan hierarchy - Design tenant structure before creation
Multi-tenant Strategies
Environment Isolation
bash
# Separate environments within same project
pfy tenant create --project-id $ID --slug dev --name "Development"
pfy tenant create --project-id $ID --slug qa --name "QA"
pfy tenant create --project-id $ID --slug prod --name "Production"Customer Isolation
bash
# Separate customers in SaaS application
pfy tenant create --project-id $ID --slug acme-corp --name "Acme Corp"
pfy tenant create --project-id $ID --slug tech-startup --name "Tech Startup Inc"Geographic Isolation
bash
# Region-based tenants
pfy tenant create --project-id $ID --slug us-east --name "US East"
pfy tenant create --project-id $ID --slug eu-west --name "EU West"
pfy tenant create --project-id $ID --slug asia-pac --name "Asia Pacific"Error Handling
Tenant already exists
Error: failed to create tenant: tenant with slug 'dev' already exists in projectSolution: Choose a different slug or update the existing tenant.
Project not found
Error: failed to create tenant: project not foundSolution: Verify the project ID using pfy project get.
Invalid tenant slug
Error: failed to create tenant: invalid slug formatSolution: Use lowercase letters, numbers, and hyphens only.
See Also
- project - Manage projects
- Commands - All available commands
- Manager Multi-tenancy Concepts