# Events feed

Pull the audit events, attack events and hourly statistics of your organization into your SIEM, with a cursor that remembers where each consumer stopped.

The events feed is one place for everything a SIEM wants from Diamwall: who changed what, when an attack started and ended, what the attack looked like, and how much traffic each hour carried. It belongs to an organization and covers the Enterprise domains of that organization:

```
GET /public-api/organizations/{org_public_id}/siem/events/
```

> **Breaking change: the account feed is gone**
> `GET /public-api/events/` was removed. Read the feed of your organization instead. See [Moving from the account feed](#moving-from-the-account-feed).

- [Read](#read-the-feed): Fetch a page, store it, follow the link, repeat.
- [Consumers](#consumers): Named readers, shared by the organization.
- [Event types](#event-types): CDN audit, attacks, hourly statistics, firewall events and feed gaps.
- [Errors](#errors-you-are-likely-to-see): What each SIEM error means and what to do.

The examples on this page use these shell variables:

```bash
export DIAMWALL_API_KEY="your key"
export EVENTS="https://api.diamwall.com/public-api/organizations/your-organization-public-id/siem/events/"
```

If you use Microsoft Sentinel or Splunk, you do not have to pull the feed yourself: an [event destination](https://docs.diamwall.com/products/event-destinations/) delivers it for you.

## Permissions

The feed needs the `siem.view` permission in the organization. `siem` is a permission of its own, at organization level, with four actions: `view`, `create`, `edit` and `delete`.

- `siem.view` is enough to read the feed. It also covers the statistics, the attacks and the CDN audit of the organization, so no other permission is needed for those events.
- By default only the owner of the organization has it. Existing roles are unchanged, and that includes the organization admin: an admin needs to be given `siem` explicitly.
- It can be given through organization grants, departments and invites.
- Where the organization has its own security policy, such as an IP list, it applies to the feed too.
- A domain restriction on the API key does not apply to the feed. What the key can read is decided by the organization.

## Read the feed

[`GET /public-api/organizations/{org_public_id}/siem/events/` in the API reference](https://docs.diamwall.com/api/#tag/domains/GET/public-api/organizations/{org_public_id}/siem/events/)

The feed is read in cycles. A cycle is a run of pages, at most 20, each with up to 100 events.

1. Call the base URL to start a cycle.
2. Store the events of the page before you do anything else.
3. Send the `next_cursor` of the answer as `cursor` on the next call. The `Link` header carries the same step as a full URL: when it is there, follow it exactly as it is given.
4. Repeat until a page comes back empty. Asking for that empty page is what confirms the cycle: the events you stored will not be sent again.

```bash
curl -i "$EVENTS?consumer=siem-main" \
  -H "Authorization: Api-Key $DIAMWALL_API_KEY"
```

```json
{
  "format_version": 1,
  "events": [
    {
      "format_version": 1,
      "event_id": "0000000000000000000000000000000000000000000000000000000000000005",
      "event_type": "attack_start",
      "event_time": "2026-11-23T12:00:00.123456Z",
      "domain_public_id": "684393bc-679d-4779-a802-12cab3769191",
      "domain_name": "example.com",
      "attack_id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "attack_started_at": "2026-11-23T12:00:00.123456Z"
    }
  ],
  "next_cursor": "signed-cursor",
  "oldest_pending_at": "2026-11-23T12:00:00.123456Z"
}
```

| Field | Meaning |
| --- | --- |
| `events` | Up to 100 events. |
| `next_cursor` | The cursor of the next page, or `null` when there is none. The `Link` header carries the same step as a full URL. |
| `oldest_pending_at` | The earliest time the feed knows is still pending, or `null` when it knows of none. |

> **Store first, then follow the link**
> If you call without a cursor before the cycle is confirmed, the same cycle is sent again. That is how you recover from a crash, and it is also why you must deduplicate by `event_id`.

Three things to build in:

- **Deduplicate by `event_id`.** The same event can arrive again across pages, retries, consumers and keys. The id is always the same.
- **Do not expect one global order.** Events are ordered inside their own source, not across sources.
- **Times are UTC** and end in `Z`.

## Consumers

A consumer is a named reader. The feed stores its filters and its position, so both survive between requests and when you rotate the API key.

Consumers belong to the organization, not to a person or a key. Everyone with access shares the same names and the same progress, so anyone can carry on where a colleague stopped, and two people reading the same consumer are reading one stream. An organization can have up to 8 consumers.

| Parameter | What it does |
| --- | --- |
| `consumer` | The name, 1 to 64 letters, digits, `-` or `_`. Not case sensitive, and shared by the whole organization. Defaults to `default`. |
| `event_type` | Keep only some types. Repeat the parameter to pick several. By default you get every type you are allowed to see. |
| `domain_public_id` | Keep only one domain. |
| `start` | Where a new consumer begins, as a UTC time with an explicit time zone, at most 7 days back. By default it begins at the start of the last closed 5-minute interval. |
| `cursor` | The cursor from a `next` link. Leave it out to begin or repeat a cycle. |

```bash
curl -i "$EVENTS?consumer=attacks-only&event_type=attack_start&event_type=attack_end&event_type=attack_log" \
  -H "Authorization: Api-Key $DIAMWALL_API_KEY"
```

- The filters belong to the consumer. To read with different filters, use a different name. Calling an existing consumer with other filters answers `409 SIEM_CONSUMER_FILTER_MISMATCH`.
- Send `start` only when you create a consumer, and never together with `cursor`.
- The first pull of a consumer that asks only for `firewall_event` can save the consumer and still answer `403 SIEM_ACCESS_DENIED`, while none of its firewall sources can be read yet. Send the same request again later, with the same name and filters and without `start`, and it carries on from there.
- A request refused for missing permissions before the consumer exists saves nothing.
- A feed gap is delivered even when your `event_type` filter leaves its own type out, as long as it belongs to a source you selected.

## Event types

Every event has `format_version`, `event_id`, `event_type` and `event_time`, the `domain_public_id` and `domain_name` it is about, and the `organization_public_id`.

| `event_type` | What it is |
| --- | --- |
| `audit_cdn` | A change to a domain's CDN configuration, with `method` (`create`, `update`, `delete` or `other`) and, when known, `actor_email`. A change made with an API key also has `api_key_public_id`, which you can look up in the [request logs](https://docs.diamwall.com/products/request-logs/). |
| `attack_start` | An attack began. Carries `attack_id` and `attack_started_at`. |
| `attack_end` | An attack ended. Same `attack_id`, plus `attack_ended_at`. |
| `attack_log` | The final record of a finished attack. |
| `statistics_hour` | The counters of one closed UTC hour for one domain. |
| `firewall_event` | A request a firewall rule acted on. See [Firewall events](#firewall-events). |
| `feed_gap` | The feed confirms that something is missing. You cannot filter for it: it comes with its source. |

The organization feed has no `audit_login` and no `audit_account` events. Those belonged to the account feed.

### Attack records

Each finished attack produces one `attack_log`. Its `attack_id` is the one in the `attack_start` and `attack_end` events, and its `event_time` is the end of the attack. It can arrive after the `attack_end` event.

The record has `attack_started_at`, `attack_ended_at`, `attack_type`, `rule`, `trigger`, `conn`, `total`, `peak`, `legit`, `suspicious`, `malicious` and `dpi`. From `attack_type` to `dpi`, each value can be text, a number, a boolean or `null`, so do not give those columns a strict type.

### Hourly statistics

A `statistics_hour` event covers one UTC hour, from `interval_start` to `interval_end`. It has a connection counter and a byte counter for each of `total`, `legit`, `malicious`, `suspicious`, `dpi` and `allowed`, for example `connections_total` and `bytes_total`.

- An hour is published once it has closed, which takes at least 10 minutes after the end of the hour.
- An hour with no traffic produces no event.
- A late correction of an hour comes with the same `event_id`. Keep the version you received last and drop the earlier one.

### Firewall events

A `firewall_event` is one request a firewall rule acted on. It always has the same 23 keys, but only `event_uid`, `timestamp` and `domain` always have a value. Every other field can be `null`, including `remote_addr`, `country`, `pop` and `request_id`, so do not give those columns a strict type. At least one of `event_name`, `event_rule` and `event_action` has text.

- `status` and `asn` are an integer or `null`.
- `referer`, `user_agent`, `ja4`, `ja4h`, `ja4one` and `ja4l` are `null` when the request did not have them. An empty value that was recorded stays `""`.

- Firewall events follow the order the CDN publishes them in, so a late one can have an earlier `event_time` than the event before it.
- Two occurrences of the same request share a `request_id` but have different `event_id` values.
- The CDN keeps firewall events for at least 72 hours after it publishes them. Read the feed more often than that.
- A consumer with no `event_type` filter starts getting firewall events when the organization is allowed to read them. A consumer with an `event_type` filter keeps its selection.

### Feed gaps

A `feed_gap` tells you the feed checked and something is not there, so you can stop waiting for it. It has `gap_source`, `gap_reason`, `gap_start` and `gap_end`.

| `gap_source` | `gap_reason` | Meaning |
| --- | --- | --- |
| `attack_end` | `attack_start_missing` | An attack ended and the feed has no start for it. |
| `attack_log` | `attack_record_missing` | 30 minutes after the attack ended, a complete search found no final record. |
| `statistics_hour` | `retention_expired` | The hours in the range are older than the statistics are kept. This gap has no `attack_id`. |
| `firewall_event` | `firewall_history_unverified` | The first interval of firewall events, whose coverage is not known. |
| `firewall_event` | `cursor_expired` | The position was no longer kept. `gap_start` and `gap_end` are `null`. Confirm the gap to carry on from the earliest event still kept. |

If the attack history is unavailable, the final record stays pending and no gap is sent.

## Errors you are likely to see

The code is in the `message` field of the answer.

| Status | Code | What happened | What to do |
| --- | --- | --- | --- |
| `400` | `SIEM_INVALID_QUERY` | A parameter is not valid, or the combination is not allowed. | Check the parameters against the table above. |
| `400` | `SIEM_INVALID_CURSOR` | The cursor is not one the feed gave out, or it can no longer be used. | Start again from the base URL. |
| `403` | `SIEM_ACCESS_DENIED` | You have no access to the organization or to the domain, or none of the firewall sources you asked for can be read yet. | Ask for `siem.view` in the organization. For a firewall-only consumer, repeat the same request later without `start`. |
| `409` | `SIEM_CONSUMER_FILTER_MISMATCH` | The filters differ from the ones stored for this consumer. | Send the stored filters, or use another consumer name. |
| `409` | `SIEM_CONSUMER_LIMIT_REACHED` | The organization already has 8 consumers. | Reuse an existing consumer name. |
| `409` | `SIEM_CONSUMER_BUSY` | Another request is reading with this consumer. | Read each consumer from one place at a time, and try again. |
| `503` | `SIEM_SOURCE_NOT_READY` | A source the page needs cannot be read yet. | Try again later. Nothing is lost. |
| `429` | `API_KEY_RATE_LIMITED` | Too many requests. | Wait for the time in the `Retry-After` header. |

The errors that come from the key itself, such as `API_KEY_IP_NOT_ALLOWED`, are on the [Errors](https://docs.diamwall.com/reference/errors/) page.

## Moving from the account feed

`GET /public-api/events/` no longer exists. To move a reader over:

1. **Change the URL** to `/public-api/organizations/{org_public_id}/siem/events/`, with the public id of your organization.
2. **Get the permission.** The person who owns the API key needs `siem.view` in the organization. Only the owner has it by default.
3. **Start a new consumer.** Positions from the account feed do not carry over. To avoid a hole, create the consumer with `start` set to the time of the last event you stored, at most 7 days back, and drop the repeats by `event_id`.
4. **Stop expecting login and account events.** `audit_login` and `audit_account` are not in the organization feed, and asking for them in `event_type` is refused.
5. **Share consumer names on purpose.** A name is now shared by the whole organization, so pick names that say who reads them.

The fields of the events have not changed.
