Crm · Work hours
Get work hours account
Gets a work hours account by organization, mandate and account ID. The response includes the account, its entries and reviewers, covered contacts, history and notes, buyout deadline, and booking settings.
Permissions
Send an API key of the organization in the path, using the X-API-Key header.
Who may call it
- The caller must have organization access.
- The caller needs
mandate.read. - The caller needs
workHours.read. - With assigned-only work hours access, the caller can get the account only if their user ID is a reviewer on at least one entry.
- The legacy
contact.readpermission also allows contact actor details to be shown.
Request
Path parameters
-
organizationIdidrequired -
mandateIdidrequired -
accountIdidrequired
curl --fail-with-body --silent --show-error --max-time 30 --globoff \
--request GET 'https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/YOUR_MANDATE_ID/crm/work-hours/accounts/YOUR_ACCOUNT_ID' \
--header 'X-API-Key: YOUR_API_KEY'const response = await fetch("https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/YOUR_MANDATE_ID/crm/work-hours/accounts/YOUR_ACCOUNT_ID", {
method: "GET",
headers: {
"X-API-Key": "YOUR_API_KEY"
},
redirect: 'error',
signal: AbortSignal.timeout(30_000),
});
if (!response.ok) throw new Error(`campai HTTP ${response.status}`);
const text = await response.text();
const result = text ? JSON.parse(text) : null;
console.log(JSON.stringify(result, null, 2));<?php
$context = stream_context_create(['http' => [
'method' => 'GET',
'header' => [
'X-API-Key: YOUR_API_KEY',
],
'timeout' => 30,
'follow_location' => 0,
'ignore_errors' => true,
]]);
$text = @file_get_contents('https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/YOUR_MANDATE_ID/crm/work-hours/accounts/YOUR_ACCOUNT_ID', false, $context);
preg_match('/^HTTP\/\S+ (\d{3})/', $http_response_header[0] ?? '', $match);
$status = (int) ($match[1] ?? 0);
if ($text === false || $status < 200 || $status >= 300) {
throw new RuntimeException("campai HTTP $status (0 means no response)");
}
$result = $text === '' ? null : json_decode($text, true, 512, JSON_THROW_ON_ERROR);
echo json_encode($result, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR), PHP_EOL;
Response
200 Successful response
Content-Type: application/json
-
accountobject34 properties
-
_idid -
createdAtstring · date-timenullable -
updatedAtstring · date-timenullable -
removedAtstring · date-timenullable -
createdByobjectnullableWithout
user.read, user actors such asaccount.createdByare masked, except for the caller's own actor.Without
apiKey.read, API actors such asaccount.createdByare masked, including the caller's own API actor. -
updatedByobjectnullable -
removedByobjectnullable -
__ignoreTriggersstringnullable -
organizationid -
mandatesid[] -
mandateScopestringselectedall -
ruleobject15 properties
-
_idid -
labelstring1–60 characters
-
unitstringhoursshifts -
requirednumber0–999
-
holderstringcontactgroup -
helpersstringmembersanyone -
proRatastringnonemonths -
feeintegernullableat most 999999
-
buyoutobjectnullable2 properties
-
amountintegerat most 9999999
-
untilDaysinteger0–365
-
-
accountintegernullable1–999999999
-
costCenter1numbernullable1–99999999
-
costCenter2numbernullable1–99999999
-
eventCategoriesobject[]at most 10 items
3 properties
-
namestring1–60 characters
-
nameNormalizedstring1–60 characters
-
bookingCategoryIdid
-
-
legalBasisstringat most 300 characters
-
decidedAtstringnullable
-
-
periodobject3 properties
-
yearinteger2000–2999
-
fromstring -
tostring
-
-
deadlineAtstring -
reminderSentForDeadlinestringnullable -
groupobjectnullable3 properties
-
_idid -
namestringat most 40 characters
-
numberstringat most 24 characters
-
-
contactsid[]at most 100 items
-
monthsinteger0–12
-
calculatedRequirednumber0–999
-
overrideobjectnullable2 properties
-
requirednumber0–999
-
reasonstring2–200 characters
-
-
requirednumber0–999
-
approvednumberat least 0
-
submittednumberat least 0
-
missingnumberat least 0
-
reviewerUserIdsstring[]at most 100 items · each at least 1 characters
-
statusstringopensettled -
buyoutobjectnullable2 properties
-
atstring · date-time -
byobject
-
-
settlementobjectnullable6 properties
-
atstring · date-time -
byobject -
missingnumber0–999
-
amountinteger0–9999999999
-
buyoutboolean -
receiptobjectnullable3 properties
-
_idid -
receiptNumberstringat most 30 characters
-
mandateid
-
-
-
changesobject[]at most 1000 items
-
notesobject[]6 properties
-
idstringexactly 6 characters
-
contentstringat most 4000 characters
-
writtenAtstring · date-time -
writtenByobject -
updatedAtstring · date-time -
updatedByobject
-
-
contactobjectnullable -
payerobjectnullable -
contactActorsobject[] -
buyoutDeadlinestringnullableaccount.buyoutDeadlineis null when the account's rule has no buyout.
-
-
bookingobjectnullablebookingis null when work hours settings are unavailable.3 properties
-
defaultMandateidnullable -
sepaDirectDebitCashAccountidnullable -
sepaCreditTransferCashAccountidnullable
-
-
entriesobject[]30 properties
-
_idid -
createdAtstring · date-timenullable -
updatedAtstring · date-timenullable -
removedAtstring · date-timenullable -
createdByobjectnullable -
updatedByobjectnullable -
removedByobjectnullable -
__ignoreTriggersstringnullable -
organizationid -
mandatesid[] -
mandateScopestringselectedall -
accountid -
ruleid -
periodobject3 properties
-
yearinteger2000–2999
-
fromstring -
tostring
-
-
unitstringhoursshifts -
datestring -
activitystring2–100 characters
-
quantitynumber0.25–99
-
statusstringdraftsubmittedapproved -
submittedAtstring · date-timenullable -
submittedByobjectnullable -
submittedOnBehalfboolean -
reviewsobject[]at most 100 items
4 properties
-
atstring · date-time -
byobject -
decisionstringsubmittedreturnedapprovedrevoked -
messagestringnullableat most 2000 characters
-
-
changesobject[]at most 100 items
4 properties
-
atstring · date-time -
byobject -
previousQuantitynumberat least 0
-
quantitynumberat least 0
-
-
reviewerUserIdsstring[]at most 100 items · each at least 1 characters
-
approvedAtstring · date-timenullable -
approvedByobjectnullable -
eventobjectnullable3 properties
-
_idid -
namestringat most 200 characters
-
attendeeid
-
-
helperobject -
reviewersobject[]Without
user.read,entries[].reviewerscan include only the caller's own reviewer actor.
-
More about the fields
account.contactActors[].user: Withoutuser.read, the name is masked and the image is null for another user's nested actor inaccount.contactActors[].user.
{
"account": {
"_id": "000000000000000000000001",
"organization": "000000000000000000000001",
"mandates": [
"000000000000000000000001"
],
"rule": {
"_id": "000000000000000000000001",
"label": "string",
"unit": "hours",
"required": 0,
"holder": "contact",
"helpers": "members",
"proRata": "none",
"fee": 1,
"buyout": {
"amount": 1,
"untilDays": 0
},
"account": 1,
"costCenter1": 1,
"costCenter2": 1,
"eventCategories": [
{
"name": "string",
"nameNormalized": "string",
"bookingCategoryId": "000000000000000000000001"
}
],
"legalBasis": "string",
"decidedAt": "string"
},
"period": {
"year": 2000,
"from": "string",
"to": "string"
},
"deadlineAt": "string",
"reminderSentForDeadline": "string",
"group": {
"_id": "000000000000000000000001",
"name": "string",
"number": "string"
},
"contacts": [
"000000000000000000000001"
],
"months": 0,
"calculatedRequired": 0,
"override": {
"required": 0,
"reason": "string"
},
"required": 0,
"approved": 0,
"submitted": 0,
"missing": 0,
"reviewerUserIds": [
"string"
],
"status": "open",
"buyout": {
"at": "2026-06-15T22:30:00Z",
"by": {
"name": "string",
"type": "user",
"userId": "string",
"image": {
"resource": "string"
}
}
},
"settlement": {
"at": "2026-06-15T22:30:00Z",
"by": {
"name": "string",
"type": "user",
"userId": "string",
"image": {
"resource": "string"
}
},
"missing": 0,
"amount": 0,
"buyout": true,
"receipt": {
"_id": "000000000000000000000001",
"receiptNumber": "string",
"mandate": "000000000000000000000001"
}
},
"changes": [
{
"at": "2026-06-15T22:30:00Z",
"by": {
"name": "string",
"type": "user",
"userId": "string",
"image": {
"resource": "string"
}
},
"type": "required",
"previousRequired": 0,
"required": 0,
"reason": "string"
}
],
"notes": [
{
"id": "string",
"content": "string",
"writtenAt": "2026-06-15T22:30:00Z",
"writtenBy": {
"name": "string",
"type": "user",
"userId": "string",
"image": {
"resource": "string"
}
}
}
],
"contact": {
"name": "string",
"type": "user",
"userId": "string",
"image": {
"resource": "string"
}
},
"payer": {
"name": "string",
"type": "user",
"userId": "string",
"image": {
"resource": "string"
}
},
"contactActors": [
{
"name": "string",
"type": "user",
"userId": "string",
"image": {
"resource": "string"
}
}
],
"buyoutDeadline": "string"
},
"booking": {
"defaultMandate": "000000000000000000000001",
"sepaDirectDebitCashAccount": "000000000000000000000001",
"sepaCreditTransferCashAccount": "000000000000000000000001"
},
"entries": [
{
"_id": "000000000000000000000001",
"organization": "000000000000000000000001",
"mandates": [
"000000000000000000000001"
],
"account": "000000000000000000000001",
"rule": "000000000000000000000001",
"period": {
"year": 2000,
"from": "string",
"to": "string"
},
"unit": "hours",
"date": "string",
"activity": "string",
"quantity": 0.25,
"status": "draft",
"submittedAt": "2026-06-15T22:30:00Z",
"submittedBy": {
"name": "string",
"type": "user",
"userId": "string",
"image": {
"resource": "string"
}
},
"submittedOnBehalf": true,
"reviews": [
{
"at": "2026-06-15T22:30:00Z",
"by": {
"name": "string",
"type": "user",
"userId": "string",
"image": {
"resource": "string"
}
},
"decision": "submitted",
"message": "string"
}
],
"changes": [
{
"at": "2026-06-15T22:30:00Z",
"by": {
"name": "string",
"type": "user",
"userId": "string",
"image": {
"resource": "string"
}
},
"previousQuantity": 0,
"quantity": 0
}
],
"reviewerUserIds": [
"string"
],
"approvedAt": "2026-06-15T22:30:00Z",
"approvedBy": {
"name": "string",
"type": "user",
"userId": "string",
"image": {
"resource": "string"
}
},
"event": {
"_id": "000000000000000000000001",
"name": "string",
"attendee": "000000000000000000000001"
},
"helper": {
"name": "string",
"type": "user",
"userId": "string",
"image": {
"resource": "string"
}
},
"reviewers": [
{
"name": "string",
"type": "user",
"userId": "string",
"image": {
"resource": "string"
}
}
]
}
]
}
Errors
Other errors
| Status | Error | When |
|---|---|---|
| 404 | Work hours account not found. | If the account is not found for the requested organization and mandate, the endpoint returns HTTP 404 with workHours.errors.accountNotFound. |
| 404 | Work hours account not found. | With assigned-only work hours access, if the caller is not a reviewer on any entry, the endpoint returns HTTP 404 with workHours.errors.accountNotFound. |
Errors nearly every request can meet are listed under Errors.