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

# eventos de clientes

> todos os eventos relacionados a clientes

## lista de eventos

| evento                     | quando acontece                  |
| -------------------------- | -------------------------------- |
| `customer.created`         | novo cliente foi registrado      |
| `customer.updated`         | dados do cliente foram alterados |
| `customer.status.draft`    | cliente marcado como rascunho    |
| `customer.status.pending`  | cliente aguardando aprovação     |
| `customer.status.approved` | cliente foi aprovado             |
| `customer.status.blocked`  | cliente foi bloqueado            |
| `customer.status.inactive` | cliente foi inativado            |

## exemplo de payload

<Tabs>
  <Tab title="novo cliente">
    ```json theme={null}
    {
      "eventId": "3a7f1c2e-4b8d-4e9f-a2c1-6d3e5f7a9b0c",
      "eventType": "customer.created",
      "eventVersion": "1.0",
      "timestamp": "2026-04-16T11:53:00.245Z",
      "subscriptionId": "a8fa74b1-af91-4dde-b68b-82e06e1d51a1",
      "brand": {
        "id": "5d84bfd8-c9ae-44bc-acfb-dbc1721fa1be",
        "name": "nome da marca"
      },
      "entity": {
        "type": "customer",
        "id": "e6892af7-75d6-4036-8779-9d2ad1336dab",
        "href": "https://integration.teceo.co/v1/customers/e6892af7-75d6-4036-8779-9d2ad1336dab"
      },
      "data": {
        "commercialName": "Loja Centro",
        "status": "DRAFT"
      },
      "metadata": {
        "changedBy": {
          "type": "user",
          "id": "30cac3a9-ceb1-46db-bd94-038c8a7f9331",
          "name": "Nome do Usuário"
        }
      }
    }
    ```
  </Tab>

  <Tab title="dados alterados">
    ```json theme={null}
    {
      "eventId": "9b2e4d7f-1a3c-4f8e-b5d2-7c9a1e3f5b8d",
      "eventType": "customer.updated",
      "eventVersion": "1.0",
      "timestamp": "2026-04-16T14:20:00.123Z",
      "subscriptionId": "a8fa74b1-af91-4dde-b68b-82e06e1d51a1",
      "brand": {
        "id": "5d84bfd8-c9ae-44bc-acfb-dbc1721fa1be",
        "name": "nome da marca"
      },
      "entity": {
        "type": "customer",
        "id": "e6892af7-75d6-4036-8779-9d2ad1336dab",
        "href": "https://integration.teceo.co/v1/customers/e6892af7-75d6-4036-8779-9d2ad1336dab"
      },
      "data": {
        "commercialName": "Loja Centro São Paulo",
        "status": "APPROVED",
        "changedFields": [
          "commercialName",
          "phone",
          "email",
          "observation",
          "suframaCode",
          "digitalChannel",
          "rules.paymentMethodIds",
          "addresses",
          "salesRepresentatives",
          "medias"
        ]
      },
      "metadata": {
        "changedBy": {
          "type": "user",
          "id": "30cac3a9-ceb1-46db-bd94-038c8a7f9331",
          "name": "Nome do Usuário"
        }
      }
    }
    ```
  </Tab>

  <Tab title="alteração de status">
    todos os eventos `customer.status.*` têm a mesma estrutura de payload.

    ```json theme={null}
    {
      "eventId": "c4d7e1f2-8a3b-4c9d-b6e5-2f7a9c1e3d5b",
      "eventType": "customer.status.approved",
      "eventVersion": "1.0",
      "timestamp": "2026-04-16T15:45:00.789Z",
      "subscriptionId": "a8fa74b1-af91-4dde-b68b-82e06e1d51a1",
      "brand": {
        "id": "5d84bfd8-c9ae-44bc-acfb-dbc1721fa1be",
        "name": "nome da marca"
      },
      "entity": {
        "type": "customer",
        "id": "e6892af7-75d6-4036-8779-9d2ad1336dab",
        "href": "https://integration.teceo.co/v1/customers/e6892af7-75d6-4036-8779-9d2ad1336dab"
      },
      "data": {
        "commercialName": "Loja Centro São Paulo",
        "status": "APPROVED",
        "previousStatus": "PENDING",
        "currentStatus": "APPROVED"
      },
      "metadata": {
        "changedBy": {
          "type": "user",
          "id": "30cac3a9-ceb1-46db-bd94-038c8a7f9331",
          "name": "Nome do Usuário"
        }
      }
    }
    ```
  </Tab>
</Tabs>

## casos de uso comuns

### sincronizar com CRM

quando um cliente é criado ou atualizado, você sincroniza com seu CRM.

```javascript theme={null}
if (eventType === "customer.created") {
  createInCRM(data);
} else if (eventType === "customer.updated") {
  updateInCRM(data, data.changedFields);
}
```

### reagir a mudanças de status

quando o status muda, você pode acionar fluxos específicos — aprovação, bloqueio, inativação.

```javascript theme={null}
if (eventType === "customer.status.approved") {
  sendWelcomeEmail(entity.id);
} else if (eventType === "customer.status.blocked") {
  notifyTeam(entity.id, data.commercialName);
}
```

## dados inclusos

o objeto `data` contém dados básicos do cliente e status. se precisar de mais informações, use `entity.href` para buscar os dados completos via API.
