Activity API
Every Activity action (2) and data model (2): endpoints, scopes, input, preconditions, events and examples.
A live feed of everything that happens in your workspace.
Module code activity · 2 actions · 2 data models · 2 events. A key or token never does more here than the person behind it can; row-level security applies exactly as in the app. Scopes: activity (everything), activity:read (read only) or activity:<capability>.
Resources
| Resource | Table | List and read | POST | PATCH | DELETE |
|---|---|---|---|---|---|
activities | activity | /api/v1/activities | |||
events | event | /api/v1/events |
Lists take limit (up to 200), cursor, order (e.g. -created_at), fields and q; every other query parameter is a column filter: ?status=paid, ?total[gte]=100, ?id[in]=a,b, ?x=null.
Actions
| Action | Needs | What it does |
|---|---|---|
activity.purge | activity:manage | Apply the activity retention policy |
activity.seal | activity:manage | Seal the audit trail |
activity.purge
Apply the activity retention policy — Deletes activity older than the workspace’s retention window. 0 keeps everything.
Needs activity:manage · removes or cannot be undone · asks a person to confirm when Era runs it
https://app.getera.io/api/v1/activities/actions/purge- Canonical address:
POST /api/v1/actions/activity.purge
Input
| Field | Type | Required | Notes |
|---|---|---|---|
days | number | Keep (days) |
Preconditions
The action is refused with 409 and one of these codes:
| Code | Refused when |
|---|---|
retention_too_short | Retention must be 0 (keep everything) or at least 30 days. |
Events it publishes: activity.purged
What it writes: activity (delete) — Removes rows older than the window
curl -X POST https://app.getera.io/api/v1/activities/actions/purge \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"days":1}'{
"ok": true,
"result": "…",
"events": [
"activity.purged"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.activities.purge({
days: 1
})era activities purge \
--days 1{
"name": "era__activity__purge",
"arguments": {
"days": 1
}
}Errors: 401 no or expired credential · 403 the credential does not hold activity:manage · 404 the record or module is outside what it may reach · 422 invalid input (problems[]) · 409 retention_too_short · 429 slow down
activity.seal
Seal the audit trail — Chains every settled activity row to the one before it, so a later change is detectable.
Needs activity:manage · changes data
https://app.getera.io/api/v1/activities/actions/seal- Canonical address:
POST /api/v1/actions/activity.seal
Input
This action takes no input.
Events it publishes: activity.sealed
What it writes: activity (update) — Writes prev_hash and row_hash on unsealed rows
curl -X POST https://app.getera.io/api/v1/activities/actions/seal \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{}'{
"ok": true,
"result": "…",
"events": [
"activity.sealed"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.activities.seal()era activities seal{
"name": "era__activity__seal",
"arguments": {}
}Errors: 401 no or expired credential · 403 the credential does not hold activity:manage · 404 the record or module is outside what it may reach · 422 invalid input (problems[]) · 429 slow down
Data models
Activity
Table activity · Resource activities
GET /api/v1/activitiesGET /api/v1/activities/{id}
| Column | Type | Nullable | Allowed values | References |
|---|---|---|---|---|
id | string (int64) · int8 | |||
organization_id | string (uuid) · uuid | organization | ||
workspace_id | string (uuid) · uuid | workspace | ||
actor_type | string · text | |||
actor_id | string (uuid) · uuid | yes | ||
actor_label | string · text | yes | ||
module_code | string · text | |||
record_type | string · text | yes | ||
record_id | string (uuid) · uuid | yes | ||
verb | string · text | |||
summary | string · text | |||
diff | object · jsonb | yes | ||
source | string · text | |||
occurred_at | string (date-time) · timestamptz | |||
reason | string · text | yes | ||
correlation_id | string (uuid) · uuid | yes | ||
run_id | string · text | yes | ||
job_id | string · text | yes | ||
source_ip | string · text | yes | ||
user_agent | string · text | yes | ||
sealed_at | string (date-time) · timestamptz | yes |
Primary key: id
Event
Table event · Resource events
GET /api/v1/eventsGET /api/v1/events/{id}
| Column | Type | Nullable | Allowed values | References |
|---|---|---|---|---|
id | string (int64) · int8 | |||
organization_id | string (uuid) · uuid | organization | ||
workspace_id | string (uuid) · uuid | workspace | ||
name | string · text | |||
module_code | string · text | |||
record_id | string (uuid) · uuid | yes | ||
payload | object · jsonb | |||
source | string · text | |||
occurred_at | string (date-time) · timestamptz | |||
dispatched_at | string (date-time) · timestamptz | yes | ||
attempts | integer · int4 | |||
last_error | string · text | yes | ||
next_attempt_at | string (date-time) · timestamptz | yes | ||
correlation_id | string (uuid) · uuid | yes |
Primary key: id
Events
Workflows and webhooks react to these events.
| Event | What happens | Payload |
|---|---|---|
activity.purged | Activity past the retention window was deleted. | days, removed |
activity.sealed | Settled activity rows were chained into the audit seal. | sealed |