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

# Events

> Learn about the different webhook events in Superleap

# Webhook Events

Superleap can send webhooks for the following events:

## Event Naming Convention

Events in Superleap follow a consistent naming pattern:

```
object_slug.verb
```

* `object_slug`: The identifier of the object (e.g., "lead", "user", "opportunity")
* `verb`: The action that occurred (e.g., "create", "update", "delete")

For example, when a lead is created, the event name is `lead.create`.

## Standard Object Events

These events correspond to the built-in objects in Superleap.

| Event                | Description                                       |
| -------------------- | ------------------------------------------------- |
| `user.create`        | Triggered when a new user is created              |
| `user.update`        | Triggered when user information is updated        |
| `user.delete`        | Triggered when a user is deleted                  |
| `lead.create`        | Triggered when a new lead is created              |
| `lead.update`        | Triggered when lead information is updated        |
| `lead.delete`        | Triggered when a lead is deleted                  |
| `opportunity.create` | Triggered when a new opportunity is created       |
| `opportunity.update` | Triggered when opportunity information is updated |
| `opportunity.delete` | Triggered when an opportunity is deleted          |

## Custom Object Events

For any custom object defined in your Superleap account, events follow the same pattern. If you have a custom object with slug `student`, you'll receive events like:

| Event            | Description                                       |
| ---------------- | ------------------------------------------------- |
| `student.create` | Triggered when a new student is created           |
| `student.update` | Triggered when a student's information is updated |
| `student.delete` | Triggered when a student's information is deleted |

## Webhook Payloads

Webhook payloads are sent as JSON in the request body and contain only three main keys:

* `before`: The state of the record before the change (empty object `{}` for create events)
* `after`: The state of the record after the change (empty object `{}` for delete events)
* `diff`: Contains only the new values of fields that were changed

All event metadata is included in the HTTP headers:

| Header                  | Example                                                          | Description                                                             |
| ----------------------- | ---------------------------------------------------------------- | ----------------------------------------------------------------------- |
| `x-superleap-event-id`  | `cK2p5W:lead:1741686315971:cK2p5W_QgAejsx2:lead.create:9qRSOzKs` | Unique identifier for the event                                         |
| `x-superleap-event`     | `lead.create`                                                    | Type of event that triggered the webhook                                |
| `x-superleap-signature` | `sha256=...`                                                     | HMAC SHA-256 signature of the request payload using your webhook secret |

Example update event payload:

```json theme={null}
{
  "before": {
    "id": "lead_987654321",
    "name": "John Smith",
    "email": "john@example.com",
    "status": "new",
    "created_at": 1740126808148
  },
  "after": {
    "id": "lead_987654321",
    "name": "John Smith",
    "email": "john.smith@example.com",
    "status": "qualified",
    "created_at": 1740126808148
  },
  "diff": {
    "email": "john.smith@example.com",
    "status": "qualified"
  }
}
```

For create events, the `before` field will be an empty object:

```json theme={null}
{
  "before": {},
  "after": {
    "id": "lead_987654321",
    "name": "Jane Doe",
    "email": "jane@example.com",
    "status": "new",
    "created_at": 1740126808148
  },
  "diff": {
    "id": "lead_987654321",
    "name": "Jane Doe",
    "email": "jane@example.com",
    "status": "new",
    "created_at": 1740126808148
  }
}
```

For delete events, the `after` field will be an empty object:

```json theme={null}
{
  "before": {
    "id": "lead_987654321",
    "name": "Jane Doe",
    "email": "jane@example.com",
    "status": "lost",
    "created_at": 1740126808148
  },
  "after": {},
  "diff": {}
}
```
