Multi-tenancy in Databunker Pro

Databunker Pro supports multi-tenancy, allowing you to manage multiple tenants within a single instance. This document outlines the API endpoints for creating, managing, and interacting with tenants.

Create Tenant

Creates a new tenant in the Databunker Pro system.

1
2
curl -H 'X-Bunker-Token: ROOT-ACCESS-TOKEN' -X POST /v2/TenantCreate \
     --data '{"tenantorg":"testorg","tenantname":"testname"}'

Request Body

Field Type Description
name string The name of the tenant. Must match the format: [a-z0-9]+
org string The organization slug associated with the tenant

Response

Field Type Description
status string Operation status (“ok” if successful)
xtoken string Tenant access token in UUID format

Example Response

1
2
3
4
{
  "status": "ok",
  "xtoken": "TENANT-ACCESS-TOKEN"
}

Notes

Create a Tenant User Account

You have two methods to specify the tenant name: you can either use the X-Bunker-Tenant HTTP header or include the tenant name in the hostname. If the X-Bunker-Tenant header is missing, Databunker Pro will attempt to retrieve the tenant name from the subdomain in the hostname. If neither option is available, a default tenant is used.

Example commands:

1
2
3
4
5
curl -H 'X-Bunker-Token: XXXXXXX' \
     -H 'X-Bunker-Tenant: TENANT-NAME' \
     -H 'Content-Type: application/json' \
     -X POST 'http://localhost:3000/v2/UserCreate' \
     --data '{"profile":{"firstname":"John","lastname":"Doe","email":"user@email.com","login":"john"}}'
1
2
3
curl -H 'X-Bunker-Token: XXXXXXX' \
     -X POST https://TENANT-NAME.databunker-domain.com/v2/UserCreate \
     --data '{"profile":{"firstname":"John","lastname":"Doe","email":"user@email.com","login":"john"}}'

Notes

Rename Tenant

Renames an existing tenant.

1
2
3
curl -H 'X-Bunker-Token: TENANT-ACCESS-TOKEN' \
     -X POST https://old-tenant.databunker-domain.com/v2/TenantUpdate \
     --data '{"tenantname":"new-name"}'

Request Body

Field Type Description
name string The new name for the tenant. Must match the format: [a-z0-9]+

Example Request

1
2
3
{
  "name": "new-name"
}

Response

Field Type Description
status string Operation status (“ok” if successful)

Example Response

1
2
3
{
  "status": "ok"
}

Other commands:

For a full list of API requests, check out the API document.

General Notes

  1. Tenant Name Format: Tenant names must follow the format [a-z0-9]+. This means they can only contain lowercase letters and numbers.

  2. Tenant-Specific URLs: After creating a tenant, you’ll interact with tenant-specific endpoints using URLs in the format https://tenant-name.databunker-domain.com/....

  3. Authentication: Most endpoints will require the TENANT-ACCESS-TOKEN for authentication. Include this token in the X-Bunker-Token header or as specified in the Databunker Pro documentation.

  4. SSL/TLS: Always use HTTPS for secure communication with the API endpoints.

For more detailed information on request/response formats, additional endpoints, or error handling, please refer to the complete Databunker Pro API documentation.

πŸ‘‹ Hello from the Databunker Team

Our developer team will be happy to customize Databunker for your specific needs!