# Eventos

> Las operaciones de Eventos de la API de Trevol: parámetros, cuerpo, respuestas y ejemplos de código.

Fuente: https://platform.trevol.si/docs/api/events

Los eventos que Trevol manda a tus webhooks, guardados 30 días, y su reenvío.

Los ejemplos son peticiones con cURL. La llave va en `TREVOL_API_KEY`; los cuerpos de ejemplo son los de la especificación. Los errores comunes están en [Errores](/docs/errores).

## Reenviar un evento a un endpoint (entrega manual nueva; el `webhook-id` es el mismo)

`POST /v1/events/{id}/resend` · `resendEvent`

Vuelve a mandar el evento a un endpoint activo de la misma empresa y el mismo ambiente. Lleva el mismo `webhook-id`: si tu servidor ya lo procesó, deduplica con él. Hasta 60 por hora.

**Cuerpo** (objeto, obligatorio)

| Campo | Tipo | Obligatorio | Descripción |
| --- | --- | --- | --- |
| `endpoint_id` | texto | sí |  |

**Respuestas**

| Estado | Qué pasó |
| --- | --- |
| 202 | La entrega encolada ([WebhookDelivery](/docs/api/objetos#WebhookDelivery)) |
| 409 | Error (application/problem+json) ([Problem](/docs/api/objetos#Problem)) |
| 429 | Error (application/problem+json) ([Problem](/docs/api/objetos#Problem)) |
| Error | Error (application/problem+json) ([Problem](/docs/api/objetos#Problem)) |

`POST /v1/events/{id}/resend` (`resendEvent`)

#### cURL

```bash
curl -X POST "https://api.trevol.si/v1/events/evt_3f0c1a2b3f0c1a2b3f0c1a2b3f0c1a2b/resend" \
  -H "Authorization: Bearer $TREVOL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "endpoint_id": "we_3f0c1a2b3f0c1a2b3f0c1a2b3f0c1a2b"
}'
```

[Probar en el Playground](https://platform.trevol.si/playground?op=resendEvent&ejemplo=reenviar)

## Los eventos de 30 días de la empresa y el ambiente

`GET /v1/events` · `listEvents`

Solo se guardan eventos si la empresa tiene al menos un endpoint en este ambiente. Útil para recuperar lo que se perdió mientras tu servidor estaba caído.

**Parámetros**

| Nombre | En | Tipo | Obligatorio | Descripción |
| --- | --- | --- | --- | --- |
| `limit` | consulta | entero |  |  |
| `starting_after` | consulta | texto |  |  |
| `type` | consulta | texto |  |  |
| `created_from` | consulta | texto |  |  |
| `created_to` | consulta | texto |  |  |

**Respuestas**

| Estado | Qué pasó |
| --- | --- |
| 200 | {object: list, data, has_more, next_cursor} (objeto) |
| Error | Error (application/problem+json) ([Problem](/docs/api/objetos#Problem)) |

`GET /v1/events` (`listEvents`)

#### cURL

```bash
curl "https://api.trevol.si/v1/events?limit=100" \
  -H "Authorization: Bearer $TREVOL_API_KEY"
```

[Probar en el Playground](https://platform.trevol.si/playground?op=listEvents)

## Un evento

`GET /v1/events/{id}` · `retrieveEvent`

El evento tal como se mandó al endpoint.

**Respuestas**

| Estado | Qué pasó |
| --- | --- |
| 200 | El recurso ([Event](/docs/api/objetos#Event)) |
| Error | Error (application/problem+json) ([Problem](/docs/api/objetos#Problem)) |

`GET /v1/events/{id}` (`retrieveEvent`)

#### cURL

```bash
curl "https://api.trevol.si/v1/events/evt_3f0c1a2b3f0c1a2b3f0c1a2b3f0c1a2b" \
  -H "Authorization: Bearer $TREVOL_API_KEY"
```

[Probar en el Playground](https://platform.trevol.si/playground?op=retrieveEvent)
