Crm · Contracts · Collections
Retry contract collection
Retries the failed contracts in a contract collection. It takes an organization ID, a nullable mandate ID, and a contract collection ID. It queues the collection for processing and returns no value.
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,contract.read,contract.edit, andreceipt.insert. - The collection lookup is restricted by the mandate filter and the caller's organization access.
Request
Path parameters
-
organizationIdidrequiredThe organization in which to retry the collection; the retry is rejected if another collection is being processed in the organization.
-
mandateIdidrequiredScopes the contract collection lookup to a mandate.
-
contractCollectionIdidrequiredThe collection to retry; it must have failed contracts.
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/contracts/collections/YOUR_CONTRACT_COLLECTION_ID/retry' \
--header 'X-API-Key: YOUR_API_KEY'const response = await fetch("https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/YOUR_MANDATE_ID/crm/contracts/collections/YOUR_CONTRACT_COLLECTION_ID/retry", {
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/contracts/collections/YOUR_CONTRACT_COLLECTION_ID/retry', 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
No response body is specified.
What else happens
- The collection's
statusis set tocollecting. - The collection's
progressis reset to 0. - The collection's
failedContractCounteris reset to 0. - The collection's
invalidatedAtis set to null. - The
crm.processContractCollectionjob is added toDefaultQueueafter the transaction.
Errors
Other errors
| Status | Error | When |
|---|---|---|
| 400 | A contract collection is already processing for this organization | If a contract collection is already processing for the organization, the endpoint returns BAD_REQUEST 400 with key routes.crm.contractCollections.alreadyProcessing. |
| 400 | A contract collection is already processing for this organization | If the collection cannot be updated for processing, the endpoint returns BAD_REQUEST 400 with key routes.crm.contractCollections.alreadyProcessing. |
| 400 | No failed contracts to retry | If the collection has no failed contracts to retry, the endpoint returns BAD_REQUEST 400 with key routes.crm.contractCollections.noFailedContracts. |
| 404 | Contract collection was not found | If the matching collection is not found, the endpoint returns NOT_FOUND 404 with key routes.crm.contractCollections.noContractCollection. |
Errors nearly every request can meet are listed under Errors.