# Send an event from the browser

> Records a capture event using the publishable token. It is the endpoint the snippet calls, and you can call it directly if you prefer not to load the script.

Página: https://doc.rapidchargeback.com/en/canais/capture/enviar-evento-navegador/

Records a capture event using the publishable token. It is the endpoint the [snippet](https://doc.rapidchargeback.com/en/canais/capture/instalar-o-snippet/) calls, and you can call it directly if you prefer not to load the script.

## Endpoint

```
POST https://api.rapidchargeback.com/api/v1/capture/{token}/events
```

## Authentication

None. The publishable token in the URL identifies the merchant.

```
Content-Type: application/json
```

The token is not a secret and can stay in your store's HTML. It only allows writing, and the event only becomes evidence if it matches a real order of yours.

## URL parameters

| Field | Type | Description |
|---|---|---|
| `token` | string | Merchant's publishable token, generated in the dashboard |

## Request body

| Field | Type | Description | Required |
|---|---|---|---|
| `type` | string (enum) | `checkout`, `terms_acceptance`, `access_log` or `usage_log` | Yes |
| `order_ref` | string | Order identifier in your system, up to 100 characters | Yes |
| `event_id` | string | Event identifier, generated by you, up to 64 characters | Yes |
| `payload` | object | Data about the fact, with a closed list of fields | No |

The full reference of accepted values is in [Types and payload](https://doc.rapidchargeback.com/en/canais/capture/payload/).

Two points specific to this channel:

- `event_id` is required here. Generate a UUID per event
- `captured_at` sent in the body is ignored. Rapid records the arrival time. To send the time of the fact, use the [server channel](https://doc.rapidchargeback.com/en/canais/capture/enviar-evento-servidor/)

The `delivery_confirmation`, `scan` and `delivery_gps` types do not exist in this channel: they are facts of your operation, not of the buyer's browser.

## Rate limit

120 requests per minute, per source IP. That is plenty for a real checkout and tight for anyone using the token outside your site.

## Validations

| Rule | Response |
|---|---|
| Unknown or inactive token, or token without a merchant | `404 NOT_FOUND` |
| `type` missing, or not one of the four accepted in this channel | `422 VALIDATION_ERROR`: *invalid_type* |
| `order_ref` missing, empty or over 100 characters | `422 VALIDATION_ERROR`: *invalid_order_ref* |
| `event_id` missing, empty or over 64 characters | `422 VALIDATION_ERROR`: *invalid_event_id* |
| `payload` text field over 512 characters | `422 VALIDATION_ERROR`: *payload_too_large* |
| Over 120 requests per minute | `429 Too Many Requests` |

There is no error for a nonexistent `order_ref`. The event is accepted, stays in the queue and is discarded if no transaction matches within the correlation window. See [Correlation window](https://doc.rapidchargeback.com/en/canais/capture/payload/#correlation-window).

## Request example

```bash
curl -X POST https://api.rapidchargeback.com/api/v1/capture/your_publishable_token/events \
  -H "Content-Type: application/json" \
  -d '{
    "type": "terms_acceptance",
    "order_ref": "TXN-2026-001",
    "event_id": "019b0000-1111-7000-8000-000000000001",
    "payload": { "url": "https://loja.exemplo.com/checkout" }
  }'
```

Checkout event with device identification:

```bash
curl -X POST https://api.rapidchargeback.com/api/v1/capture/your_publishable_token/events \
  -H "Content-Type: application/json" \
  -d '{
    "type": "checkout",
    "order_ref": "TXN-2026-001",
    "event_id": "019b0000-1111-7000-8000-000000000002",
    "payload": {
      "device_id": "8kJ2mQvR1nZxYb0T",
      "device_fingerprint": "8kJ2mQvR1nZxYb0T",
      "fp": "pro",
      "fp_request_id": "1712059781234.Xk9Lp2"
    }
  }'
```

## Response examples

### Success (202)

```json
{ "accepted": true }
```

`202` means the event entered the queue, not that it has already become evidence. Correlation with the transaction happens later.

### Error: unknown token (404)

```json
{ "error": { "code": "NOT_FOUND" } }
```

### Error: type not available in this channel (422)

```json
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "invalid_type"
  }
}
```

### Error: missing `event_id` (422)

```json
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "invalid_event_id"
  }
}
```

### Error: payload field too long (422)

```json
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "payload_too_large"
  }
}
```

## Next steps

- [Install the snippet](https://doc.rapidchargeback.com/en/canais/capture/instalar-o-snippet/)
- [Send an event from the server](https://doc.rapidchargeback.com/en/canais/capture/enviar-evento-servidor/)
- [Snippet configuration](https://doc.rapidchargeback.com/en/canais/capture/config-do-snippet/)
