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

# Disparar evento

> Dispara um evento e inicia as automações ligadas a ele.



## OpenAPI

````yaml /automations-api/api-reference/openapi-automations.json post /v1/events/send
openapi: 3.0.3
info:
  title: 'Notifique API v1: Automações e eventos'
  version: 1.0.0
  description: >-
    Definição de **eventos** (nome + schema opcional do `payload`),
    **automações** em grafo (gatilho por evento ou **mensagem recebida** em
    canal, delays, condições, inclusive com **`source: "message"`** no inbound,
    **`endFlow`** para encerrar um ramo, envios multicanal, atualização de
    contato, etc.) e **disparo** via `POST /v1/events/send`. Autenticação:
    `Authorization: Bearer sk_live_...` ou header `x-api-key`. Todos os corpos
    usam **camelCase**.


    **Escopos:** `events:read` | `events:write` | `automations:read` |
    `automations:write`. O motor de envio dos passos (`sendTemplate`, e-mails
    diretos, etc.) ainda exige as chaves de envio dos canais correspondentes.


    **Paginação:** query `page` (≥1, padrão 1) e `limit` (1 a 100, padrão 20),
    como strings ou números coerentes.


    **Workspace bloqueado** responde **402** com `Payment Required`.


    **Onboarding:** em qualquer rota `/v1`, se a conta ainda não concluiu o
    onboarding, o middleware responde **403** com `code: ONBOARDING_REQUIRED`
    (corpo semelhante aos outros 403).
servers:
  - url: https://api.notifique.dev
    description: Produção
security:
  - ntfAutoBearerAuth: []
  - ntfAutoApiKeyHeader: []
tags:
  - name: Eventos
    description: CRUD de definições de evento + disparo `POST /v1/events/send`.
  - name: Automações
    description: CRUD de automações, stop e listagem de runs.
  - name: Runs
    description: Histórico e detalhe de execuções (`AutomationRun` + passos).
paths:
  /v1/events/send:
    post:
      tags:
        - Eventos
      summary: Disparar evento
      description: Dispara um evento e inicia as automações ligadas a ele.
      operationId: ntfAuto_sendEvent
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
            maxLength: 256
          description: Chave única por disparo lógico no workspace.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NtfAuto_EventSendBody'
      responses:
        '200':
          $ref: '#/components/responses/NtfAuto_EventSend200'
        '400':
          $ref: '#/components/responses/NtfAuto_EventSend400'
        '401':
          $ref: '#/components/responses/NtfAuto_401'
        '402':
          $ref: '#/components/responses/NtfAuto_402'
        '403':
          $ref: '#/components/responses/NtfAuto_403EventsWrite'
        '404':
          $ref: '#/components/responses/NtfAuto_EventSend404'
components:
  schemas:
    NtfAuto_EventSendBody:
      type: object
      required:
        - event
      properties:
        event:
          type: string
          maxLength: 256
          description: Nome igual ao cadastro em `POST /v1/events`.
        payload:
          type: object
          additionalProperties: true
          description: Objeto; campos obrigatórios e tipos vêm de `schemaJson`.
        contactId:
          type: string
          description: Mutuamente exclusivo com email/phone.
        email:
          type: string
          format: email
        phone:
          type: string
          description: 'E.164 recomendado (ex.: +5511999990000).'
      description: Exatamente **um** entre `contactId`, `email`, `phone` deve ser enviado.
    NtfAuto_EventSendResponse:
      type: object
      required:
        - success
        - data
      properties:
        success:
          type: boolean
          enum:
            - true
        data:
          type: object
          required:
            - runs
          properties:
            runs:
              type: array
              items:
                type: object
                required:
                  - runId
                  - automationId
                properties:
                  runId:
                    type: string
                  automationId:
                    type: string
            idempotentReplay:
              type: boolean
              description: Presente quando a resposta veio de cache de idempotência.
    NtfAuto_ErrorSend400:
      type: object
      required:
        - success
        - error
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: string
          description: Mensagem humana (pode repetir o sentido de `code`).
        code:
          type: string
          enum:
            - RESERVED_EVENT
            - RECIPIENT_REQUIRED
            - INVALID_PAYLOAD
            - MISSING_PAYLOAD_FIELD
            - PAYLOAD_TYPE_MISMATCH
            - EVENT_NOT_DEFINED
            - CONTACT_NOT_FOUND
            - INVALID_EVENT_SCHEMA
    NtfAuto_ErrorEnvelope401:
      type: object
      required:
        - success
        - error
        - message
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: string
          example: Unauthorized
        message:
          type: string
    NtfAuto_ErrorPaymentRequired:
      type: object
      required:
        - success
        - error
        - message
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: string
          enum:
            - Payment Required
        message:
          type: string
          example: Plan expired or suspended
    NtfAuto_ErrorForbiddenScope:
      type: object
      required:
        - success
        - error
        - message
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: string
          enum:
            - Forbidden
        message:
          type: string
  responses:
    NtfAuto_EventSend200:
      description: >-
        Disparo aceito. `runs` pode ser vazio; `idempotentReplay` quando a mesma
        `Idempotency-Key` já foi processada.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NtfAuto_EventSendResponse'
          examples:
            withRuns:
              value:
                success: true
                data:
                  runs:
                    - runId: clrunxxxxxxxxxxxxxxxxx
                      automationId: clautyyyyyyyyyyyyyyyyy
            idempotent:
              value:
                success: true
                data:
                  runs:
                    - runId: clrunxxxxxxxxxxxxxxxxx
                      automationId: clautyyyyyyyyyyyyyyyyy
                  idempotentReplay: true
            noAutomations:
              value:
                success: true
                data:
                  runs: []
    NtfAuto_EventSend400:
      description: >-
        `event` ausente, prefixo reservado, `payload` inválido frente ao schema,
        ou destinatário inválido.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NtfAuto_ErrorSend400'
          examples:
            missingEvent:
              value:
                success: false
                error: Bad Request
                message: event is required
                code: BAD_REQUEST
            reserved:
              value:
                success: false
                error: Event name uses reserved prefix
                code: RESERVED_EVENT
                message: Event name uses reserved prefix
            recipient:
              value:
                success: false
                error: Provide exactly one of contactId, email, or phone
                code: RECIPIENT_REQUIRED
                message: Provide exactly one of contactId, email, or phone
            payloadObject:
              value:
                success: false
                error: payload must be an object
                code: INVALID_PAYLOAD
                message: payload must be an object
            missingField:
              value:
                success: false
                error: 'Missing required field: plan'
                code: MISSING_PAYLOAD_FIELD
                message: 'Missing required field: plan'
            typeMismatch:
              value:
                success: false
                error: Field userId must be a string
                code: PAYLOAD_TYPE_MISMATCH
                message: Field userId must be a string
    NtfAuto_401:
      description: >-
        Chave ausente ou inválida. No middleware global de `/v1` também ocorre
        quando não há API Key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NtfAuto_ErrorEnvelope401'
          examples:
            route:
              value:
                success: false
                error: Unauthorized
                message: Invalid or missing API Key
                code: UNAUTHORIZED
            middleware:
              value:
                success: false
                error: Unauthorized
                message: >-
                  API Key is required. Provide Authorization: Bearer <key> or
                  x-api-key header.
                code: UNAUTHORIZED
    NtfAuto_402:
      description: Plano expirado ou workspace suspenso.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NtfAuto_ErrorPaymentRequired'
          example:
            success: false
            error: Payment Required
            message: Plan expired or suspended
            code: WORKSPACE_BLOCKED
    NtfAuto_403EventsWrite:
      description: Sem escopo `events:write`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NtfAuto_ErrorForbiddenScope'
          example:
            success: false
            error: Forbidden
            message: 'Missing scope: events:write'
            code: FORBIDDEN
    NtfAuto_EventSend404:
      description: Evento não cadastrado ou contato não encontrado.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NtfAuto_ErrorSend400'
          examples:
            event:
              value:
                success: false
                error: Event is not registered for this workspace
                code: EVENT_NOT_DEFINED
                message: Event is not registered for this workspace
            contact:
              value:
                success: false
                error: Contact not found
                code: CONTACT_NOT_FOUND
                message: Contact not found
  securitySchemes:
    ntfAutoBearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: '`Authorization: Bearer sk_live_...`'
    ntfAutoApiKeyHeader:
      type: apiKey
      in: header
      name: x-api-key
      description: Mesmo valor da chave, sem prefixo Bearer.

````