# Audit logs

Source: https://www.pontive.com/docs/api-reference/management/audit-logs

Base URL: `https://api.{region}.pontive.com/v1` (operations that name another server say so).

Authentication: send `Authorization: Bearer <token>` with a secret key (`pontive_sk_…`, which implies its instance) or an access token issued for this API. A token that can reach several instances also names one with `X-Pontive-Instance-ID: inst_…`. Secret keys are for servers only.

## List audit log entries

```http
GET https://api.{region}.pontive.com/v1/logs/audit
```

The instance's audit log, newest first. Pass next_cursor as before to page back, or as after to poll for what committed since, oldest first. Needs sys:audit:read on the instance, or on the organization named by organization_id.

Operation ID: `ListAuditLogs`

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `action` | string[] |  | Action name, or a prefix such as pontive.secret_key.* (repeatable) |
| `category` | string[] |  | Category (repeatable) |
| `severity` | string[] |  | info, warning or high (repeatable) |
| `result` | string[] |  | success, failure or denied (repeatable) |
| `actor_type` | string |  | Actor type |
| `actor_id` | string |  | Actor id |
| `actor_instance` | string |  | The agent instance that acted (an agent actor's actor.instance) |
| `on_behalf_of` | string |  | A delegator (usr_…): entries an actor wrote for them with a delegated token |
| `credential_id` | string |  | Credential id, such as a secret key's key_… |
| `target_id` | string |  | Id of any target |
| `organization_id` | string |  | An organization's entries (org_…) |
| `ip_address` | string |  | Client IP address |
| `request_id` | string |  | Request id (req_…) |
| `subject` | string |  | An entity in any role: the actor, the credential or a target |
| `from` | string |  | RFC 3339: occurred at or after |
| `to` | string |  | RFC 3339: occurred before |
| `after` | string |  | Cursor: entries committed after it, oldest first |
| `before` | string |  | Cursor: older entries, newest first |
| `limit` | integer |  | 1–100, default 50 |

### Responses

- `200` OK: ListResponseDoc
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `503` Service Unavailable: ErrResponse

## Get an audit log entry

```http
GET https://api.{region}.pontive.com/v1/logs/audit/{audit_log_entry_id}
```

One audit_log_entry (pontive-spec 43 §4.1).

Operation ID: `GetAuditLog`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `audit_log_entry_id` | string | yes | Entry id (ale_…) |

### Responses

- `200` OK: AuditLogEntryDoc
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` Not Found: ErrResponse
- `503` Service Unavailable: ErrResponse

## List request log entries

```http
GET https://api.{region}.pontive.com/v1/logs/requests
```

Every management-API call made against the instance, reads included, newest first. Needs sys:audit:read on the instance.

Operation ID: `ListRequestLogs`

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `actor_type` | string |  | Actor type, such as agent |
| `actor_id` | string |  | Actor id |
| `actor_instance` | string |  | The agent instance that made the request (an agent actor's actor.instance) |
| `on_behalf_of` | string |  | A delegator (usr_…): requests an actor made for them with a delegated token |
| `credential_id` | string |  | Credential id, such as a secret key's key_… |
| `method` | string[] |  | GET, POST, PUT, PATCH or DELETE (repeatable) |
| `status_class` | string[] |  | 2xx, 3xx, 4xx or 5xx (repeatable) |
| `ip_address` | string |  | Client IP address |
| `route` | string |  | Route pattern, as recorded (/v1/users/{identifier}) |
| `from` | string |  | RFC 3339: occurred at or after |
| `to` | string |  | RFC 3339: occurred before |
| `after` | string |  | Cursor: entries committed after it, oldest first |
| `before` | string |  | Cursor: older entries, newest first |
| `limit` | integer |  | 1–100, default 50 |

### Responses

- `200` OK: ListResponseDoc
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `503` Service Unavailable: ErrResponse

## Get a request log entry

```http
GET https://api.{region}.pontive.com/v1/logs/requests/{request_id}
```

One request_log_entry (pontive-spec 43 §4.6), by the request id returned in X-Request-ID.

Operation ID: `GetRequestLog`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `request_id` | string | yes | Request id (req_…) |

### Responses

- `200` OK: RequestLogEntryDoc
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` Not Found: ErrResponse
- `503` Service Unavailable: ErrResponse

## List the agent activity in an organization

```http
GET https://api.{region}.pontive.com/v1/organizations/{organization}/agent-activity
```

What agents did in the organization (pontive-spec 20 G2, G3): its audit entries whose actor is an agent, on its own installation or acting for a member with a delegated token (on_behalf_of names the member), newest first. Filter by actor_id (an agt_…) and on_behalf_of (a usr_…). The view an organization's owners and admins read from the embedded agent-management element, with pontive:org:agent:read; audit-svc decides it with sys:audit:read on the organization, which they hold.

Operation ID: `ListOrganizationAgentActivity`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `organization` | string | yes | The organization's id, or its slug |

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `action` | string[] |  | Action name, or a prefix such as pontive.member.* (repeatable) |
| `actor_id` | string |  | One agent (agt_…) |
| `actor_instance` | string |  | The agent instance that acted (an agent actor's actor.instance) |
| `on_behalf_of` | string |  | A member (usr_…): what agents did for them with a delegated token |
| `from` | string |  | RFC 3339: occurred at or after |
| `to` | string |  | RFC 3339: occurred before |
| `after` | string |  | Cursor: entries committed after it, oldest first |
| `before` | string |  | Cursor: older entries, newest first |
| `limit` | integer |  | 1–100, default 50 |

### Responses

- `200` OK: ListResponseDoc
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `503` Service Unavailable: ErrResponse

## List an organization's audit log entries

```http
GET https://api.{region}.pontive.com/v1/organizations/{organization}/audit-logs
```

The entries that belong to one organization: the view its admins read with sys:audit:read on the organization. Same filters and cursors as GET /audit-logs.

Operation ID: `ListOrganizationAuditLogs`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `organization` | string | yes | The organization's id, or its slug |

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `action` | string[] |  | Action name, or a prefix such as pontive.member.* (repeatable) |
| `severity` | string[] |  | info, warning or high (repeatable) |
| `actor_id` | string |  | Actor id |
| `actor_instance` | string |  | The agent instance that acted (an agent actor's actor.instance) |
| `on_behalf_of` | string |  | A delegator (usr_…): entries an actor wrote for them with a delegated token |
| `target_id` | string |  | Id of any target |
| `from` | string |  | RFC 3339: occurred at or after |
| `to` | string |  | RFC 3339: occurred before |
| `after` | string |  | Cursor: entries committed after it, oldest first |
| `before` | string |  | Cursor: older entries, newest first |
| `limit` | integer |  | 1–100, default 50 |

### Responses

- `200` OK: ListResponseDoc
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `503` Service Unavailable: ErrResponse

## Schemas

### ListResponseDoc

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | Record<string, any>[] |  |  |
| `next_cursor` | string |  |  |
| `object` | string |  |  |

### ErrResponse

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | ErrBody |  |  |

### AuditLogEntryDoc

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `action` | string |  |  |
| `actor` | Actor |  |  |
| `category` | string |  |  |
| `changes` | Record<string, any> |  |  |
| `context` | Context |  |  |
| `credential` | Credential |  |  |
| `details` | Record<string, any> |  |  |
| `id` | string |  |  |
| `object` | string |  |  |
| `occurred_at` | string |  |  |
| `on_behalf_of` | Actor[] |  |  |
| `outcome` | Outcome |  |  |
| `schema_version` | integer |  |  |
| `scope` | Scope |  |  |
| `severity` | string |  |  |
| `targets` | Target[] |  |  |

### RequestLogEntryDoc

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `actor` | Actor |  |  |
| `context` | Context |  |  |
| `credential` | Credential |  |  |
| `duration_ms` | integer |  |  |
| `error_code` | string |  |  |
| `id` | string |  |  |
| `method` | string |  |  |
| `object` | string |  |  |
| `occurred_at` | string |  |  |
| `on_behalf_of` | Actor[] |  |  |
| `path` | string |  |  |
| `route` | string |  |  |
| `scope` | Scope |  |  |
| `status` | integer |  |  |

### ErrBody

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `code` | string |  | Code is the spec's machine-readable code for this error, in snake case: a domain code such as seat_limit_reached where the refusal has one, otherwise a generic one such as permission_denied, not_found, conflict, invalid_request or service_unavailable. |
| `details` | ErrDetail[] |  | Details are per-field findings, present only on a refusal that has them, e.g. a 422 invalid_theme names each invalid value by its path, a 422 package_invalid each problem, and a 409 capability_in_use each count by its name. |
| `doc_url` | string |  | DocURL links to documentation about this error, when available. |
| `message` | string |  | Message is a human-readable description of what went wrong. |
| `object` | string |  | Object is the discriminator; always "error". |
| `param` | string |  | Param names the request parameter this error refers to, when applicable. |
| `type` | "validation_error" \| "authentication_error" \| "authorization_error" \| "not_found" \| "conflict_error" \| "rate_limit_error" \| "internal_error" |  | Type is the error's category, set by its HTTP status: one of validation_error, authentication_error, authorization_error, not_found, conflict_error, rate_limit_error, internal_error. |

### Actor

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `access` | StaffAccess |  |  |
| `email` | string |  |  |
| `id` | string |  |  |
| `instance` | string |  | Instance is the running copy of an agent that acted (pontive-spec 45 §12, 20 D10): the token's agent_instance. Only for an agent actor. |
| `name` | string |  |  |
| `type` | string |  |  |

### Context

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `asn` | ASN |  |  |
| `geo` | Geo |  |  |
| `ip_address` | string |  |  |
| `origin` | string |  |  |
| `request_id` | string |  |  |
| `trace_id` | string |  |  |
| `user_agent` | string |  |  |

### Credential

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `app_id` | string |  |  |
| `id` | string |  |  |
| `session_id` | string |  |  |
| `type` | string |  |  |
| `value` | string |  |  |

### Outcome

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `reason` | string |  |  |
| `result` | string |  |  |

### Scope

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `instance_id` | string |  |  |
| `organization_id` | string |  |  |
| `project_id` | string |  |  |
| `workspace_id` | string |  |  |

### Target

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string |  |  |
| `name` | string |  |  |
| `type` | string |  |  |

### ErrDetail

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `field` | string |  | Field is where the finding is: for a theme, its dotted path. |
| `message` | string |  | Message is what is wrong there. |

### StaffAccess

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `expires_at` | string |  |  |
| `reason` | string |  |  |
| `session_id` | string |  |  |

### ASN

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string |  |  |
| `number` | integer |  |  |

### Geo

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `city` | string |  |  |
| `country` | string |  |  |
| `region` | string |  |  |
