Terraform Multi-Tenant Agents (Shared)

Deploy the same agent for every customer, each isolated in their own ChatBotKit sub-account. One master token plus the provider's run_as attribute targets each sub-account through a provider alias - no per-customer tokens.

terraform
infrastructure-as-code
multi-tenant
1384

This example runs a multi-tenant product on ChatBotKit where every customer gets the same agent inside their own isolated sub-account - a "partner user" with its own bots, datasets, conversations, and settings.

Isolation comes from the provider's run_as attribute. You hold one partner/master token (CHATBOTKIT_API_KEY) and configure one provider alias per customer, each with run_as set to that customer's sub-account ID, which sends the X-RunAs-UserId header. There are no per-customer tokens - account IDs are not secret. This is the standard Terraform multi-account pattern, provider aliases, the same way the AWS provider uses assume_role.

The agent is defined once in a reusable module and deployed into each sub-account via its alias - no for_each. Improve the agent once and it ships to every customer on the next apply.

This is the foundation for white-label and B2B SaaS products where account separation, per-tenant limits, and reproducible provisioning matter.

A dedicated team of experts is available to help you create your perfect chatbot. Reach out via or chat for more information.