# Count audit events (admin)

`GET /v1/admin/orgs/{slug}/audit-events/count`

How many audit events the list holds, and how many of them the search and
filters leave. Takes exactly the parameters `adminListAuditEvents` filters
by, with the same rules and the same refusals, and needs the same
permission. Recorded at the trace level as `list.counted`, since a
dashboard counts again on every change of its filters.

Counting reads every record of the window, so the audit log counts at
most 10000 records for each number and sets `at_least` on one that
stopped there. Both numbers are of the window: `total` is every record
in it, `matching` the ones the filters leave.

## Authorization

- [Bearer token](https://www.nauthera.io/docs/v1/api#auth-bearerAuth) (`bearerAuth`) and [OAuth 2.0](https://www.nauthera.io/docs/v1/api#auth-oauth2) (`oauth2`) with scope `nauthera.audit:read`

Authorization header: The access token, as `Bearer <token>` (RFC 6750 §2.1) or, for a sender-constrained token, `DPoP <token>` (RFC 9449 §7.1). A token minted with a `cnf.jkt` confirmation is only accepted together with a `DPoP` proof signed by that key, whichever of the two schemes carries it.

Requires the permission [`audit.read`](https://www.nauthera.io/docs/v1/api#permission-audit.read): Read an organization's audit log.

This endpoint is rate limited; it answers `429` when a limit is hit.

## Path parameters

- `slug` (string, required): The organization slug. It names the TENANT OF RECORD for the operation: the rows it reads and writes, the policy its secrets are derived under, and the organization its audit record is filed against all come from this organization. A token is admitted only through its own slug, except a main-org token, which may be admitted through any — so cross-tenant administration is performed through the TARGET tenant's slug, never by naming its resources through another. A token reaching for a slug it may not be admitted through is refused identically whether that organization exists or not. Constraints: 1–64 characters.

## Query parameters

- `from` (string (date-time), optional): Inclusive start of the window (RFC3339). Defaults to 30 days before `to`. Constraints: at most 64 characters. The window from `from` to `to` may span at most 90 days.
- `to` (string (date-time), optional): Exclusive end of the window (RFC3339). Defaults to now. Constraints: at most 64 characters. The window from `from` to `to` may span at most 90 days.
- `action` (array of strings, optional): Action patterns, comma-separated. `*` and `?` are wildcards and do not stop at a dot, so `user.*` covers `user.password.changed` as well as `user.created`. A pattern matching no known action simply returns nothing, and an empty element is ignored. With no pattern, every action but `system.audit.checkpoint` is returned: the hash chain's checkpoint records, which the verifier reads, come back only to a pattern that matches them. Constraints: at most 32 items; each item: at most 128 characters; each item: pattern `^[a-z0-9_.*?-]*$`.
- `category` (array of enums, optional): Categories, comma-separated. A record is matched by the category it was written under. One of: `"authentication"`, `"session"`, `"mfa"`, `"token"`, `"user"`, `"organization"`, `"client"`, `"role"`, `"admin"`, `"audit"`, `"system"`. Constraints: at most 16 items.
- `outcome` (array of enums, optional): Outcomes, comma-separated. `failure,denied,error`, in any order, is every refusal and fault: the base query of most detectors, which has an index of its own. One of: `"success"`, `"failure"`, `"denied"`, `"error"`. Constraints: at most 16 items.
- `severity` (array of enums, optional): Severities, comma-separated. One of: `"info"`, `"notice"`, `"warning"`, `"critical"`. Constraints: at most 16 items.
- `reason` (array of enums, optional): Reasons, comma-separated: the error each refusal answered with, such as `invalid_grant` or `invalid_dpop_proof`. A success carries no reason; ask for successes with `outcome`. One of: `"invalid_credentials"`, `"account_locked"`, `"rate_limited"`, `"mfa_required"`, `"email_verification_required"`, `"invalid_code"`, `"factor_locked"`, `"missing_role"`, `"missing_scope"`, `"cross_org_denied"`, `"not_found"`, `"conflict"`, `"invalid_request"`, `"invalid_client"`, `"invalid_grant"`, `"invalid_redirect_uri"`, `"unauthenticated"`, `"registration_closed"`, `"invalid_target"`, `"invalid_dpop_proof"`, `"repeated_header"`, `"token_expired"`, `"missing_expiry"`, `"audience_mismatch"`, `"unsupported_critical"`, `"unregistered_client"`, `"redirect_uri_required"`, `"pushed_request_required"`, `"invalid_request_uri"`, `"request_uri_client_mismatch"`, `"invalid_request_object"`, `"unavailable"`, `"internal_error"`, `"access_denied"`, `"login_required"`, `"consent_required"`, `"interaction_required"`, `"unsupported_grant_type"`, `"invalid_scope"`, `"unauthorized_client"`, `"unsupported_response_type"`, `"account_selection_required"`, `"invalid_authorization_details"`, `"expired_token"`, `"request_not_supported"`, `"request_uri_not_supported"`, `"unsupported_token_type"`, `"invalid_token"`, `"use_dpop_nonce"`, `"authorization_pending"`, `"slow_down"`, `"invalid_client_metadata"`, `"invalid_software_statement"`, `"unapproved_software_statement"`, `"account_unavailable"`, `"insufficient_user_authentication"`, `"protected_account"`, `"passkey_offered"`, `"password_change_required"`, `"terms_acceptance_required"`, `"insufficient_scope"`. Constraints: at most 16 items.
- `actor_type` (array of enums, optional): Actor types, comma-separated. `anonymous` is every record made before a caller was identified. One of: `"user"`, `"admin"`, `"client"`, `"system"`, `"anonymous"`. Constraints: at most 8 items.
- `operation` (array of strings, optional): Operations, comma-separated, each matched exactly: the operation a record was made under, as its `operation` field holds it — the operationId as this document spells it, so a record stored by an earlier release, which holds the Go identifier (`GetJWKS`), is found by that spelling. Constraints: at most 16 items; each item: at most 256 characters; each item: pattern `^[A-Za-z0-9_./-]+$`.
- `actor_id` (string, optional): Only records caused by this principal. Constraints: at most 256 characters.
- `target_id` (string, optional): Only records acting on this object. Constraints: at most 256 characters.
- `target_type` (enum, optional): The kind of object an event acted upon. `audit_log` is the log itself, for the events that record reading or exporting it. `consent` is one user's standing agreement with one client for one resource, named by the agreement's id, so every decision about it shares one target. `group` is one of an organization's groups of users. One of: `"user"`, `"organization"`, `"client"`, `"session"`, `"token"`, `"factor"`, `"role"`, `"system"`, `"audit_log"`, `"consent"`, `"group"`.
- `subject` (string, optional): Only records in which this user is the actor or the target: their whole trail, each record once, in one keyset-paginated listing. Composes with `actor_id` and `target_id` like any other filter. Constraints: at most 256 characters.
- `client_ip` (string, optional): Only records from this address. Any spelling of an address matches the one the server stores (`2001:DB8::1` is `2001:db8::1`, and `::ffff:203.0.113.5` is `203.0.113.5`); a value that is not an IP address is rejected with a 400. An address is personal data, so a caller without the `users.pii.read` permission is refused with a 403. Constraints: at most 64 characters.
- `client_net` (string, optional): Only records from addresses in this network: an IPv4 `/24` or an IPv6 `/64`, the unit an address rotates within while its owner stays the same. A single address stands for the network it lies in. Any other prefix length is rejected with a 400. Records written before the server kept the network are not matched. Constraints: at most 64 characters.
- `network_zone` (array of strings, optional): Network zones, comma-separated: only records whose client address fell in one of them, as the record's `network_zones` names them. A sign-in records its zones; other records name none and are not matched. A value that is not a lowercase label is rejected with a 400. Constraints: at most 16 items; each item: at most 63 characters.
- `client_ip_country` (array of strings (iso-3166-1-alpha-2), optional): Countries, comma-separated, each an ISO 3166-1 alpha-2 code in either case: only records whose client address was in one of them when the record was written, as the record's `client_ip_country` names it. A record written without an IP geolocation database (`geoip.database`), or before the server kept the country, is not matched. Where a user was is personal data, so a caller without the `users.pii.read` permission is refused with a 403. Constraints: at most 16 items; each item: at most 2 characters; each item: pattern `^[A-Za-z]{2}$`.
- `client_ip_asn` (array of strings, optional): AS numbers, comma-separated, each with or without `AS` in front: only records whose client address was announced from one of them when the record was written, as the record's `client_ip_asn` names it. A record written without an ASN database (`geoip.asn_database`), or before the server kept the network, is not matched. A caller without the `users.pii.read` permission is refused with a 403, as for `client_ip`. Constraints: at most 16 items; each item: at most 12 characters; each item: pattern `^(AS|as)?[0-9]{1,10}$`.
- `client_ip_as_organization` (string, optional): The organization of the autonomous system the client address was announced from when the record was written (`client_ip_asn`'s `organization`), ignoring case. `*` stands for any run of characters and `?` for any one, so `*hosting*` matches every provider whose name holds "hosting"; without either the whole name must match. A record written without an ASN database is not matched. A caller without the `users.pii.read` permission is refused with a 403, as for `client_ip`. Constraints: at most 128 characters.
- `client_id` (string, optional): Only records about this client, whether the server resolved the record to it or the caller only named it. Each record says which: a resolved client is its `client_id`, a named one its `claimed_client_id`. Constraints: at most 256 characters.
- `session_id` (string, optional): Constraints: at most 256 characters.
- `request_id` (string, optional): The `X-Request-ID` of a single request. This and `trace_id` are what a support engineer arrives with. Constraints: at most 256 characters.
- `trace_id` (string, optional): Constraints: at most 64 characters.
- `cross_tenant_only` (boolean, optional): Only actions taken on this organization by an actor from another one. It is the single most useful security view a multi-tenant audit log offers, which is why it is a first-class filter.

## Headers

- `DPoP` (string, optional): DPoP proof JWT (RFC 9449 §4). REQUIRED on a request presenting a DPoP-bound access token, and it must be signed by the key named in the token's `cnf.jkt` and cover this request's method and URI. The proof is read from the request itself rather than from this decoded parameter, so every protected operation is covered whether or not it declares it. Constraints: at most 8192 characters.

## Responses

### 200 OK

The audit events the list holds and the audit events that match.

Content type: `application/json`

Headers:
- `Cache-Control` = `no-store`

How many rows a list holds (`total`, with no search and no filter) and how many of them its search and filters leave (`matching`): the numbers a page of the list cannot carry, read beside it from the list's count operation.

- `total` (object, required): A number of rows. A list that counts at most a cap of rows (the audit log) stops there and says so with `at_least`; every other list counts exactly and never sets it. No other properties are accepted.
  - `count` (integer (int64), required): Constraints: at least 0. Example: `1240`.
  - `at_least` (boolean, required): The count stopped at the cap, so the rows number `count` or more.
- `matching` (object, required): A number of rows. A list that counts at most a cap of rows (the audit log) stops there and says so with `at_least`; every other list counts exactly and never sets it. No other properties are accepted.
  - `count` (integer (int64), required): Constraints: at least 0. Example: `1240`.
  - `at_least` (boolean, required): The count stopped at the cap, so the rows number `count` or more.

### 400 Bad Request

The search or a filter was invalid, as `adminListAuditEvents` would refuse it.

Content type: `application/problem+json`

RFC 9457 (formerly RFC 7807) problem details (application/problem+json). `code` is a stable machine-readable slug for the problem kind (it mirrors the last path segment of `type`), so consumers can branch on it without parsing prose. `type` is `https://nauthera.io/problems/<code>`, which resolves to the code's runbook: why it happened, who is affected and what to do (RFC 9457 §3.1.1). A problem without a code has `about:blank`. `errors` is present on validation failures and lists every offending field.

- `title` (string, required): Example: `"Request validation failed"`.
- `status` (integer, required): Example: `400`.
- `type` (string (uri), optional): Example: `"https://nauthera.io/problems/validation_error"`.
- `detail` (string, optional): Example: `"One or more fields did not satisfy the API schema."`.
- `code` (enum, optional): The kind of problem, as a stable machine-readable slug a client branches on and translates rather than parsing `title` or `detail`, which are English prose for logs. A problem whose status says everything the server knows carries no `code`. One of: `"invalid_request"`, `"invalid_credentials"`, `"forbidden"`, `"unauthorized"`, `"insufficient_user_authentication"`, `"protected_account"`, `"password_held_by_directory"`, `"last_role_administrator"`, `"group_membership_managed"`, `"invalid_code"`, `"too_many_requests"`, `"too_many_attempts"`, `"account_locked"`, `"account_unavailable"`, `"already_enrolled"`, `"registration_disabled"`, `"registration_conflict"`, `"terms_acceptance_required"`, `"captcha_failed"`, `"invalid_reset_link"`, `"password_reused"`, `"password_too_short"`, `"password_too_long"`, `"password_compromised"`, `"invalid_verification_link"`, `"invalid_invitation_link"`, `"mail_relay_missing"`, `"email_unverified"`, `"not_found"`, `"conflict"`, `"precondition_failed"`, `"unavailable"`, `"busy"`, `"window_too_large"`, `"too_many_series"`, `"internal_error"`, `"rate_limited"`, `"malformed"`, `"body_too_large"`, `"unsupported_media_type"`, `"required"`, `"validation_error"`, `"unknown_org"`, `"invalid_token"`, `"invalid_dpop_proof"`, `"use_dpop_nonce"`, `"server_error"`.

  `validation_error` is the one code whose message is not a sentence about
  the code itself: the request failed the schema, and the specifics are
  the `errors` list — one entry per offending field — which a form renders
  on those fields. `required` and `malformed` are spelled like two of the
  per-field violation codes (`FieldError.code`) but mean something else;
  the two vocabularies are told apart by position, never by spelling.

  **Compatibility:** this is a CLOSED enum, with the same cost as
  `AuditAction`: a client generated against an older version of this
  document rejects a problem carrying a code added after it was built.
  Regenerate on upgrade, or decode the field as a plain string. It is
  enumerated anyway so that what a client must translate is knowable
  from the contract alone.
- `instance` (string, optional): Example: `"/introspect"`.
- `request_id` (string, optional): Example: `"8d94ed49-1caf-4ab3-9594-557142f2d023"`.
- `trace_id` (string, optional): Distributed-trace id (hex) for correlating this response with traces and logs. Present only when tracing is enabled and the request was recorded. Opaque and safe to log/share. Example: `"4bf92f3577b34da6a3ce929d0e0e4736"`.
- `errors` (array of objects, optional): Field-level violations (present for validation errors).

  Each item: A single field-level validation violation.
  - `field` (string, required): Offending field, dotted for nested bodies (e.g. child.id). Example: `"token_type_hint"`.
  - `code` (enum, required): The rule a field broke, as a stable machine-readable slug a client branches on and translates rather than parsing `message`, which is English prose for logs. One of: `"required"`, `"too_short"`, `"too_long"`, `"pattern"`, `"invalid_format"`, `"not_allowed"`, `"minimum"`, `"maximum"`, `"too_few"`, `"too_many"`, `"not_unique"`, `"malformed"`, `"undeclared"`, `"read_only"`.

    **Compatibility:** a CLOSED enum, with the cost `ProblemCode` has: a
    client generated against an older version of this document rejects a
    field error carrying a code added after it was built.
  - `message` (string, required): Example: `"field token_type_hint must be one of [access_token, refresh_token]"`.

### 401 Unauthorized

Problem details (RFC 9457) with an RFC 6750 / RFC 9449 challenge.

Content type: `application/problem+json`

Headers:
- `Cache-Control` = `no-store`
- `WWW-Authenticate` (string)
- `DPoP-Nonce` (string)

RFC 9457 (formerly RFC 7807) problem details (application/problem+json). `code` is a stable machine-readable slug for the problem kind (it mirrors the last path segment of `type`), so consumers can branch on it without parsing prose. `type` is `https://nauthera.io/problems/<code>`, which resolves to the code's runbook: why it happened, who is affected and what to do (RFC 9457 §3.1.1). A problem without a code has `about:blank`. `errors` is present on validation failures and lists every offending field.

- `title` (string, required): Example: `"Request validation failed"`.
- `status` (integer, required): Example: `400`.
- `type` (string (uri), optional): Example: `"https://nauthera.io/problems/validation_error"`.
- `detail` (string, optional): Example: `"One or more fields did not satisfy the API schema."`.
- `code` (enum, optional): The kind of problem, as a stable machine-readable slug a client branches on and translates rather than parsing `title` or `detail`, which are English prose for logs. A problem whose status says everything the server knows carries no `code`. One of: `"invalid_request"`, `"invalid_credentials"`, `"forbidden"`, `"unauthorized"`, `"insufficient_user_authentication"`, `"protected_account"`, `"password_held_by_directory"`, `"last_role_administrator"`, `"group_membership_managed"`, `"invalid_code"`, `"too_many_requests"`, `"too_many_attempts"`, `"account_locked"`, `"account_unavailable"`, `"already_enrolled"`, `"registration_disabled"`, `"registration_conflict"`, `"terms_acceptance_required"`, `"captcha_failed"`, `"invalid_reset_link"`, `"password_reused"`, `"password_too_short"`, `"password_too_long"`, `"password_compromised"`, `"invalid_verification_link"`, `"invalid_invitation_link"`, `"mail_relay_missing"`, `"email_unverified"`, `"not_found"`, `"conflict"`, `"precondition_failed"`, `"unavailable"`, `"busy"`, `"window_too_large"`, `"too_many_series"`, `"internal_error"`, `"rate_limited"`, `"malformed"`, `"body_too_large"`, `"unsupported_media_type"`, `"required"`, `"validation_error"`, `"unknown_org"`, `"invalid_token"`, `"invalid_dpop_proof"`, `"use_dpop_nonce"`, `"server_error"`.

  `validation_error` is the one code whose message is not a sentence about
  the code itself: the request failed the schema, and the specifics are
  the `errors` list — one entry per offending field — which a form renders
  on those fields. `required` and `malformed` are spelled like two of the
  per-field violation codes (`FieldError.code`) but mean something else;
  the two vocabularies are told apart by position, never by spelling.

  **Compatibility:** this is a CLOSED enum, with the same cost as
  `AuditAction`: a client generated against an older version of this
  document rejects a problem carrying a code added after it was built.
  Regenerate on upgrade, or decode the field as a plain string. It is
  enumerated anyway so that what a client must translate is knowable
  from the contract alone.
- `instance` (string, optional): Example: `"/introspect"`.
- `request_id` (string, optional): Example: `"8d94ed49-1caf-4ab3-9594-557142f2d023"`.
- `trace_id` (string, optional): Distributed-trace id (hex) for correlating this response with traces and logs. Present only when tracing is enabled and the request was recorded. Opaque and safe to log/share. Example: `"4bf92f3577b34da6a3ce929d0e0e4736"`.
- `errors` (array of objects, optional): Field-level violations (present for validation errors).

  Each item: A single field-level validation violation.
  - `field` (string, required): Offending field, dotted for nested bodies (e.g. child.id). Example: `"token_type_hint"`.
  - `code` (enum, required): The rule a field broke, as a stable machine-readable slug a client branches on and translates rather than parsing `message`, which is English prose for logs. One of: `"required"`, `"too_short"`, `"too_long"`, `"pattern"`, `"invalid_format"`, `"not_allowed"`, `"minimum"`, `"maximum"`, `"too_few"`, `"too_many"`, `"not_unique"`, `"malformed"`, `"undeclared"`, `"read_only"`.

    **Compatibility:** a CLOSED enum, with the cost `ProblemCode` has: a
    client generated against an older version of this document rejects a
    field error carrying a code added after it was built.
  - `message` (string, required): Example: `"field token_type_hint must be one of [access_token, refresh_token]"`.

### 403 Forbidden

Problem details (RFC 9457) with an RFC 6750 / RFC 9449 challenge.

Content type: `application/problem+json`

Headers:
- `Cache-Control` = `no-store`
- `WWW-Authenticate` (string)
- `DPoP-Nonce` (string)

RFC 9457 (formerly RFC 7807) problem details (application/problem+json). `code` is a stable machine-readable slug for the problem kind (it mirrors the last path segment of `type`), so consumers can branch on it without parsing prose. `type` is `https://nauthera.io/problems/<code>`, which resolves to the code's runbook: why it happened, who is affected and what to do (RFC 9457 §3.1.1). A problem without a code has `about:blank`. `errors` is present on validation failures and lists every offending field.

- `title` (string, required): Example: `"Request validation failed"`.
- `status` (integer, required): Example: `400`.
- `type` (string (uri), optional): Example: `"https://nauthera.io/problems/validation_error"`.
- `detail` (string, optional): Example: `"One or more fields did not satisfy the API schema."`.
- `code` (enum, optional): The kind of problem, as a stable machine-readable slug a client branches on and translates rather than parsing `title` or `detail`, which are English prose for logs. A problem whose status says everything the server knows carries no `code`. One of: `"invalid_request"`, `"invalid_credentials"`, `"forbidden"`, `"unauthorized"`, `"insufficient_user_authentication"`, `"protected_account"`, `"password_held_by_directory"`, `"last_role_administrator"`, `"group_membership_managed"`, `"invalid_code"`, `"too_many_requests"`, `"too_many_attempts"`, `"account_locked"`, `"account_unavailable"`, `"already_enrolled"`, `"registration_disabled"`, `"registration_conflict"`, `"terms_acceptance_required"`, `"captcha_failed"`, `"invalid_reset_link"`, `"password_reused"`, `"password_too_short"`, `"password_too_long"`, `"password_compromised"`, `"invalid_verification_link"`, `"invalid_invitation_link"`, `"mail_relay_missing"`, `"email_unverified"`, `"not_found"`, `"conflict"`, `"precondition_failed"`, `"unavailable"`, `"busy"`, `"window_too_large"`, `"too_many_series"`, `"internal_error"`, `"rate_limited"`, `"malformed"`, `"body_too_large"`, `"unsupported_media_type"`, `"required"`, `"validation_error"`, `"unknown_org"`, `"invalid_token"`, `"invalid_dpop_proof"`, `"use_dpop_nonce"`, `"server_error"`.

  `validation_error` is the one code whose message is not a sentence about
  the code itself: the request failed the schema, and the specifics are
  the `errors` list — one entry per offending field — which a form renders
  on those fields. `required` and `malformed` are spelled like two of the
  per-field violation codes (`FieldError.code`) but mean something else;
  the two vocabularies are told apart by position, never by spelling.

  **Compatibility:** this is a CLOSED enum, with the same cost as
  `AuditAction`: a client generated against an older version of this
  document rejects a problem carrying a code added after it was built.
  Regenerate on upgrade, or decode the field as a plain string. It is
  enumerated anyway so that what a client must translate is knowable
  from the contract alone.
- `instance` (string, optional): Example: `"/introspect"`.
- `request_id` (string, optional): Example: `"8d94ed49-1caf-4ab3-9594-557142f2d023"`.
- `trace_id` (string, optional): Distributed-trace id (hex) for correlating this response with traces and logs. Present only when tracing is enabled and the request was recorded. Opaque and safe to log/share. Example: `"4bf92f3577b34da6a3ce929d0e0e4736"`.
- `errors` (array of objects, optional): Field-level violations (present for validation errors).

  Each item: A single field-level validation violation.
  - `field` (string, required): Offending field, dotted for nested bodies (e.g. child.id). Example: `"token_type_hint"`.
  - `code` (enum, required): The rule a field broke, as a stable machine-readable slug a client branches on and translates rather than parsing `message`, which is English prose for logs. One of: `"required"`, `"too_short"`, `"too_long"`, `"pattern"`, `"invalid_format"`, `"not_allowed"`, `"minimum"`, `"maximum"`, `"too_few"`, `"too_many"`, `"not_unique"`, `"malformed"`, `"undeclared"`, `"read_only"`.

    **Compatibility:** a CLOSED enum, with the cost `ProblemCode` has: a
    client generated against an older version of this document rejects a
    field error carrying a code added after it was built.
  - `message` (string, required): Example: `"field token_type_hint must be one of [access_token, refresh_token]"`.

### 429 Too Many Requests

Too many requests.

Content type: `application/problem+json`

RFC 9457 (formerly RFC 7807) problem details (application/problem+json). `code` is a stable machine-readable slug for the problem kind (it mirrors the last path segment of `type`), so consumers can branch on it without parsing prose. `type` is `https://nauthera.io/problems/<code>`, which resolves to the code's runbook: why it happened, who is affected and what to do (RFC 9457 §3.1.1). A problem without a code has `about:blank`. `errors` is present on validation failures and lists every offending field.

- `title` (string, required): Example: `"Request validation failed"`.
- `status` (integer, required): Example: `400`.
- `type` (string (uri), optional): Example: `"https://nauthera.io/problems/validation_error"`.
- `detail` (string, optional): Example: `"One or more fields did not satisfy the API schema."`.
- `code` (enum, optional): The kind of problem, as a stable machine-readable slug a client branches on and translates rather than parsing `title` or `detail`, which are English prose for logs. A problem whose status says everything the server knows carries no `code`. One of: `"invalid_request"`, `"invalid_credentials"`, `"forbidden"`, `"unauthorized"`, `"insufficient_user_authentication"`, `"protected_account"`, `"password_held_by_directory"`, `"last_role_administrator"`, `"group_membership_managed"`, `"invalid_code"`, `"too_many_requests"`, `"too_many_attempts"`, `"account_locked"`, `"account_unavailable"`, `"already_enrolled"`, `"registration_disabled"`, `"registration_conflict"`, `"terms_acceptance_required"`, `"captcha_failed"`, `"invalid_reset_link"`, `"password_reused"`, `"password_too_short"`, `"password_too_long"`, `"password_compromised"`, `"invalid_verification_link"`, `"invalid_invitation_link"`, `"mail_relay_missing"`, `"email_unverified"`, `"not_found"`, `"conflict"`, `"precondition_failed"`, `"unavailable"`, `"busy"`, `"window_too_large"`, `"too_many_series"`, `"internal_error"`, `"rate_limited"`, `"malformed"`, `"body_too_large"`, `"unsupported_media_type"`, `"required"`, `"validation_error"`, `"unknown_org"`, `"invalid_token"`, `"invalid_dpop_proof"`, `"use_dpop_nonce"`, `"server_error"`.

  `validation_error` is the one code whose message is not a sentence about
  the code itself: the request failed the schema, and the specifics are
  the `errors` list — one entry per offending field — which a form renders
  on those fields. `required` and `malformed` are spelled like two of the
  per-field violation codes (`FieldError.code`) but mean something else;
  the two vocabularies are told apart by position, never by spelling.

  **Compatibility:** this is a CLOSED enum, with the same cost as
  `AuditAction`: a client generated against an older version of this
  document rejects a problem carrying a code added after it was built.
  Regenerate on upgrade, or decode the field as a plain string. It is
  enumerated anyway so that what a client must translate is knowable
  from the contract alone.
- `instance` (string, optional): Example: `"/introspect"`.
- `request_id` (string, optional): Example: `"8d94ed49-1caf-4ab3-9594-557142f2d023"`.
- `trace_id` (string, optional): Distributed-trace id (hex) for correlating this response with traces and logs. Present only when tracing is enabled and the request was recorded. Opaque and safe to log/share. Example: `"4bf92f3577b34da6a3ce929d0e0e4736"`.
- `errors` (array of objects, optional): Field-level violations (present for validation errors).

  Each item: A single field-level validation violation.
  - `field` (string, required): Offending field, dotted for nested bodies (e.g. child.id). Example: `"token_type_hint"`.
  - `code` (enum, required): The rule a field broke, as a stable machine-readable slug a client branches on and translates rather than parsing `message`, which is English prose for logs. One of: `"required"`, `"too_short"`, `"too_long"`, `"pattern"`, `"invalid_format"`, `"not_allowed"`, `"minimum"`, `"maximum"`, `"too_few"`, `"too_many"`, `"not_unique"`, `"malformed"`, `"undeclared"`, `"read_only"`.

    **Compatibility:** a CLOSED enum, with the cost `ProblemCode` has: a
    client generated against an older version of this document rejects a
    field error carrying a code added after it was built.
  - `message` (string, required): Example: `"field token_type_hint must be one of [access_token, refresh_token]"`.

### Error

Problem details (RFC 9457) with an RFC 6750 / RFC 9449 challenge.

Content type: `application/problem+json`

Headers:
- `Cache-Control` = `no-store`
- `WWW-Authenticate` (string)
- `DPoP-Nonce` (string)

RFC 9457 (formerly RFC 7807) problem details (application/problem+json). `code` is a stable machine-readable slug for the problem kind (it mirrors the last path segment of `type`), so consumers can branch on it without parsing prose. `type` is `https://nauthera.io/problems/<code>`, which resolves to the code's runbook: why it happened, who is affected and what to do (RFC 9457 §3.1.1). A problem without a code has `about:blank`. `errors` is present on validation failures and lists every offending field.

- `title` (string, required): Example: `"Request validation failed"`.
- `status` (integer, required): Example: `400`.
- `type` (string (uri), optional): Example: `"https://nauthera.io/problems/validation_error"`.
- `detail` (string, optional): Example: `"One or more fields did not satisfy the API schema."`.
- `code` (enum, optional): The kind of problem, as a stable machine-readable slug a client branches on and translates rather than parsing `title` or `detail`, which are English prose for logs. A problem whose status says everything the server knows carries no `code`. One of: `"invalid_request"`, `"invalid_credentials"`, `"forbidden"`, `"unauthorized"`, `"insufficient_user_authentication"`, `"protected_account"`, `"password_held_by_directory"`, `"last_role_administrator"`, `"group_membership_managed"`, `"invalid_code"`, `"too_many_requests"`, `"too_many_attempts"`, `"account_locked"`, `"account_unavailable"`, `"already_enrolled"`, `"registration_disabled"`, `"registration_conflict"`, `"terms_acceptance_required"`, `"captcha_failed"`, `"invalid_reset_link"`, `"password_reused"`, `"password_too_short"`, `"password_too_long"`, `"password_compromised"`, `"invalid_verification_link"`, `"invalid_invitation_link"`, `"mail_relay_missing"`, `"email_unverified"`, `"not_found"`, `"conflict"`, `"precondition_failed"`, `"unavailable"`, `"busy"`, `"window_too_large"`, `"too_many_series"`, `"internal_error"`, `"rate_limited"`, `"malformed"`, `"body_too_large"`, `"unsupported_media_type"`, `"required"`, `"validation_error"`, `"unknown_org"`, `"invalid_token"`, `"invalid_dpop_proof"`, `"use_dpop_nonce"`, `"server_error"`.

  `validation_error` is the one code whose message is not a sentence about
  the code itself: the request failed the schema, and the specifics are
  the `errors` list — one entry per offending field — which a form renders
  on those fields. `required` and `malformed` are spelled like two of the
  per-field violation codes (`FieldError.code`) but mean something else;
  the two vocabularies are told apart by position, never by spelling.

  **Compatibility:** this is a CLOSED enum, with the same cost as
  `AuditAction`: a client generated against an older version of this
  document rejects a problem carrying a code added after it was built.
  Regenerate on upgrade, or decode the field as a plain string. It is
  enumerated anyway so that what a client must translate is knowable
  from the contract alone.
- `instance` (string, optional): Example: `"/introspect"`.
- `request_id` (string, optional): Example: `"8d94ed49-1caf-4ab3-9594-557142f2d023"`.
- `trace_id` (string, optional): Distributed-trace id (hex) for correlating this response with traces and logs. Present only when tracing is enabled and the request was recorded. Opaque and safe to log/share. Example: `"4bf92f3577b34da6a3ce929d0e0e4736"`.
- `errors` (array of objects, optional): Field-level violations (present for validation errors).

  Each item: A single field-level validation violation.
  - `field` (string, required): Offending field, dotted for nested bodies (e.g. child.id). Example: `"token_type_hint"`.
  - `code` (enum, required): The rule a field broke, as a stable machine-readable slug a client branches on and translates rather than parsing `message`, which is English prose for logs. One of: `"required"`, `"too_short"`, `"too_long"`, `"pattern"`, `"invalid_format"`, `"not_allowed"`, `"minimum"`, `"maximum"`, `"too_few"`, `"too_many"`, `"not_unique"`, `"malformed"`, `"undeclared"`, `"read_only"`.

    **Compatibility:** a CLOSED enum, with the cost `ProblemCode` has: a
    client generated against an older version of this document rejects a
    field error carrying a code added after it was built.
  - `message` (string, required): Example: `"field token_type_hint must be one of [access_token, refresh_token]"`.

## Example request

```bash
curl -g 'https://auth.example.com/v1/admin/orgs/{slug}/audit-events/count' \
  -H "Authorization: Bearer $ACCESS_TOKEN"
```

## Example response (200)

```json
{
  "total": {
    "count": 1240,
    "at_least": false
  },
  "matching": {
    "count": 1240,
    "at_least": false
  }
}
```
