API Reference
Errors
HTTP status codes and error responses
The Partner API uses standard HTTP response codes.
HTTP Status Codes
| Code | Meaning |
|---|---|
200 | Success |
400 | Bad Request — Invalid parameters |
401 | Unauthorized — Invalid or missing API key |
403 | Forbidden — Valid key but access denied |
404 | Not Found — Resource does not exist |
429 | Too Many Requests — Rate limit exceeded |
500 | Internal Server Error |
Error Response Format
{
"statusCode": 401,
"message": "Invalid or revoked API key",
"error": "Unauthorized"
}Common Errors
Invalid API Key
{
"statusCode": 401,
"message": "Invalid or revoked API key",
"error": "Unauthorized"
}Verify the API key is correct and has not been revoked.
Missing Authorization Header
{
"statusCode": 401,
"message": "Missing Authorization header",
"error": "Unauthorized"
}Include Authorization: Bearer <key> in the request.
Invalid UUID Parameter
{
"statusCode": 400,
"message": "Validation failed (uuid is expected)",
"error": "Bad Request"
}Ensure UUID parameters are valid UUIDs.
Resource Not Found
{
"statusCode": 404,
"message": "Receivable not found",
"error": "Not Found"
}Verify the resource ID exists and belongs to your organization.
Error Handling Example
import requests
def get_receivables(api_key):
response = requests.get(
"https://api.kapwork.com/v1/receivables",
headers={"Authorization": f"Bearer {api_key}"}
)
if response.status_code == 200:
return response.json()
elif response.status_code == 401:
raise AuthenticationError("Invalid API key")
elif response.status_code == 429:
raise RateLimitError("Rate limit exceeded")
else:
error = response.json()
raise APIError(f"{error['error']}: {error['message']}")Recommendations
- Check the status code before parsing the response body
- Implement exponential backoff for retrying failed requests
- Log error responses for debugging
- Handle network errors gracefully