Crm · Compensation
Add compensation claim
Creates a draft compensation claim for a contributor and the compensation period containing the supplied date. It takes an organization, a mandate, a contact and a date, and returns claimId. The claim follows the contact’s mandates, and a notification is sent for the period opening.
Permissions
Send an API key of the organization in the path, using the X-API-Key header.
Who may call it
- Organization access with
mandate.readandcompensationClaim.insertis required. - The contact must be visible under the caller’s mandate access.
Request
Path parameters
-
organizationIdidrequired -
mandateIdidrequired
Body
Content-Type: application/json
-
contactIdidrequired -
datestringrequired
Request
curl --fail-with-body --silent --show-error --max-time 30 --globoff \
--request POST 'https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/YOUR_MANDATE_ID/crm/compensation/claims' \
--header 'X-API-Key: YOUR_API_KEY'const response = await fetch("https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/YOUR_MANDATE_ID/crm/compensation/claims", {
method: "POST",
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' => 'POST',
'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/compensation/claims', 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;
No request that worked has been recorded yet, so the body is not shown.
Response
200 Successful response
Content-Type: application/json
-
claimIdid
Response200
{
"claimId": "000000000000000000000001"
}
What else happens
- Creates a draft compensation claim.
- Advances the claim’s yearly sequence number.
- Sends a period-opening notification for the claim.
- Notification delivery can create a delivery batch.
- Notification delivery can update an existing delivery batch.
- Notification delivery can remove earlier delivery items for the same source.
- Notification delivery can create delivery items.
- Preparing a notification email creates an email notification log.
- Notification delivery can create or update a read receipt.
- A replacement notification can remove matching earlier notifications.
- Notification processing can create a notification record.
- Notification processing can create or update a user watch counter.
- Notification delivery can enqueue a
common.processNotificationDeliveryjob onDefaultQueue.
Errors
Caused by the organization's data
| Status | Error | When |
|---|---|---|
| 400 | This asset does not belong to this design owner. | If the notification email is being prepared and the default action email template contains an asset that does not belong to that template. |
| 400 | Invalid email headers | If the notification email subject contains a line break, or its sender name is missing or contains a line break. |
Other errors
| Status | Error | When |
|---|---|---|
| 400 | No claim can be created for this contact and period. | If the contact is not found or is not visible under the mandate filter, the endpoint returns 400 with compensation.errors.notEligible. |
| 400 | No claim can be created for this contact and period. | If the contact is not a contributor or is not eligible for the period, the endpoint returns 400 with compensation.errors.notEligible. |
| 400 | No claim can be created for this contact and period. | If the contact has no mandates, the endpoint returns 400 with compensation.errors.notEligible. |
| 400 | Notification key is required when replace is true | If a replacement notification has no key, the endpoint returns 400 with dispatch.notification.createNotification.keyRequiredForReplace. |
| 400 | Global notifications only support root target | If a global notification has no root target, the endpoint returns 400 with dispatch.notification.createNotification.globalNotificationsOnlyRoot. |
| 400 | Root notifications must be global | If an organization notification has a root target, the endpoint returns 400 with dispatch.notification.createNotification.rootNotificationsMustBeGlobal. |
| 400 | Exactly one of user or contact is required | If a notification specifies both a user and a contact, the endpoint returns 400 with dispatch.notification.createNotification.exactlyOneRecipientRequired. |
| 400 | Exactly one of user or contact is required | If a notification specifies neither a user nor a contact, the endpoint returns 400 with dispatch.notification.createNotification.exactlyOneRecipientRequired. |
| 400 | Organization is required when contact is provided | If a contact notification has no organization, the endpoint returns 400 with dispatch.notification.createNotification.organizationRequiredForContact. |
| 400 | Notification message or details is required | If a notification has no usable message or details, the endpoint returns 400 with dispatch.notification.createNotification.messageOrDetailsRequired. |
| 400 | Community-App notification links require an organization | If a Community-App notification link requires an organization but its ID or short ID is missing, the endpoint returns 400 with dispatch.notification.createNotification.connectLinkRequiresOrganization. |
| 400 | The email sender name is invalid. | If the organization’s email sender name is missing or contains a line break, the endpoint returns 400 with emailSender.invalidName. |
| 404 | Compensation claims are not set up for this organization. | If compensation claims are not set up, the endpoint returns 404 with compensation.errors.notEnabled. |
| 404 | This contact has no compensation profile. | If the contributor’s compensation profile is not active, the endpoint returns 404 with compensation.errors.profileNotFound. |
| 404 | Notification contact not found | If the notification contact cannot be found in the organization, the endpoint returns 404 with dispatch.notification.createNotification.contactNotFound. |
| 404 | The organization has no default template for this transactional type | If the organization has no default action email template, the endpoint returns 404 with templates.transactional.noDefault. |
| 409 | A claim for this contact and period already exists. | If a claim already overlaps the contact’s period, the endpoint returns 409 with compensation.errors.claimExists. |
| 412 | Email sender settings must be transferred before sending from this organization. | If the organization’s email sender settings are not initialized, the endpoint returns 412 with emailSender.notInitialized. |
2 rare errors, such as when something changes at the same moment
| Status | Error | When |
|---|---|---|
| 404 | Organization was not found | If the organization can no longer be found. |
| 408 | Cache loading timed out | If loading information needed for the notification email takes too long. |
Errors nearly every request can meet are listed under Errors.