CropPath cho nhà phát triển

Tài liệu API

audit

2 thao tác

GET /v1/audit

Audit log of the caller's tenant

Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: tenant_read · listAudit

Append-only audit rows of the caller's tenant, newest first, with keyset pagination: the company's activity log (SELF-1-7, #188). Every request that reaches the handler of a mutating route writes exactly one row (ingest and broker authorization are exempt). Rows cannot be changed or deleted: there is no route for it and the table refuses it. A successful sign-in is filed under the company the session first acts for (the user's first membership); a failed sign-in carries no company and appears in no company's log. Each item names who the actor is (actor_kind, actor_name); CropPath staff (platform admins) acting for the company are support. Filters combine (every one given must match). Allowed for auditor, tenant_admin and platform_admin.

Tham số

TênVị tríKiểuMô tả
entity
không bắt buộc
querystring

Only rows about this entity type.

actor
không bắt buộc
querystring

Only rows by this actor.

entity_id
không bắt buộc
querystring

Only rows about this record id (for example a lot code). An id longer than 128 characters is matched as its stored SHA-256 form. At most 512 characters.

action_prefix
không bắt buộc
querystring

Only rows whose action starts with one of these comma-separated prefixes (at most 30; lowercase dotted words, for example lot.,carton. or export.).

since
không bắt buộc
querystring

Only rows at or after this time: an ISO 8601 date or date-time (+07:00 when it has no offset).

until
không bắt buộc
querystring

Only rows before this time (exclusive), as since; it must be after since.

cursor
không bắt buộc
querystring

next_cursor of the previous page.

limit
không bắt buộc
queryinteger

Page size, 1 to 200.

Phản hồi

Mã trạng tháiKiểuMô tả
200AuditPage
application/json

One page of audit rows.

400Error
application/json

A cursor that is not one this API issued, a limit outside 1 to 200, a malformed filter (action prefix, since, until, a range whose until is not after since, a record id over 512 characters), or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (operator and lab) or tenant not allowed (X-Tenant).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "items": [
    {
      "id": 42,
      "at": 1790000000.5,
      "actor": "admin@coop.example",
      "tenant": "coop-dl",
      "action": "envelope.review",
      "entity": "envelope",
      "entity_id": "3f2b8f0e-6a39-4f7e-9b1e-0d6c1c5e7a11",
      "before_hash": "9b0f1d6a2c7e4b3f8a5d0c9e1f2a3b4c5d6e7f8091a2b3c4d5e6f708192a3b4c",
      "after": {
        "status": 200,
        "id": "3f2b8f0e-6a39-4f7e-9b1e-0d6c1c5e7a11",
        "decision": "approve",
        "result": "accepted"
      },
      "request_id": "req-7f3a",
      "ip_hash": "c3a1e07d94b2f58a61d0e7c4b9f3a2d8e5c17b60f4a9d2e3b8c5f1a7d0e4b962",
      "actor_kind": "member",
      "actor_name": "Nguyễn Văn An"
    }
  ],
  "next_cursor": "eyJpZCI6NDJ9"
}
Phản hồi 400 · application/json · bad_cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Phản hồi 400 · application/json · bad_limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 400 · application/json · bad_action_prefix
{
  "error": "bad action prefix",
  "code": "bad_action_prefix"
}
Phản hồi 400 · application/json · bad_since
{
  "error": "bad since",
  "code": "bad_since"
}
Phản hồi 400 · application/json · bad_until
{
  "error": "bad until",
  "code": "bad_until"
}
Phản hồi 400 · application/json · bad_range
{
  "error": "bad range",
  "code": "bad_range"
}
Phản hồi 400 · application/json · bad_entity_id
{
  "error": "bad entity id",
  "code": "bad_entity_id"
}
Phản hồi 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Phản hồi 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/audit.csv

Activity log of the caller's tenant (CSV)

Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: tenant_read · getAuditCsv

The rows GET /v1/audit lists for the same filters, newest first, as a CSV download (SELF-1-7, #188): at most 10,000 rows per file; when more match, X-Next-Cursor is the cursor of the next file. An audited read (export.audit: which filters were set, by name, the parsed range and action prefixes, and the row count), downloaded as an attachment, never cached. Allowed for auditor, tenant_admin and platform_admin acting for the tenant; another tenant's rows never appear.

Tham số

TênVị tríKiểuMô tả
entity
không bắt buộc
querystring

Only rows about this entity type.

actor
không bắt buộc
querystring

Only rows by this actor.

entity_id
không bắt buộc
querystring

Only rows about this record id (for example a lot code). An id longer than 128 characters is matched as its stored SHA-256 form. At most 512 characters.

action_prefix
không bắt buộc
querystring

Only rows whose action starts with one of these comma-separated prefixes (at most 30; lowercase dotted words, for example lot.,carton. or export.).

since
không bắt buộc
querystring

Only rows at or after this time: an ISO 8601 date or date-time (+07:00 when it has no offset).

until
không bắt buộc
querystring

Only rows before this time (exclusive), as since; it must be after since.

cursor
không bắt buộc
querystring

The previous file's X-Next-Cursor; omitted for the first file.

Phản hồi

Mã trạng tháiKiểuMô tả
200string
text/csv

CSV with a header row (id, time_utc, actor, actor_kind, actor_name, action, entity, entity_id, status, error, request_id; CRLF line ends), then one row per audit row. time_utc is ISO 8601 UTC. A text cell starting with =, +, -, @, a tab or a carriage return gets a leading ' so a spreadsheet never runs it as a formula.

400Error
application/json

A cursor that is not one this API issued, a malformed filter (action prefix, since, until, a range whose until is not after since, a record id over 512 characters), or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (operator and lab) or tenant not allowed (X-Tenant).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Next-Cursor200string

The cursor of the next file; absent on the last.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Ví dụ phản hồi

Phản hồi 200 · text/csv
id,time_utc,actor,actor_kind,actor_name,action,entity,entity_id,status,error,request_id
42,2026-10-10T01:30:00Z,admin@coop.example,member,Nguyễn Văn An,lot.seal,lot,LO-260928-014,200,,req-7f3a
Phản hồi 400 · application/json · bad_cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 400 · application/json · bad_action_prefix
{
  "error": "bad action prefix",
  "code": "bad_action_prefix"
}
Phản hồi 400 · application/json · bad_since
{
  "error": "bad since",
  "code": "bad_since"
}
Phản hồi 400 · application/json · bad_until
{
  "error": "bad until",
  "code": "bad_until"
}
Phản hồi 400 · application/json · bad_range
{
  "error": "bad range",
  "code": "bad_range"
}
Phản hồi 400 · application/json · bad_entity_id
{
  "error": "bad entity id",
  "code": "bad_entity_id"
}
Phản hồi 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Phản hồi 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}