Errors
Every error the SDK throws means the protected action did not run. All of them extend AithorizedError, which has a code and, when a request was created, a requestId. Their messages are written to be handed back to the model as-is.
| Class | code | When | Extra fields |
|---|---|---|---|
AithorizedRejectedError | REJECTED | A human rejected it. | feedback: what the reviewer wrote, for the agent to act on. |
AithorizedExpiredError | EXPIRED | Nobody decided before the time limit. | |
AithorizedDeniedError | DENIED | A DENY rule matched (locally, before any request). | ruleId |
AithorizedKillSwitchError | KILL_SWITCH_ACTIVE | The kill switch is on for this workspace, agent or session. | |
AithorizedCircuitBrokenError | CIRCUIT_BROKEN | The agent is frozen by the circuit breaker; a human must unfreeze it. | |
AithorizedSuspendedError | TENANT_SUSPENDED | The workspace is suspended by the service. | |
AithorizedVerificationError | VERIFICATION_FAILED | The signed decision did not check out (signature, key directory, hashes, approver count or an edit outside the allowed fields). | check: which check failed. |
AithorizedHttpError | the API's code | Any other API error, after retries. | status, errorBody |
ts
import { AithorizedRejectedError, AithorizedError } from '@aithorized/sdk';
try {
await refund({ charge: 'ch_1', amount: 45000 });
} catch (err) {
if (err instanceof AithorizedRejectedError) return `Refund refused: ${err.feedback}`;
if (err instanceof AithorizedError) return err.message; // fixed, model-readable text
throw err;
}Retries
Creating a request is retried a few times on network errors and 5xx, always with the same idempotency key, so a retry never creates a second request. isRetryableCreateError(err) tells you whether an error belongs to that class.