> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flexxible.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a tenant

> Creates a new tenant and an associated organization for the specified owning organization. The tenant's name is also used as the name of the newly created organization. Requires product_config_id. Optionally supports policy assignment.



## OpenAPI

````yaml /en/api-reference/openapi.en-v1.json post /v1/organizations/{organization_id}/tenants
openapi: 3.0.3
info:
  title: Public Portal API
  version: 1.0.0
  description: Public REST API for portal
servers:
  - url: https://api.staging.flxwvdexternal.com
    description: Staging API server.
security:
  - bearerAuth: []
tags: []
paths:
  /v1/organizations/{organization_id}/tenants:
    post:
      tags:
        - Tenants
      summary: Create a tenant
      description: >-
        Creates a new tenant and an associated organization for the specified
        owning organization. The tenant's name is also used as the name of the
        newly created organization. Requires product_config_id. Optionally
        supports policy assignment.
      operationId: createTenant
      parameters:
        - name: organization id
          in: path
          required: true
          schema:
            type: string
            maxLength: 24
            pattern: ^[0-9a-f]{24}$
          description: >-
            The unique identifier of the owning organization that will create
            the tenant
          example: 507f1f77bcf86cd799439011
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTenantRequestV1'
            examples:
              create-tenant-with-all-required-fields:
                summary: Create a tenant with all required fields
                value:
                  name: Production Tenant
                  product_config_id: 507f1f77bcf86cd799439030
                  organization_email: tenant@example.com
                  organization_language: en
                  organization_country: US
                  organization_industry: Technology
              create-tenant-with-optional-fields:
                summary: Create a tenant with policy
                value:
                  name: Enterprise Tenant
                  product_config_id: 507f1f77bcf86cd799439030
                  policy_id: 507f1f77bcf86cd799439050
                  organization_email: enterprise@example.com
                  organization_language: es
                  organization_country: ES
                  organization_industry: Finance
      responses:
        '201':
          description: >-
            Tenant and associated organization successfully created. Returns the
            created tenant resource.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TenantByIdV1'
        '400':
          $ref: '#/components/responses/BadRequest'
          description: >-
            Bad Request. Common Causes: - Invalid request body or path
            parameters - Missing required fields (name, product_config_id,
            organization_email, organization_language, organization_country,
            organization_industry) - Invalid id format
        '401':
          $ref: '#/components/responses/Unauthorized'
          description: Unauthorized - authentication required
        '404':
          $ref: '#/components/responses/NotFound'
          description: Owner organization not found
        '422':
          description: >-
            Unprocessable entity - Business logic validation error. Common
            causes: - Product config not found - Organization not eligible to
            create tenants - Organization does not exist in build - Organization
            has no eligible products - Invalid partner relationship -
            Organization and parent organization are end customers - Referenced
            entity not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    CreateTenantRequestV1:
      type: object
      properties:
        name:
          type: string
          maxLength: 512
        product_config_id:
          type: string
          maxLength: 24
          pattern: ^[0-9a-f]{24}$
        policy_id:
          type: string
          maxLength: 24
          pattern: ^[0-9a-f]{24}$
        organization_email:
          type: string
          maxLength: 512
        organization_language:
          type: string
          maxLength: 512
        organization_country:
          type: string
          maxLength: 512
        organization_industry:
          type: string
          maxLength: 512
      required:
        - name
        - product_config_id
        - organization_email
        - organization_language
        - organization_country
        - organization_industry
    TenantByIdV1:
      type: object
      properties:
        id:
          type: string
        organization_id:
          type: string
          description: Tenant organization ID
        create_date:
          type: string
          format: date-time
        name:
          type: string
        region:
          type: string
        product_id:
          type: string
          nullable: true
          description: Product ID (nullable)
        policy_id:
          type: string
          nullable: true
          description: Policy ID (nullable)
      required:
        - id
        - organization id
        - create_date
        - name
        - region
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            code:
              type: string
            details:
              type: string
          required:
            - message
            - code
      required:
        - error
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    TooManyRequests:
      description: Too Many Requests
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InternalServerError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````