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

# Quick Start

> Cadastre um evento, monte uma jornada simples e dispare pela API.

<Tip>
  **Evento** = nome do fato (`user.created`). **Automação** = grafo com gatilho + passos. Dispare com **Enviar evento** e use **`Idempotency-Key`** contra duplicata.
</Tip>

## Em poucas palavras

* Um passo **`trigger`** por fluxo; ligações em **`connections`**
* Passo **`condition`:** sempre saídas `"true"` e `"false"`
* Envios no fluxo exigem escopos de canal (`email:send`, etc.)

Contexto: [Introdução](/automations-api/como-funciona/introducao). Escopos: [Escopos da API Key](/automations-api/como-funciona/escopos-da-api-key).

## Antes de começar

* Escopos: `events:read`, `events:write`, `automations:read`, `automations:write`
* Pelo menos **um template** criado (anote os IDs)
* Auth: `Authorization: Bearer sk_live_...` ou `x-api-key`
* Base URL: `https://api.notifique.dev`

***

## 1. Registrar o evento

#### 1A, Pelo painel

**Automações → Eventos** → cadastre o nome e o schema do payload (opcional).

#### 1B, Pela API

Escopo: **`events:write`**.

```http theme={null}
POST /v1/events
Content-Type: application/json
Authorization: Bearer sk_live_xxxxx
```

```json theme={null}
{
  "name": "user.created",
  "schemaJson": {
    "userId": "string",
    "plan": "string"
  }
}
```

`schemaJson` é opcional, se existir, valida o `payload` no disparo.

***

## 2. Criar a automação

Escopo: **`automations:write`**.

```http theme={null}
POST /v1/automations
Content-Type: application/json
Authorization: Bearer sk_live_xxxxx
```

Exemplo: boas-vindas + e-mail após 3 dias.

```json theme={null}
{
  "name": "Boas-vindas e dicas em 3 dias",
  "status": "ENABLED",
  "graph": {
    "steps": [
      {
        "stepKey": "t1",
        "stepType": "trigger",
        "config": { "eventName": "user.created" }
      },
      {
        "stepKey": "sWelcome",
        "stepType": "sendTemplate",
        "config": {
          "templateId": "YOUR_WELCOME_TEMPLATE_ID",
          "channels": ["email"],
          "variables": { "name": "{{plan}}" }
        }
      },
      {
        "stepKey": "d1",
        "stepType": "delay",
        "config": { "durationMs": 259200000 }
      },
      {
        "stepKey": "sTips",
        "stepType": "sendTemplate",
        "config": {
          "templateId": "YOUR_TIPS_TEMPLATE_ID",
          "channels": ["email"],
          "variables": { "name": "{{plan}}" }
        }
      }
    ],
    "connections": [
      { "from": "t1", "to": "sWelcome" },
      { "from": "sWelcome", "to": "d1" },
      { "from": "d1", "to": "sTips" }
    ]
  }
}
```

`259200000` ms = 3 dias. Troque os IDs dos templates.

***

## 3. Disparar o evento

Escopo: **`events:write`**. Header opcional: `Idempotency-Key: onboarding-001`

```http theme={null}
POST /v1/events/send
Content-Type: application/json
Authorization: Bearer sk_live_xxxxx
Idempotency-Key: onboarding-001
```

```json theme={null}
{
  "event": "user.created",
  "email": "nova.pessoa@example.com",
  "payload": {
    "userId": "usr_123",
    "plan": "pro"
  }
}
```

Destinatário: **um** entre `contactId`, `email` ou `phone` (E.164).

Resposta esperada:

```json theme={null}
{
  "success": true,
  "data": {
    "runs": [
      { "runId": "clxx...", "automationId": "clyy..." }
    ]
  }
}
```

Várias automações no mesmo `eventName` → **várias** runs.

***

## 4. Ver execuções

Escopo: **`automations:read`**.

```http theme={null}
GET /v1/automations/:id/runs
Authorization: Bearer sk_live_xxxxx
```

Detalhe de uma run: `GET /v1/automations/:automationId/runs/:runId`, veja spec **Automações e eventos** no menu.

***

## Próximos passos

* [Eventos](/automations-api/como-funciona/eventos): boas práticas de nome e payload
* [Assistentes](/automations-api/como-funciona/assistentes): passo IA no grafo
* [Casos de uso](/automations-api/como-funciona/casos-de-uso): chatbot, follow-up, etc.
* [Templates](/template-api/como-funciona/quick-start)
