Create a shift swap

post/v1/shift-swaps

Creates a shift swap and returns it. Send an Idempotency-Key header to make the request safe to retry. Available to keys belonging to office staff and caregivers. With a caregiver's or patient's key, a saved record that key cannot read back is answered with only object and id. Requires a key with write scope.

Authorization

Authorization: Bearer ak_...requiredscope: read + write

An AveeCare API key created in Settings → API Keys. This endpoint changes data, so the key needs read + write scope. About authentication

Headers

Idempotency-Key
stringmax length 255

A unique value (a UUID works well) that makes this request safe to retry for 24 hours. A retry with the same key and body returns the first result; the same key with a different body is refused with idempotency_conflict.

Request body

application/json
visitId
stringrequiredmax length 64

The visit to hand over.

requestingCaregiverId
string | nullmax length 64

The caregiver giving up the visit. With a caregiver's API key this is always that caregiver (leave it out), and the visit must be assigned to them; office staff must send it.

targetCaregiverId
string | nullmax length 64

The caregiver asked to take the visit.

targetCaregiverName
string | nullmax length 200

Display name of the target caregiver.

reason
string | nullmax length 20000

Why the swap is requested.

status
string | null

Where the swap stands. With a caregiver's key: new swaps are Pending; the asked caregiver changes a Pending swap to Accepted or Declined; the requesting caregiver can change it to Cancelled. AdminApproved and AdminDenied are for office staff.

One ofPendingAcceptedDeclinedCancelledAdminApprovedAdminDeniednull
requestDate
string · date-time | null

When the swap was requested.

Response

201

The new shift swap.

object
stringread-only

String representing the object's type. Always shift_swap.

id
stringread-only

Unique identifier of the shift swap.

visitId
string | nullmax length 64

The visit to hand over.

requestingCaregiverId
string | nullmax length 64

The caregiver giving up the visit. With a caregiver's API key this is always that caregiver (leave it out), and the visit must be assigned to them; office staff must send it.

requestingCaregiverName
string | nullread-onlymax length 2000

Display name of the requesting caregiver, taken from the caregiver's record.

targetCaregiverId
string | nullmax length 64

The caregiver asked to take the visit.

targetCaregiverName
string | nullmax length 200

Display name of the target caregiver.

reason
string | nullmax length 20000

Why the swap is requested.

status
string | null

Where the swap stands. With a caregiver's key: new swaps are Pending; the asked caregiver changes a Pending swap to Accepted or Declined; the requesting caregiver can change it to Cancelled. AdminApproved and AdminDenied are for office staff.

One ofPendingAcceptedDeclinedCancelledAdminApprovedAdminDeniednull
requestDate
string · date-time | null

When the swap was requested.

responseDate
string · date-time | nullread-only

When the target caregiver answered.

adminResponseDate
string · date-time | nullread-only

When the office answered.

createdAt
string · date-time | nullread-only

When the shift swap was created.

updatedAt
string · date-time | nullread-only

When the shift swap was last changed.

Response headers

Request-IdstringUnique ID of this request. Quote it when contacting support.
RateLimit-LimitintegerRequests allowed in the current window.
RateLimit-RemainingintegerRequests left in the current window.
RateLimit-ResetintegerSeconds until the window resets.
Idempotent-ReplayedstringPresent and true when this response is the stored result of an earlier request with the same Idempotency-Key.

Errors

StatusCodeMeaning
400
n/a
The request was malformed, a value was invalid, or it contained an unknown field (invalid_request, unknown_field).
401
n/a
The API key is missing, malformed, expired or revoked (unauthorized).
403
n/a
The key is read-only (insufficient_scope), or its user's role cannot do this (forbidden).
409
n/a
The Idempotency-Key was already used with a different request, or that request is still running (idempotency_conflict).
429
n/a
Too many requests (rate_limited). Wait for Retry-After seconds.
500
n/a
Something went wrong on our side (internal_error). Retry, and quote the request ID if it persists.

Every error uses the same body. See Errors for the full list of codes.