Docs

Approve or decline a shift swap

Preview· P9
POST
/shift-swaps/{shift_swap_id}/decide

Approves or declines a swap waiting for approval (status: accepted), all its approval steps at once (your organisation's approvers decide step by step in Agoo Workspace and the Console). Approving moves the shift to the colleague who took it (and the shift asked for in return to the person who offered it), and both are told; it's refused with conflict when either now has a shift at that time. A decline needs a note they see. A swap that isn't waiting returns invalid_state. shift_swap.approved or shift_swap.declined fires.

Scope: attendance:manage · Plan: Pro and Enterprise in live mode; every plan in test mode.

Authorization

headerAuthorizationBearer <token>

Send Authorization: Bearer <token> on every request. The token is one of:

PrefixWhat it isWhere it may be used
agoo_sk_live_Secret key, live modeYour servers only
agoo_sk_test_Secret key, test modeYour servers only
agoo_pk_live_Publishable key, live modeBrowsers and apps: create pre-registrations and bookings, read public booking types (with their intake questions) and their free slots, read the visit types open for pre-registration with their public forms. Never lists people.
agoo_pk_test_Publishable key, test modeAs above, in test mode

Admins create keys in Console → Developers → API keys and choose each key's scopes. A key is shown once. Never put a secret key in a URL, a browser or a mobile app.

Scope: attendance:manage

Path Parameters

shift_swap_id*string

The shift swap's ID.

Match^shift_swap_[0-7][0-9a-hjkmnp-tv-z]{25}$
Example"shift_swap_01m5rqnybsm3s6ta3zbtb975p6"

Header Parameters

Idempotency-Key*string

A UUID you generate for this operation. If you retry with the same key within 24 hours, Agoo returns the original response instead of acting twice. While the first request is still running, a retry returns conflict. Reusing a key with a different request returns idempotency_key_reused. Responses with rate_limited, internal_error or unavailable aren't stored, so retry those with the same key.

Formatuuid

Request Body

application/json
  1. body
decision*string
Value in"approve""decline"
note?string

Required to decline (3 to 300 characters): they see it.

Lengthlength <= 300

Response Body

The shift swap, decided.

application/json
  1. response

A published shift offered to a colleague (or anyone who can take it), and where it stands.

id*ShiftSwapId

A shift swap ID (TypeID with the shift_swap prefix).

Match^shift_swap_[0-7][0-9a-hjkmnp-tv-z]{25}$
Example"shift_swap_01m5rqnybsm3s6ta3zbtb975p6"
site_id*SiteId

A site ID (TypeID with the site prefix).

Match^site_[0-7][0-9a-hjkmnp-tv-z]{25}$
Example"site_01kjpt3yw0fz0v414608h9x65s"
status*string
Value in"offered""accepted""approved""declined""refused""withdrawn""expired""cancelled"
shift*

A shift on a site's roster. A published shift with a change waiting shows its published values.

return_shift*|

An exchange: the colleague's shift the person offering takes in return.

from_person_id*PersonId

A person ID (TypeID with the person prefix).

Match^person_[0-7][0-9a-hjkmnp-tv-z]{25}$
Example"person_01kjsesxm0e4zbyvkr7bcfxbfg"
to_person_id*|

The colleague it was offered to; null: anyone who can take it.

taker_person_id*|null
note*string|null
decision_note*string|null
approval*|

Where its approval stands; null when it needed none.

created_at*string
Formatdate-time
accepted_at*|
Formatdate-time
decided_at*|
Formatdate-time
updated_at*string
Formatdate-time
curl -X POST 'https://api.agoo.ardent.africa/v1/shift-swaps/shift_swap_01m5rqnybsm3s6ta3zbtb975p6/decide' \  -H 'Idempotency-Key: 3f6b2a1e-8c4d-4f7a-9b2e-5d1c0a7e9f64' \  -H 'Content-Type: application/json' \  -d '{  "decision": "approve"}'
{  "id": "shift_swap_01m5rqnybsm3s6ta3zbtb975p6",  "site_id": "site_01kjpt3yw0fz0v414608h9x65s",  "status": "offered",  "shift": {    "id": "roster_shift_01m5dk4qexa6kwfsr9nhy4r7w5",    "site_id": "site_01kjpt3yw0fz0v414608h9x65s",    "person_id": "person_01kjsesxm0e4zbyvkr7bcfxbfg",    "open": true,    "on_date": "2019-08-24",    "starts_at": "2019-08-24T14:15:22Z",    "ends_at": "2019-08-24T14:15:22Z",    "start_time": "20:00",    "end_time": "08:00",    "shift_id": "shift_01kn6pqfm0fmasbh61jnr3syze",    "name": "Night gate",    "label": "Main gate",    "colour": "blue",    "break_kind": "none",    "break_minutes": 0,    "break_starts": "string",    "note": "string",    "status": "draft",    "pending_change": true,    "removing": true,    "source": "pattern",    "published_at": "2019-08-24T14:15:22Z",    "created_at": "2019-08-24T14:15:22Z",    "updated_at": "2019-08-24T14:15:22Z"  },  "return_shift": {    "id": "roster_shift_01m5dk4qexa6kwfsr9nhy4r7w5",    "site_id": "site_01kjpt3yw0fz0v414608h9x65s",    "person_id": "person_01kjsesxm0e4zbyvkr7bcfxbfg",    "open": true,    "on_date": "2019-08-24",    "starts_at": "2019-08-24T14:15:22Z",    "ends_at": "2019-08-24T14:15:22Z",    "start_time": "20:00",    "end_time": "08:00",    "shift_id": "shift_01kn6pqfm0fmasbh61jnr3syze",    "name": "Night gate",    "label": "Main gate",    "colour": "blue",    "break_kind": "none",    "break_minutes": 0,    "break_starts": "string",    "note": "string",    "status": "draft",    "pending_change": true,    "removing": true,    "source": "pattern",    "published_at": "2019-08-24T14:15:22Z",    "created_at": "2019-08-24T14:15:22Z",    "updated_at": "2019-08-24T14:15:22Z"  },  "from_person_id": "person_01kjsesxm0e4zbyvkr7bcfxbfg",  "to_person_id": "person_01kjsesxm0e4zbyvkr7bcfxbfg",  "taker_person_id": "person_01kjsesxm0e4zbyvkr7bcfxbfg",  "note": "string",  "decision_note": "string",  "approval": {    "status": "pending",    "step": 0,    "of": 0  },  "created_at": "2019-08-24T14:15:22Z",  "accepted_at": "2019-08-24T14:15:22Z",  "decided_at": "2019-08-24T14:15:22Z",  "updated_at": "2019-08-24T14:15:22Z"}