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

> Create one or more operations based on the scope and targets sent. Currently available operation types: execute_microservice, delete_workspaces, shutdown_workspaces, restart_workspaces, and suspend_workspaces.



## OpenAPI

````yaml /en/api-reference/openapi.en-v1.json post /v1/organizations/{organization_id}/operations
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}/operations:
    post:
      tags:
        - Operations
      summary: Create operations
      description: >-
        Create one or more operations based on the scope and targets sent.
        Currently available operation types: execute_microservice,
        delete_workspaces, shutdown_workspaces, restart_workspaces, and
        suspend_workspaces.
      operationId: createOperations
      parameters:
        - name: organization id
          in: path
          required: true
          schema:
            type: string
            maxLength: 24
            pattern: ^[0-9a-f]{24}$
          description: Unique organization identifier.
          example: 507f1f77bcf86cd799439011
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateOperationV1Request'
            examples:
              workspace_scope:
                summary: Create operation on 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: Create operation on sessions
                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: Create delete_workspaces operation on workspaces
                value:
                  type: delete_workspaces
                  target:
                    type: workspaces
                    ids:
                      - 507f1f77bcf86cd799439011
                      - 507f1f77bcf86cd799439012
              shutdown_workspaces_workspace_scope:
                summary: Create shutdown_workspaces operation on workspaces
                value:
                  type: shutdown_workspaces
                  target:
                    type: workspaces
                    ids:
                      - 507f1f77bcf86cd799439011
              restart_workspaces_workspace_scope_with_expiration:
                summary: >-
                  Create restart_workspaces operation on workspaces with custom
                  expiration
                value:
                  type: restart_workspaces
                  target:
                    type: workspaces
                    ids:
                      - 507f1f77bcf86cd799439011
                  expiration_in_seconds: 1200
              suspend_workspaces_workspace_scope:
                summary: Create suspend_workspaces operation on workspaces
                value:
                  type: suspend_workspaces
                  target:
                    type: workspaces
                    ids:
                      - 507f1f77bcf86cd799439011
      responses:
        '201':
          description: Operations created successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateOperationV1Response'
              example:
                ids:
                  - organization_id: 507f1f77bcf86cd799439011
                    operation_id: 507f1f77bcf86cd799439031
        '400':
          $ref: '#/components/responses/BadRequest'
          description: >-
            Bad request. Common causes: unsupported type, invalid target.type,
            empty target.ids, expiration_in_seconds out of range, or payload not
            allowed for
            delete_workspaces/shutdown_workspaces/restart_workspaces/suspend_workspaces.
        '401':
          $ref: '#/components/responses/Unauthorized'
          description: Unauthorized.
        '404':
          $ref: '#/components/responses/NotFound'
          description: Organization not found.
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
          description: >-
            Unprocessable entity. Common causes: objectives cannot be resolved
            in the organization, or insufficient permissions on 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: Operation command type.
          enum:
            - execute_microservice
            - delete_workspaces
            - shutdown_workspaces
            - restart_workspaces
            - suspend_workspaces
        target:
          type: object
          description: Scope and objectives object.
          required:
            - type
            - ids
          properties:
            type:
              type: string
              description: >-
                Scope of targets. Only workspaces are allowed for
                delete_workspaces/shutdown_workspaces/restart_workspaces/suspend_workspaces.
              enum:
                - workspaces
                - sessions
            ids:
              type: array
              description: >-
                List of target identifiers. IDs are expected for workspaces;
                uppercase UUIDs are expected for sessions.
              minItems: 1
              maxItems: 20000
              items:
                type: string
                minLength: 1
                maxLength: 64
          additionalProperties: false
        expiration_in_seconds:
          type: integer
          maximum: 84600
          minimum: 600
          description: >-
            Custom expiration in seconds. If omitted, the command's default
            value is used.
        payload:
          type: object
          description: >-
            Specific load of the operation type. Payload is not allowed for
            delete_workspaces/shutdown_workspaces/restart_workspaces/suspend_workspaces.
          additionalProperties: true
      additionalProperties: false
    CreateOperationV1Response:
      type: object
      required:
        - ids
      properties:
        ids:
          type: array
          description: >-
            Identifiers of operations created in the same order as they were
            created.
          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: Identifier of the organization owning the operation.
              operation_id:
                type: string
                pattern: ^[0-9a-f]{24}$
                minLength: 24
                maxLength: 24
                description: Identifier of the created operation.
    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'
    UnprocessableEntity:
      description: Unprocessable Entity
      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

````