Donation · Donations
List donation candidates
Lists incoming cash transactions in the inclusive fromDate–toDate range for the specified organization and mandate that can be recorded as donations. Candidates include open transactions and transactions with a qualifying uncommitted posting. Returns up to 200 candidates, newest first, and hasMore indicates whether more were found.
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
donation.insert. - The caller needs
cashTransaction.read.
Request
Path parameters
-
organizationIdidrequired -
mandateIdidrequired
Body
Content-Type: application/json
-
fromDatestringrequired -
toDatestringrequired
curl --fail-with-body --silent --show-error --max-time 30 --globoff \
--request POST 'https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/YOUR_MANDATE_ID/donation/donations/candidates' \
--header 'X-API-Key: YOUR_API_KEY'const response = await fetch("https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/YOUR_MANDATE_ID/donation/donations/candidates", {
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/donation/donations/candidates', 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
-
candidatesobject[]9 properties
-
cashTransactionIdid -
cashAccountIdid -
datestring -
amountnumber -
partialboolean -
counterpartNamestring -
purposestring -
postingobjectnullablecandidates[].postingis null for unassigned and partially assigned transactions.3 properties
-
postingIdid -
accountinteger1–999999999
-
receiptNumberstring
-
-
debtorobjectnullablecandidates[].debtoris null when no debtor matches the transaction's counterpart account.2 properties
-
accountinteger1–999999999
-
namestring
-
-
-
hasMoreboolean
{
"candidates": [
{
"cashTransactionId": "000000000000000000000001",
"cashAccountId": "000000000000000000000001",
"date": "string",
"amount": 1,
"partial": true,
"counterpartName": "string",
"purpose": "string",
"posting": {
"postingId": "000000000000000000000001",
"account": 1,
"receiptNumber": "string"
},
"debtor": {
"account": 1,
"name": "string"
}
}
],
"hasMore": true
}
Errors
Other errors
| Status | Error | When |
|---|---|---|
| 404 | A mandate needs to be provided | If mandateId is a null object ID, the endpoint returns HTTP 404 with key organization.getMandate.nullMandateId. |
| 404 | Mandate mandate ID not found | If the mandate is not found in the organization, the endpoint returns HTTP 404 with key organization.getMandate.notFound. |
Marked words such as mandate ID are filled in with the actual value when the error happens.
Errors nearly every request can meet are listed under Errors.