KapworkKapwork Partner API
API Reference

Errors

HTTP status codes and error responses

The Partner API uses standard HTTP response codes.

HTTP Status Codes

CodeMeaning
200Success
400Bad Request — Invalid parameters
401Unauthorized — Invalid or missing API key
403Forbidden — Valid key but access denied
404Not Found — Resource does not exist
429Too Many Requests — Rate limit exceeded
500Internal 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

  1. Check the status code before parsing the response body
  2. Implement exponential backoff for retrying failed requests
  3. Log error responses for debugging
  4. Handle network errors gracefully

On this page