- Problems with authentication — bad credentials, a revoked agent, an unreachable MudraID. These the SDK raises as exceptions.
- Responses from the platform you called — a
404, a409, a500from the API itself. These come back as normal responses for your code to handle.
Catch the base class for anything SDK-originated
Every exception the SDK raises inherits fromMudraIDError. Catch the base class to handle all of them in one place:
Catch a subclass when you want to react specifically
| Exception | Raised when | Typical response |
|---|---|---|
MudraIDConfigError | MUDRAID_API_KEY_ID or MUDRAID_SECRET is missing or empty | Fail fast at startup — it’s a misconfiguration |
MudraIDAuthError | MudraID rejected the credentials (401) | Alert; the credentials are wrong or stale |
MudraIDRevokedError | Access denied (403): agent inactive, no platform access, or scope rejected | Stop retrying; the agent needs attention in the portal |
MudraIDNetworkError | MudraID was unreachable or returned something malformed | Retry with backoff — it may be transient |
MudraIDPlatformNotRegisteredError | The URL’s host isn’t a platform this agent is registered with | Fix the target, or register the platform |
Platform responses are not exceptions
A4xx or 5xx from the platform itself is returned to you as an ordinary requests.Response. The SDK does not raise it — your code decides what a 404 or a 409 means for your application.
401 from the platform: the SDK assumes the token expired, refreshes it, and retries once before handing the response back. So you rarely see a 401 at all.

