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

# Execute a single automation/script action

> Executa uma ação do editor de automação/script como na execução real (templates, notify, choose/repeat) e devolve o resultado de cada passo e a resposta do service (ex.: camera.snapshot). Nada é gravado no histórico. Espera no máximo 60s.



## OpenAPI

````yaml https://portal.unicontrol.me/v1/openapi post /v1/actions/execute
openapi: 3.1.0
info:
  title: Unicontrol API
  description: Welcome
  version: 1.0.0
servers:
  - url: http://0.0.0.0:3000
    description: Local Server
  - url: https://portal.test.flexhome.casa
    description: Development
  - url: https://portal.unicontrol.me
    description: Production
security:
  - bearerAuth: []
paths:
  /v1/actions/execute:
    post:
      tags:
        - Scripts
      summary: Execute a single automation/script action
      description: >-
        Executa uma ação do editor de automação/script como na execução real
        (templates, notify, choose/repeat) e devolve o resultado de cada passo e
        a resposta do service (ex.: camera.snapshot). Nada é gravado no
        histórico. Espera no máximo 60s.
      operationId: postV1ActionsExecute
      parameters:
        - in: header
          name: X-Organization-Id
          required: false
          schema:
            type: string
          description: >-
            ID da organização para contexto (opcional). Quando presente, filtra
            recursos da org.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - action
              properties:
                action:
                  type: object
                  description: Ação no mesmo formato de `actions` da automação/script
                resource:
                  type: string
                  enum:
                    - automations
                    - scripts
                  description: >-
                    Editor de origem, usado na checagem de permissão (padrão:
                    scripts)
                variables:
                  type: object
                  description: >-
                    Variáveis iniciais (respostas de ações anteriores já
                    executadas, ex.: `{ snapshot: {...} }`)
            example:
              action:
                action: service
                service: camera.snapshot
                target:
                  entity_id: onvif.camera.entrada
              resource: automations
      responses:
        '200':
          description: Resultado da execução
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - success
                      - failed
                      - timeout
                  error:
                    type: string
                    nullable: true
                  response:
                    description: Resposta do service, quando houver
                  variables:
                    type: object
                  steps:
                    type: array
                    items:
                      type: object
                  duration_ms:
                    type: integer
        '400':
          description: Dados inválidos
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
              example:
                message: validation error
        '401':
          description: Não autenticado
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
              example:
                error: unauthorized
        '403':
          description: Acesso negado
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
              example:
                error: forbidden
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.