Skip to content

Approvals API

One approval inbox for every product. Every endpoint below is part of the stable v1 contract. Base URL https://app.aio.opexcg.com; send your key in X-API-Key.

  • GET /api/approvals/inbox: List your pending approvals
  • POST /api/approvals/tasks/:id/decide: Approve or reject
  • GET /api/approvals/instances/:id: Get an approval’s timeline

List your pending approvals

GET /api/approvals/inbox

Approval tasks waiting for the caller across every product the workspace can use, oldest first. Each item names the record (product, entityType, entityId) and carries rev, the instance revision.

  • Product: none (any workspace)
  • Permission: any member

Query parameters

Field Type Required Description
limit integer no Most tasks to return, 1 to 100. Default 50. min 1, max 100, default 50
product string no Only this product’s tasks, e.g. expenses. All products when absent. min length 1, max length 32

Response 200

Pending tasks.

Field Type Description
items object[]
items[].taskId string Decide with this id.
items[].instanceId string
items[].product string Owning product, e.g. expenses, leave.
items[].entityType string
items[].entityId string Id of the record being approved.
items[].requesterId string
items[].requesterName string | null
items[].stageName string
items[].stageIndex number
items[].stageCount number
items[].mode "any" | "all" | "n_of_m" How many approvers a stage needs.
items[].requiredCount number
items[].approvedCount number
items[].rev number Instance revision.
items[].submittedAt number
items[].dueAt number | null
items[].title string | null
items[].summary string | null
items[].link string | null Path in the web app.

Objects may carry more fields than listed; only the listed ones are part of the contract.

Example

Terminal window
curl -X GET 'https://app.aio.opexcg.com/api/approvals/inbox' \
-H "X-API-Key: $OPEX_API_KEY"

Response 200:

{
"items": [
{
"taskId": "5463c184-da51-4b84-9c77-4a7229e51fc2",
"instanceId": "c85d566c-fe01-453e-bd0f-3088c2026c26",
"product": "leave",
"entityType": "leave_request",
"entityId": "f5e82a9f-325e-4069-a3a7-5e3e56a039d5",
"requesterId": "usr-fajar-nugroho",
"requesterName": "Fajar Nugroho",
"stageName": "Approval",
"stageIndex": 0,
"stageCount": 1,
"mode": "any",
"requiredCount": 1,
"approvedCount": 0,
"rev": 0,
"submittedAt": 1794052051774,
"dueAt": null,
"title": "Sick leave for Fajar Nugroho",
"summary": "2028-03-31 → 2028-03-31 · 1 working day",
"link": "/leave/approvals?requestId=f5e82a9f-325e-4069-a3a7-5e3e56a039d5"
}
]
}

Approve or reject

POST /api/approvals/tasks/:id/decide

Records the caller’s decision on one approval task. The answer says what happened: the vote was recorded (the stage needs more approvers), the instance advanced to its next stage, or it ended approved or rejected. A task that was already decided, or whose instance moved on, answers 409; re-read the inbox and try again.

  • Product: none (any workspace)
  • Permission: any member
  • Also: Only the task’s assignee may decide it; the record’s product must be entitled.

Path parameters

Field Type Required Description
id string yes Approval task id (taskId from the inbox).

Request body (JSON)

Field Type Required Description
decision "approved" | "rejected" yes
comment string | null no

Response 200

The outcome.

Field Type Description
instanceId string
status "pending" | "approved" | "rejected" | "cancelled"
currentStage number
outcome "recorded" | "advanced" | "approved" | "rejected" What the decision did.

Objects may carry more fields than listed; only the listed ones are part of the contract.

Errors: not_found, approval_conflict, approval_not_assignee, self_approval_not_allowed, plus the shared ones. Meanings: error codes.

Example

Terminal window
curl -X POST 'https://app.aio.opexcg.com/api/approvals/tasks/5463c184-da51-4b84-9c77-4a7229e51fc2/decide' \
-H "X-API-Key: $OPEX_API_KEY" \
-H "content-type: application/json" \
-d '{"decision":"approved","comment":"Enjoy the day off"}'

Response 200:

{
"instanceId": "c85d566c-fe01-453e-bd0f-3088c2026c26",
"status": "approved",
"currentStage": 0,
"outcome": "approved"
}

Get an approval’s timeline

GET /api/approvals/instances/:id

One approval instance: its status, every stage with its tasks and decisions, and the event history.

  • Product: none (any workspace)
  • Permission: any member
  • Also: The requester, a participant, or a holder of the product’s approve or override permission.

Path parameters

Field Type Required Description
id string yes Approval instance id (instanceId).

Response 200

The timeline.

Field Type Description
id string
product string
entityType string
entityId string
requesterId string
status "pending" | "approved" | "rejected" | "cancelled"
currentStage number
rev number
submittedAt number
closedAt number | null
definitionName string The approval workflow that applied.
version number
stages object[]
stages[].index number
stages[].name string
stages[].mode "any" | "all" | "n_of_m" How many approvers a stage needs.
stages[].requiredCount number
stages[].approvedCount number
stages[].status "pending" | "approved" | "rejected" | "skipped" | "cancelled" | "upcoming"
stages[].dueAt number | null
stages[].tasks object[]
stages[].tasks[].id string
stages[].tasks[].assigneeId string
stages[].tasks[].assigneeName string | null
stages[].tasks[].status "pending" | "approved" | "rejected" | "skipped" | "superseded"
stages[].tasks[].decidedAt number | null
stages[].tasks[].comment string | null
events object[]
events[].kind string
events[].actorId string | null
events[].actorName string | null
events[].createdAt number

Objects may carry more fields than listed; only the listed ones are part of the contract.

Errors: not_found, forbidden, plus the shared ones. Meanings: error codes.

Example

Terminal window
curl -X GET 'https://app.aio.opexcg.com/api/approvals/instances/c85d566c-fe01-453e-bd0f-3088c2026c26' \
-H "X-API-Key: $OPEX_API_KEY"

Response 200:

{
"id": "c85d566c-fe01-453e-bd0f-3088c2026c26",
"product": "leave",
"entityType": "leave_request",
"entityId": "f5e82a9f-325e-4069-a3a7-5e3e56a039d5",
"requesterId": "usr-fajar-nugroho",
"status": "pending",
"currentStage": 0,
"rev": 0,
"submittedAt": 1794052051774,
"closedAt": null,
"definitionName": "Standard leave approval",
"version": 1,
"stages": [
{
"index": 0,
"key": "approve",
"name": "Approval",
"mode": "any",
"requiredCount": 1,
"approvedCount": 0,
"status": "pending",
"dueAt": null,
"tasks": [
{
"id": "9b522958-fa67-4bdb-b93f-c8ed3a0ff898",
"assigneeId": "usr-sari-wulandari",
"assigneeName": "Sari Wulandari",
"delegatedFrom": null,
"status": "pending",
"decidedAt": null,
"comment": null
},
{
"id": "5fb7f2ae-773e-4880-a915-86fbeca7bb8b",
"assigneeId": "usr-wulan-sari",
"assigneeName": "Wulan Sari",
"delegatedFrom": null,
"status": "pending",
"decidedAt": null,
"comment": null
}
]
}
],
"events": [
{
"kind": "submitted",
"actorId": "usr-fajar-nugroho",
"actorName": "Fajar Nugroho",
"taskId": null,
"createdAt": 1794052051774,
"data": {
"version": 1
}
},
{
"kind": "stage_opened",
"actorId": null,
"actorName": null,
"taskId": null,
"createdAt": 1794052051774,
"data": {
"stage": "approve",
"approvers": 16,
"fallback": false
}
}
]
}