Skip to main content

Errors

All Urblock API errors follow a consistent format. Error responses include a type, a machine-readable code, a human-readable message, and the HTTP status.

Error Response Format

{
"error": {
"type": "invalid_request_error",
"code": "token_not_found",
"message": "No token found with id tok_xyz.",
"param": "token_id",
"status": 404
}
}
FieldTypeDescription
typestringError category (see Error Types)
codestringMachine-readable error code
messagestringHuman-readable explanation
paramstring | nullThe parameter that caused the error (if applicable)
statusnumberHTTP status code

Error Types

TypeHTTP StatusWhen
invalid_request_error400, 404, 409, 422Invalid parameters, missing fields, resource not found, conflicts
authentication_error401Missing, invalid, or expired API key / JWT
authorization_error403Insufficient permissions or wrong key type
rate_limit_error429Too many requests
api_error500Internal server error (transient — safe to retry)

Common Error Codes

Authentication & Authorization

CodeTypeStatusDescription
invalid_api_keyauthentication_error401API key is invalid or revoked
secret_key_requiredauthorization_error403Write operation requires sk_ key
token_expiredauthentication_error401JWT access token has expired
invalid_refresh_tokenauthentication_error401Refresh token is invalid or revoked
scope_insufficientauthorization_error403API key lacks the required scope

Validation

CodeTypeStatusDescription
validation_errorinvalid_request_error400Request body or query params failed validation
invalid_addressinvalid_request_error400Not a valid Ethereum address
invalid_amountinvalid_request_error400Amount must be a positive numeric string
invalid_networkinvalid_request_error400Unsupported network slug

Resource Not Found

CodeTypeStatusDescription
token_not_foundinvalid_request_error404Token ID does not exist
wallet_not_foundinvalid_request_error404Wallet ID does not exist
transaction_not_foundinvalid_request_error404Transaction ID does not exist
vesting_not_foundinvalid_request_error404Vesting schedule not found
vault_not_foundinvalid_request_error404Vault not found
governance_not_foundinvalid_request_error404Governance instance not found

Conflicts & Business Logic

CodeTypeStatusDescription
duplicate_idempotency_keyinvalid_request_error409Idempotency key reused with different params
token_not_deployedinvalid_request_error409Token not yet deployed
already_frozeninvalid_request_error409Address is already frozen
insufficient_balanceinvalid_request_error422Sender has insufficient balance

Rate Limiting

CodeTypeStatusDescription
rate_limit_exceededrate_limit_error429Too many requests — check Retry-After header

SDK Error Handling

try {
const token = await urblock.tokens.get("tok_nonexistent");
} catch (err) {
if (err.type === "invalid_request_error") {
console.log(`Not found: ${err.message}`);
// → "Not found: No token found with id tok_nonexistent."
} else if (err.type === "rate_limit_error") {
const retryAfter = err.headers?.["retry-after"];
console.log(`Rate limited — retry in ${retryAfter}s`);
} else {
throw err; // Unexpected error
}
}

Retry Logic

async function withRetry<T>(fn: () => Promise<T>, maxRetries = 3): Promise<T> {
for (let attempt = 0; attempt < maxRetries; attempt++) {
try {
return await fn();
} catch (err: any) {
if (err.status === 429) {
const delay = parseInt(err.headers?.["retry-after"] ?? "5") * 1000;
await new Promise(r => setTimeout(r, delay));
continue;
}
if (err.status >= 500) {
await new Promise(r => setTimeout(r, 2 ** attempt * 1000));
continue;
}
throw err; // 4xx errors are not retryable
}
}
throw new Error("Max retries exceeded");
}

// Usage
const token = await withRetry(() => urblock.tokens.get("tok_abc123"));

HTTP Status Code Summary

StatusMeaningRetryable?
200Success
201Created
400Bad RequestNo — fix the request
401UnauthorizedNo — check API key
403ForbiddenNo — check permissions
404Not FoundNo — resource doesn't exist
409ConflictNo — check idempotency key or state
422UnprocessableNo — business logic error
429Rate LimitedYes — wait for Retry-After
500Internal ErrorYes — exponential backoff

Next Steps