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

> Crea una o varias operaciones en base al alcance y objetivos enviados. Tipos de operacion disponibles actualmente: execute_microservice, delete_workspaces, shutdown_workspaces, restart_workspaces y suspend_workspaces.



## OpenAPI

````yaml /api-reference/openapi-v1.json post /v1/organizations/{organization_id}/operations
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}/operations:
    post:
      tags:
        - Operaciones
      summary: Crear operaciones
      description: >-
        Crea una o varias operaciones en base al alcance y objetivos enviados.
        Tipos de operacion disponibles actualmente: execute_microservice,
        delete_workspaces, shutdown_workspaces, restart_workspaces y
        suspend_workspaces.
      operationId: createOperations
      parameters:
        - name: organization_id
          in: path
          required: true
          schema:
            type: string
            maxLength: 24
            pattern: ^[0-9a-f]{24}$
          description: Identificador unico de la organizacion.
          example: 507f1f77bcf86cd799439011
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateOperationV1Request'
            examples:
              workspace_scope:
                summary: Crear operacion sobre workspaces
                value:
                  type: execute_microservice
                  target:
                    type: workspaces
                    ids:
                      - 507f1f77bcf86cd799439011
                      - 507f1f77bcf86cd799439012
                  expiration_in_seconds: 600
                  payload:
                    microservice_id: 507f1f77bcf86cd799439015
                    parameters:
                      mode: safe
              session_scope:
                summary: Crear operacion sobre sesiones
                value:
                  type: execute_microservice
                  target:
                    type: sessions
                    ids:
                      - 550E8400-E29B-41D4-A716-446655440000
                      - 7F5C3F8D-8A9B-4C8D-B8D1-123456789ABC
                  payload:
                    microservice_id: 507f1f77bcf86cd799439015
                    parameters:
                      mode: safe
              delete_workspaces_workspace_scope:
                summary: Crear operacion delete_workspaces sobre workspaces
                value:
                  type: delete_workspaces
                  target:
                    type: workspaces
                    ids:
                      - 507f1f77bcf86cd799439011
                      - 507f1f77bcf86cd799439012
              shutdown_workspaces_workspace_scope:
                summary: Crear operacion shutdown_workspaces sobre workspaces
                value:
                  type: shutdown_workspaces
                  target:
                    type: workspaces
                    ids:
                      - 507f1f77bcf86cd799439011
              restart_workspaces_workspace_scope_with_expiration:
                summary: >-
                  Crear operacion restart_workspaces sobre workspaces con
                  expiracion personalizada
                value:
                  type: restart_workspaces
                  target:
                    type: workspaces
                    ids:
                      - 507f1f77bcf86cd799439011
                  expiration_in_seconds: 1200
              suspend_workspaces_workspace_scope:
                summary: Crear operacion suspend_workspaces sobre workspaces
                value:
                  type: suspend_workspaces
                  target:
                    type: workspaces
                    ids:
                      - 507f1f77bcf86cd799439011
      responses:
        '201':
          description: Operaciones creadas correctamente.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateOperationV1Response'
              example:
                ids:
                  - organization_id: 507f1f77bcf86cd799439011
                    operation_id: 507f1f77bcf86cd799439031
        '400':
          $ref: '#/components/responses/BadRequest'
          description: >-
            Solicitud incorrecta. Causas comunes: tipo no soportado, target.type
            invalido, target.ids vacio, expiration_in_seconds fuera de rango, o
            payload no permitido para
            delete_workspaces/shutdown_workspaces/restart_workspaces/suspend_workspaces.
        '401':
          $ref: '#/components/responses/Unauthorized'
          description: No autorizado.
        '404':
          $ref: '#/components/responses/NotFound'
          description: Organizacion no encontrada.
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
          description: >-
            Entidad no procesable. Causas comunes: objetivos no resolubles en la
            organizacion, o permisos insuficientes sobre reporting groups.
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    CreateOperationV1Request:
      type: object
      required:
        - type
        - target
      properties:
        type:
          type: string
          description: Tipo de comando de operacion.
          enum:
            - execute_microservice
            - delete_workspaces
            - shutdown_workspaces
            - restart_workspaces
            - suspend_workspaces
        target:
          type: object
          description: Objeto de alcance y objetivos.
          required:
            - type
            - ids
          properties:
            type:
              type: string
              description: >-
                Alcance de objetivos. Para
                delete_workspaces/shutdown_workspaces/restart_workspaces/suspend_workspaces
                solo se permite workspaces.
              enum:
                - workspaces
                - sessions
            ids:
              type: array
              description: >-
                Lista de identificadores objetivo. Para workspaces se esperan
                ids; para sessions se esperan UUID en mayuscula.
              minItems: 1
              maxItems: 20000
              items:
                type: string
                minLength: 1
                maxLength: 64
          additionalProperties: false
        expiration_in_seconds:
          type: integer
          maximum: 84600
          minimum: 600
          description: >-
            Expiracion personalizada en segundos. Si se omite se usa el valor
            por defecto del comando.
        payload:
          type: object
          description: >-
            Carga especifica del tipo de operacion. Para
            delete_workspaces/shutdown_workspaces/restart_workspaces/suspend_workspaces
            no se permite payload.
          additionalProperties: true
      additionalProperties: false
    CreateOperationV1Response:
      type: object
      required:
        - ids
      properties:
        ids:
          type: array
          description: >-
            Identificadores de operaciones creadas en el mismo orden de
            creación.
          minItems: 1
          items:
            type: object
            required:
              - organization_id
              - operation_id
            properties:
              organization_id:
                type: string
                pattern: ^[0-9a-f]{24}$
                minLength: 24
                maxLength: 24
                description: Identificador de la organización propietaria de la operación.
              operation_id:
                type: string
                pattern: ^[0-9a-f]{24}$
                minLength: 24
                maxLength: 24
                description: Identificador de la operación creada.
    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'
    UnprocessableEntity:
      description: Entidad no procesable
      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

````