Errors
The exceptions the package raises and what to do about them.
Updated October 31, 2026
Every error the package raises on purpose is a costcrunch.CostCrunchError.
| Exception | Means |
|---|---|
AuthError | No key or sign-in found, or signing in failed |
PermissionDenied | The key or session was refused (revoked, wrong company, read-only) |
NotFound | No such document, supplier, project, or material in your company |
ApiError | Any other error from CostCrunch |
UsageError | A bad argument, caught before anything is sent (for example an unknown status) |
ApiError, NotFound, and PermissionDenied carry .status (the HTTP status), .code (for example API_KEY_INVALID), and .message.
from costcrunch import CostCrunch, NotFound, ApiError
cc = CostCrunch()
try:
doc = cc.documents.get("not-a-real-id")
except NotFound:
print("no such document")
except ApiError as e:
print(e.status, e.code, e.message)
Temporary server errors on reads are retried automatically, up to three times.
Didn't answer your question?
Email [email protected]