:active → Tenant created, schema not yet provisioned
:provisioned → PostgreSQL schema created and ready for use
:suspended → Access disabled (data preserved)
:deleted → Soft delete (schema can be deprovisioned)
The tenant library provides multi-tenancy with PostgreSQL schema-per-tenant isolation.
| Multi-tenancy requires PostgreSQL. It is not available with SQLite or H2. |
:active → Tenant created, schema not yet provisioned
:provisioned → PostgreSQL schema created and ready for use
:suspended → Access disabled (data preserved)
:deleted → Soft delete (schema can be deprovisioned)
Slugs must be lowercase alphanumeric with hyphens, 2–100 characters:
(tenant/valid-slug? "acme-corp") ;=> true
(tenant/valid-slug? "ACME") ;=> false (uppercase)
(tenant/valid-slug? "acme_corp") ;=> false (underscore)
;; Slug → PostgreSQL schema name
(tenant/slug->schema-name "acme-corp") ;=> "tenant_acme_corp"
# Create tenant
curl -X POST http://localhost:3000/api/tenants \
-H "Content-Type: application/json" \
-d '{"name": "ACME Corp", "slug": "acme-corp"}'
# Provision (creates PostgreSQL schema)
curl -X POST http://localhost:3000/api/tenants/acme-corp/provision \
-H "Authorization: Bearer <admin-token>"
# Suspend
curl -X POST http://localhost:3000/api/tenants/acme-corp/suspend \
-H "Authorization: Bearer <admin-token>"
# Activate
curl -X POST http://localhost:3000/api/tenants/acme-corp/activate \
-H "Authorization: Bearer <admin-token>"
(require '[boundary.tenant.shell.provisioning :as provisioning])
(provisioning/with-tenant-schema db-ctx "tenant_acme_corp"
(fn [tx]
;; Sets: SET search_path TO tenant_acme_corp, public
(jdbc/execute! tx ["SELECT * FROM orders"])))
:boundary/tenant-service
{:db #ig/ref :boundary/db
:cache #ig/ref :boundary/cache ; optional
:job-queue #ig/ref :boundary/job-queue} ; optional
See tenant library for the full reference.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |