CostCrunchGet an API key

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.

ExceptionMeans
AuthErrorNo key or sign-in found, or signing in failed
PermissionDeniedThe key or session was refused (revoked, wrong company, read-only)
NotFoundNo such document, supplier, project, or material in your company
ApiErrorAny other error from CostCrunch
UsageErrorA 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]