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

# Create a new organization

> Creates a new tenant organization in the hub Keycloak realm (server-generated UUID), default organization groups, a database record, and OpenFGA permissions. Display `name` is provided by the caller; Keycloak assigns `id` and `alias`. Automatically creates default organization groups and sets up permissions in OpenFGA.



## OpenAPI

````yaml /openapi/em-runtime-governance-v2.yaml post /governance/organizations
openapi: 3.1.0
info:
  title: em_runtime_governance
  version: 5.27.0
servers: []
security: []
paths:
  /governance/organizations:
    post:
      tags:
        - organizations
      summary: Create a new organization
      description: >-
        Creates a new tenant organization in the hub Keycloak realm
        (server-generated UUID), default organization groups, a database record,
        and OpenFGA permissions. Display `name` is provided by the caller;
        Keycloak assigns `id` and `alias`. Automatically creates default
        organization groups and sets up permissions in OpenFGA.
      operationId: create_organization
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OrganizationCreateRequest'
        required: true
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrganizationCreateResponse'
        '400':
          description: Invalid input or organization already exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unauthorized
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal Server Error
      security:
        - HTTPBearer: []
components:
  schemas:
    OrganizationCreateRequest:
      properties:
        name:
          type: string
          maxLength: 255
          minLength: 1
          title: Name
          description: Display name of the organization
        description:
          anyOf:
            - type: string
              maxLength: 500
            - type: 'null'
          title: Description
          description: Optional description of the organization
      type: object
      required:
        - name
      title: OrganizationCreateRequest
      description: Request body for creating a new organization.
    OrganizationCreateResponse:
      properties:
        id:
          type: string
          title: Id
          description: >-
            Keycloak organization UUID (tenant id for APIs, OpenFGA, and data
            scoping)
        name:
          type: string
          title: Name
          description: Display name of the organization
        alias:
          type: string
          title: Alias
          description: >-
            Keycloak organization alias (URL-safe slug for OIDC
            scope=organization:<alias>)
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: Description of the organization
        created_at:
          type: string
          format: date-time
          title: Created At
          description: Timestamp when the organization was created
      type: object
      required:
        - id
        - name
        - alias
        - created_at
      title: OrganizationCreateResponse
      description: Response after successfully creating an organization.
    ErrorResponse:
      properties:
        error:
          $ref: '#/components/schemas/ErrorBody'
      type: object
      required:
        - error
      title: ErrorResponse
      description: Standard error response model.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ErrorBody:
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
          title: Message
        details:
          additionalProperties: true
          type: object
          title: Details
        request_id:
          type: string
          title: Request Id
        timestamp:
          type: string
          format: date-time
          title: Timestamp
      type: object
      required:
        - code
        - message
        - request_id
        - timestamp
      title: ErrorBody
      description: Error body with structured details.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    ErrorCode:
      type: string
      enum:
        - INVALID_REQUEST
        - INVALID_TOKEN
        - INSUFFICIENT_PERMISSIONS
        - RESOURCE_NOT_FOUND
        - RESOURCE_ALREADY_EXISTS
        - VALIDATION_ERROR
        - RATE_LIMIT_EXCEEDED
        - SERVICE_UNAVAILABLE
        - INTERNAL_ERROR
      title: ErrorCode
      description: Standard error codes for API responses.
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````