🚧 We’re still putting the finishing touches on our platform

Create Tenant

Overview

The Create Tenant endpoint allows you to programmatically create new tenants (organizations/websites) in the system. Each tenant represents an isolated instance with its own database and domain configuration, enabling multi-tenancy architecture.

Endpoint Details

Create a new tenant in the system.

Endpoint: POST /api/tenants

Authentication: Required (Bearer Token)

Request Headers:

Content-Type: application/json
Accept: application/json
Authorization: Bearer YOUR_API_TOKEN

Request Body:

Field Type Required Description
email string No Email address of the user who will own the tenant. Must exist in the system. If not provided, a default user will be assigned.
name string No Name of the organization/tenant. Maximum 255 characters. If not provided, a name will be automatically generated.
subdomain string No Custom subdomain name for the tenant. Must be 3-63 characters long, contain only lowercase letters, numbers, and hyphens. Must start and end with a letter or number. Cannot contain consecutive hyphens or dots. Example: my-page (not my-page.qrweb.mn). If not provided, a random subdomain will be generated.

Request Body Example:

{
  "email": "[email protected]",
  "name": "My Organization",
  "subdomain": "my-organization"
}

All fields are optional. You can provide any combination or none at all.

Validation Rules:

subdomain field requirements:

  • Minimum 3 characters, maximum 63 characters
  • Only lowercase letters (a-z), numbers (0-9), and hyphens (-) are allowed
  • Must start with a letter or number
  • Must end with a letter or number
  • Cannot contain consecutive hyphens (--)
  • Cannot contain dots (.) - provide only the subdomain part, not the full domain
  • Valid examples: my-page, page123, test-site-1
  • Invalid examples: my page (spaces), My-Page (uppercase), -mypage (starts with hyphen), page.qrweb.mn (contains dot), my--page (consecutive hyphens)

Success Response (200 OK):

{
  "tenant_id": "860f5708-21eb-44bf-bb4f-ce1dbed2ede1"
}

Error Responses:

401 Unauthorized:

{
  "message": "Unauthorized"
}

404 Not Found (User not found):

{
  "message": "User not found"
}

422 Unprocessable Entity (Validation failed):

{
  "message": "The email field must be a valid email address. (and 2 more errors)",
  "errors": {
    "email": [
      "The email field must be a valid email address.",
      "The selected email is invalid."
    ],
    "subdomain": [
      "The subdomain field must be at least 3 characters.",
      "The subdomain field format is invalid."
    ]
  }
}

Usage Examples

cURL

Example:

curl -X POST https://webfluss.com/api/tenants \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -d '{"email": "[email protected]", "name": "My Organization", "subdomain": "my-organization"}'

Example Response:

{
  "tenant_id": "860f5708-21eb-44bf-bb4f-ce1dbed2ede1"
}

Postman

Environment Setup

Create a Postman environment with these variables:

  • base_url: https://webfluss.com
  • api_token: YOUR_API_TOKEN

1. Create Tenant Request

  1. Create a new request

    • Method: POST
    • URL: {{base_url}}/api/tenants
  2. Headers Tab

    Key Value
    Content-Type application/json
    Accept application/json
    Authorization Bearer {{api_token}}
  3. Body Tab

    • Select: raw
    • Type: JSON
    • Example:
      {
        "email": "[email protected]",
        "name": "Facebook Page Name",
        "subdomain": "my-organization"
      }