> ## 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.

# Crear un tenant

> Crea un nuevo tenant y una organización asociada para la organización propietaria especificada. El nombre del tenant también se usa como nombre de la organización recién creada. Requiere product_config_id. Admite opcionalmente la asignación de política.



## OpenAPI

````yaml /api-reference/openapi-v1.json post /v1/organizations/{organization_id}/tenants
openapi: 3.0.3
info:
  title: API Publica Portal
  version: 1.0.0
  description: Api publica REST para 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: Crear un tenant
      description: >-
        Crea un nuevo tenant y una organización asociada para la organización
        propietaria especificada. El nombre del tenant también se usa como
        nombre de la organización recién creada. Requiere product_config_id.
        Admite opcionalmente la asignación de política.
      operationId: createTenant
      parameters:
        - name: organization_id
          in: path
          required: true
          schema:
            type: string
            maxLength: 24
            pattern: ^[0-9a-f]{24}$
          description: >-
            El identificador único de la organización propietaria que creará el
            tenant
          example: 507f1f77bcf86cd799439011
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTenantRequestV1'
            examples:
              create-tenant-with-all-required-fields:
                summary: Crear un tenant con la información mínima requerida
                value:
                  name: Tenant de producción
                  product_config_id: 507f1f77bcf86cd799439030
                  organization_email: tenant@example.com
                  organization_language: en
                  organization_country: US
                  organization_industry: Tecnología
              create-tenant-with-optional-fields:
                summary: Crear un tenant con política
                value:
                  name: Tenant empresarial
                  product_config_id: 507f1f77bcf86cd799439030
                  policy_id: 507f1f77bcf86cd799439050
                  organization_email: enterprise@example.com
                  organization_language: es
                  organization_country: ES
                  organization_industry: Finanzas
      responses:
        '201':
          description: >-
            Tenant y organización asociados creados correctamente. Devuelve el
            recurso tenant creado.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TenantByIdV1'
        '400':
          $ref: '#/components/responses/BadRequest'
          description: >-
            Solicitud incorrecta. Causas comunes: - Cuerpo de solicitud o
            parámetros de ruta no válidos - Faltan campos obligatorios (name,
            product_config_id, organization_email, organization_language,
            organization_country, organization_industry) - Formato de id no
            válido
        '401':
          $ref: '#/components/responses/Unauthorized'
          description: No autorizado - se requiere autenticación
        '404':
          $ref: '#/components/responses/NotFound'
          description: No se encontró la organización propietaria
        '422':
          description: >-
            Entidad no procesable - Error de validación de lógica de negocio.
            Causas comunes: - Product config no encontrado - La organización no
            es elegible para crear tenants - La organización no existe en build
            - La organización no tiene productos elegibles - Relación de partner
            no válida - La organización y la organización padre son clientes
            finales - Entidad referenciada no encontrada
          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: ID de la organización del tenant
        create_date:
          type: string
          format: date-time
        name:
          type: string
        region:
          type: string
        product_id:
          type: string
          nullable: true
          description: ID del producto (nullable)
        policy_id:
          type: string
          nullable: true
          description: ID de la política (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: Solicitud incorrecta
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: No autorizado
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: No encontrado
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    TooManyRequests:
      description: Demasiadas solicitudes
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InternalServerError:
      description: Error interno del servidor
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````