HTTP status codes and error handling for the Precium API.
Returned for successful GET requests and updates.
JSON
{
"id": "8f4a6b0f-fa9b-4f45-8e19-b75c1a70432a",
"status": "COMPLETED",
...
}
Returned when a resource is successfully created.
JSON
{
"id": "new-resource-id",
"status": "PENDING",
...
}
Returned when a resource is successfully deleted. No response body.
Invalid request data. Check required fields and formats.
JSON
{
"value": {
"Message": "Validation error: field 'accountNumber' is required"
},
"statusCode": 400
}
Common causes:
Invalid or expired access token.
JSON
{
"message": "Unauthorized"
}
Resolution: Request a new access token.
Insufficient permissions for the requested operation.
JSON
{
"message": "Forbidden"
}
Resolution: Contact Precium support to verify account permissions.
Requested resource does not exist.
JSON
{
"message": "Resource not found"
}
Common causes:
Resource conflict, typically duplicate data.
JSON
{
"message": "Duplicate external reference"
}
Common causes:
externalReferencecontractReference
Server-side error.
JSON
{
"message": "Internal server error"
}
Resolution: Contact Precium support with request details.
When a collection returns UNPAID, additional information may include:
When verifyAccount: true fails:
JSON
{
"value": {
"Message": "Debtor account verification failure: details={\"AccountExists\":true,\"AccountIsOpen\":false,\"AccountTypeMatches\":null,\"IdNumberMatches\":null,\"AccountAcceptsDebits\":null}"
},
"statusCode": 400
}
JSX
async function apiRequest(options, maxRetries = 3) {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
const response = await fetch(options.url, options);
if (response.status === 401) {
// Refresh token and retry
await refreshToken();
continue;
}
if (response.status >= 500) {
// Server error - wait and retry
await sleep(attempt * 1000);
continue;
}
return response;
} catch (error) {
if (attempt === maxRetries) throw error;
await sleep(attempt * 1000);
}
}
}
Log all API responses for debugging:
JSX
console.log({
timestamp: new Date().toISOString(),
endpoint: response.url,
status: response.status,
requestId: response.headers.get('x-request-id'),
body: await response.json()
});
Map API errors to user-friendly messages:
JSX
const errorMessages = {
400: 'Invalid request data. Please check your input.',
401: 'Session expired. Please log in again.',
403: 'You do not have permission for this action.',
404: 'The requested resource was not found.',
409: 'This reference already exists.',
500: 'An unexpected error occurred. Please try again later.'
};
If you encounter a 500 status code or persistent errors:
x-request-id in response headers
Email: support@precium.com