Leave API
Konten ini belum tersedia dalam bahasa Anda.
Leave requests, balances, types and cover. 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/leave/requests: List leave requestsGET /api/leave/requests/:id: Get a leave requestPOST /api/leave/requests: Request leavePOST /api/leave/requests/:id/cancel: Cancel a leave requestGET /api/leave/balances/mine: Get your leave balancesGET /api/leave/types: List leave typesGET /api/leave/peers: List colleagues who can cover
List leave requests
GET /api/leave/requests
Your own leave requests, or the team’s with scope=team. Dates are epoch milliseconds at UTC midnight.
Sort keys: start_date (default), status, created_at.
- Product: Leave (
leave) - Permission (any of):
leave:request:read_own,leave:request:read_others,leave:report:read
Query parameters
| Field | Type | Required | Description |
|---|---|---|---|
page |
string |
no | 1-based page number. Default 1. |
pageSize |
string |
no | Rows per page, 1 to 100. Larger values are clamped. Default 20. |
search |
string |
no | Free-text filter (trimmed, first 200 characters). |
sort |
string |
no | Sort key. Unknown keys fall back to the endpoint’s default sort. |
dir |
string |
no | asc or desc (default). |
scope |
string |
no | mine (default) or team. team needs leave:request:read_others, leave:report:read, leave:approval:approve or leave:approval:override. |
status |
string |
no | pending, approved, rejected, cancelled or revision_requested. |
from |
string |
no | Requests ending on or after this time (epoch milliseconds). |
to |
string |
no | Requests starting on or before this time (epoch milliseconds). |
year |
string |
no | Calendar year, e.g. 2026. |
month |
string |
no | Month 1 to 12 (with year). |
type_id |
string |
no | Only this leave type. |
Response 200
One page of requests.
| Field | Type | Description |
|---|---|---|
items |
object[] |
|
items[].id |
string |
|
items[].requester_id |
string |
|
items[].type_id |
string |
|
items[].start_date |
number |
First day, epoch milliseconds (UTC midnight). |
items[].end_date |
number |
Last day, epoch milliseconds (UTC midnight). |
items[].days |
number |
Working days the request counts. |
items[].is_backdated |
number |
1 = emergency or retroactive request filed on or after start date. |
items[].reason |
string |
|
items[].covering_peer_id |
string |
|
items[].status |
"pending" | "approved" | "rejected" | "cancelled" | "revision_requested" |
|
items[].approver_id |
string | null |
|
items[].decided_at |
number | null |
|
items[].decision_note |
string | null |
|
items[].created_at |
number |
|
items[].requester_name |
string | null |
|
items[].type_name |
string |
|
items[].covering_peer_name |
string | null |
|
items[].approval_instance_id |
string | null |
Approval timeline: GET /api/approvals/instances/{id}. |
total |
number |
|
page |
number |
|
pageSize |
number |
Objects may carry more fields than listed; only the listed ones are part of the contract.
Errors: forbidden, plus the shared ones. Meanings: error codes.
Example
curl -X GET 'https://app.aio.opexcg.com/api/leave/requests?pageSize=2' \ -H "X-API-Key: $OPEX_API_KEY"Response 200:
{ "items": [ { "id": "cf0af695-a15a-4b4f-abba-4caa5cc54d7c", "tenant_id": "opexcg-tenant", "requester_id": "usr-fitri-handayani", "requester_name": "Fitri Handayani", "type_id": "e1ca06b1-cf8d-41e9-b2ff-85f1a1c3706a", "type_name": "Sick", "paid": 1, "start_date": 1837814400000, "end_date": 1837900800000, "days": 2, "reason": "Family event", "covering_peer_id": "usr-sari-wulandari", "covering_peer_name": "Sari Wulandari", "status": "pending", "approver_id": null, "approver_name": null, "decided_at": null, "decision_note": null, "created_at": 1794052051232, "modified_at": 1794052051232, "deleted_at": null, "approval_instance_id": "3ff4d93a-c92b-4a2c-b9de-3c3faf0718c9" } ], "total": 1, "page": 1, "pageSize": 2}Get a leave request
GET /api/leave/requests/:id
One leave request. Visible to the requester and to the people who approve or manage leave.
- Product: Leave (
leave) - Permission: any member
Path parameters
| Field | Type | Required | Description |
|---|---|---|---|
id |
string |
yes | Leave request id. |
Response 200
The request.
| Field | Type | Description |
|---|---|---|
id |
string |
|
requester_id |
string |
|
type_id |
string |
|
start_date |
number |
First day, epoch milliseconds (UTC midnight). |
end_date |
number |
Last day, epoch milliseconds (UTC midnight). |
days |
number |
Working days the request counts. |
is_backdated |
number |
1 = emergency or retroactive request filed on or after start date. |
reason |
string |
|
covering_peer_id |
string |
|
status |
"pending" | "approved" | "rejected" | "cancelled" | "revision_requested" |
|
approver_id |
string | null |
|
decided_at |
number | null |
|
decision_note |
string | null |
|
created_at |
number |
|
requester_name |
string | null |
|
type_name |
string |
|
covering_peer_name |
string | null |
|
approval_instance_id |
string | null |
Approval timeline: GET /api/approvals/instances/{id}. |
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
curl -X GET 'https://app.aio.opexcg.com/api/leave/requests/cf0af695-a15a-4b4f-abba-4caa5cc54d7c' \ -H "X-API-Key: $OPEX_API_KEY"Response 200:
{ "id": "cf0af695-a15a-4b4f-abba-4caa5cc54d7c", "tenant_id": "opexcg-tenant", "requester_id": "usr-fitri-handayani", "requester_name": "Fitri Handayani", "type_id": "e1ca06b1-cf8d-41e9-b2ff-85f1a1c3706a", "type_name": "Sick", "paid": 1, "start_date": 1837814400000, "end_date": 1837900800000, "days": 2, "reason": "Family event", "covering_peer_id": "usr-sari-wulandari", "covering_peer_name": "Sari Wulandari", "status": "pending", "approver_id": null, "approver_name": null, "decided_at": null, "decision_note": null, "created_at": 1794052051232, "modified_at": 1794052051232, "deleted_at": null, "approval_instance_id": "3ff4d93a-c92b-4a2c-b9de-3c3faf0718c9"}Request leave
POST /api/leave/requests
Files a leave request for the caller and starts its approval. start_date and end_date are calendar days (YYYY-MM-DD); covering_peer_id is a colleague from the peers list who covers while you are away.
- Product: Leave (
leave) - Permission (any of):
leave:request:create
Request body (JSON)
| Field | Type | Required | Description |
|---|---|---|---|
type_id |
string |
yes | min length 1 |
start_date |
integer | string |
yes | |
end_date |
integer | string |
yes | |
reason |
string |
yes | min length 1, max length 2000 |
covering_peer_id |
string |
yes | min length 1 |
Response 201
The new request.
| Field | Type | Description |
|---|---|---|
id |
string |
|
requester_id |
string |
|
type_id |
string |
|
start_date |
number |
First day, epoch milliseconds (UTC midnight). |
end_date |
number |
Last day, epoch milliseconds (UTC midnight). |
days |
number |
Working days the request counts. |
is_backdated |
number |
1 = emergency or retroactive request filed on or after start date. |
reason |
string |
|
covering_peer_id |
string |
|
status |
"pending" | "approved" | "rejected" | "cancelled" | "revision_requested" |
|
approver_id |
string | null |
|
decided_at |
number | null |
|
decision_note |
string | null |
|
created_at |
number |
Objects may carry more fields than listed; only the listed ones are part of the contract.
Errors: forbidden, invalid_window, window_too_long, type_not_found, zero_working_days, overlapping_leave, leave_balance_not_allocated, backdated_not_allowed, exceeds_max_backdated_days, plus the shared ones. Meanings: error codes.
Example
curl -X POST 'https://app.aio.opexcg.com/api/leave/requests' \ -H "X-API-Key: $OPEX_API_KEY" \ -H "content-type: application/json" \ -d '{"type_id":"e1ca06b1-cf8d-41e9-b2ff-85f1a1c3706a","start_date":"2028-03-28","end_date":"2028-03-29","reason":"Family event","covering_peer_id":"usr-sari-wulandari"}'Response 201:
{ "id": "cf0af695-a15a-4b4f-abba-4caa5cc54d7c", "tenant_id": "opexcg-tenant", "requester_id": "usr-fitri-handayani", "type_id": "e1ca06b1-cf8d-41e9-b2ff-85f1a1c3706a", "start_date": 1837814400000, "end_date": 1837900800000, "days": 2, "reason": "Family event", "covering_peer_id": "usr-sari-wulandari", "status": "pending", "approver_id": null, "decided_at": null, "decision_note": null, "created_at": 1794052051232, "created_by": "usr-fitri-handayani", "modified_at": 1794052051232, "modified_by": "usr-fitri-handayani", "deleted_at": null, "deleted_by": null}Cancel a leave request
POST /api/leave/requests/:id/cancel
Cancels a request. Your own need leave:request:cancel_own, anyone else’s leave:request:cancel_others.
- Product: Leave (
leave) - Permission (any of):
leave:request:cancel_own,leave:request:cancel_others
Path parameters
| Field | Type | Required | Description |
|---|---|---|---|
id |
string |
yes | Leave request id. |
Response 200
The cancelled request.
| Field | Type | Description |
|---|---|---|
id |
string |
|
requester_id |
string |
|
type_id |
string |
|
start_date |
number |
First day, epoch milliseconds (UTC midnight). |
end_date |
number |
Last day, epoch milliseconds (UTC midnight). |
days |
number |
Working days the request counts. |
is_backdated |
number |
1 = emergency or retroactive request filed on or after start date. |
reason |
string |
|
covering_peer_id |
string |
|
status |
"pending" | "approved" | "rejected" | "cancelled" | "revision_requested" |
|
approver_id |
string | null |
|
decided_at |
number | null |
|
decision_note |
string | null |
|
created_at |
number |
Objects may carry more fields than listed; only the listed ones are part of the contract.
Errors: not_found, forbidden, invalid_transition, plus the shared ones. Meanings: error codes.
Example
curl -X POST 'https://app.aio.opexcg.com/api/leave/requests/cf0af695-a15a-4b4f-abba-4caa5cc54d7c/cancel' \ -H "X-API-Key: $OPEX_API_KEY"Response 200:
{ "id": "cf0af695-a15a-4b4f-abba-4caa5cc54d7c", "tenant_id": "opexcg-tenant", "requester_id": "usr-fitri-handayani", "type_id": "e1ca06b1-cf8d-41e9-b2ff-85f1a1c3706a", "start_date": 1837814400000, "end_date": 1837900800000, "days": 2, "reason": "Family event", "covering_peer_id": "usr-sari-wulandari", "status": "cancelled", "approver_id": null, "decided_at": 1794052051531, "decision_note": null, "created_at": 1794052051232, "created_by": "usr-fitri-handayani", "modified_at": 1794052051532, "modified_by": "usr-fitri-handayani", "deleted_at": null, "deleted_by": null}Get your leave balances
GET /api/leave/balances/mine
Your allowance, used and remaining days per leave type for one year.
- Product: Leave (
leave) - Permission (any of):
leave:balance:read_own
Query parameters
| Field | Type | Required | Description |
|---|---|---|---|
year |
string |
no | Balance year, e.g. 2026. Default: the current year (UTC). |
Response 200
Your balances.
| Field | Type | Description |
|---|---|---|
items |
object[] |
|
items[].type_id |
string |
|
items[].type_name |
string |
|
items[].year |
number |
|
items[].total_allowance |
number |
|
items[].used_days |
number |
|
items[].pending_days |
number |
Days in requests still waiting for approval. |
items[].expires_at |
number | null |
|
has_active_policy |
boolean |
|
missing_hire_date |
boolean |
|
missing_hire_date_count |
number |
Objects may carry more fields than listed; only the listed ones are part of the contract.
Example
curl -X GET 'https://app.aio.opexcg.com/api/leave/balances/mine' \ -H "X-API-Key: $OPEX_API_KEY"Response 200:
{ "items": []}List leave types
GET /api/leave/types
The workspace’s leave types. Use an id as type_id when requesting leave.
- Product: Leave (
leave) - Permission (any of):
leave:type:read
Response 200
The leave types.
| Field | Type | Description |
|---|---|---|
items |
object[] |
|
items[].id |
string |
|
items[].name |
string |
|
items[].paid |
number |
1 = paid leave. |
items[].requires_quota |
number |
1 = counted against a yearly allowance. |
items[].default_allowance |
number |
|
items[].allow_backdated |
number |
1 = allows emergency or retroactive leave requests. |
items[].max_backdated_days |
number |
Maximum past days allowed for retroactive requests. |
items[].description |
string | null |
Objects may carry more fields than listed; only the listed ones are part of the contract.
Example
curl -X GET 'https://app.aio.opexcg.com/api/leave/types' \ -H "X-API-Key: $OPEX_API_KEY"Response 200:
{ "items": [ { "id": "b09deadf-87b7-4f11-bce1-d9b2c63c34ce", "name": "Annual", "paid": 1, "requires_quota": 1, "default_allowance": 12, "description": "Cuti tahunan berbayar (12 hari/tahun)" }, { "id": "e1ca06b1-cf8d-41e9-b2ff-85f1a1c3706a", "name": "Sick", "paid": 1, "requires_quota": 0, "default_allowance": 0, "description": "Izin sakit berbayar tanpa pemotongan kuota" } ]}List colleagues who can cover
GET /api/leave/peers
Active members of the workspace other than you (up to 100), for covering_peer_id.
- Product: Leave (
leave) - Permission: any member
Query parameters
| Field | Type | Required | Description |
|---|---|---|---|
search |
string |
no | Substring of the member’s name or email. |
includeInactive |
string |
no | true to include deactivated members. |
includeSelf |
string |
no | true to include yourself. |
Response 200
The members.
| Field | Type | Description |
|---|---|---|
items |
object[] |
|
items[].id |
string |
|
items[].name |
string | null |
|
items[].email |
string |
|
items[].role |
string |
|
items[].is_active |
number |
Objects may carry more fields than listed; only the listed ones are part of the contract.
Example
curl -X GET 'https://app.aio.opexcg.com/api/leave/peers' \ -H "X-API-Key: $OPEX_API_KEY"Response 200:
{ "items": [ { "id": "usr-sari-wulandari", "name": "Sari Wulandari", "role": "admin", "is_active": 1 }, { "id": "usr-budi-santoso", "name": "Budi Santoso", "role": "admin", "is_active": 1 } ]}