Error Reference

Understanding API errors and how to handle them.

Error CodeDescriptionHow to Fix
unauthorizedYou are not authenticated or don't have permissionEnsure you're using a valid API key and are signed in
notAuthorizedYour identity does not have admin access for this operationThis action requires admin privileges. Only the canister admin can perform this operation.
userDisabledYour account has been permanently disabledContact hey@vanishd.io to appeal
userFrozenYour account is temporarily frozen for investigationYou can view data but not create new items. Contact hey@vanishd.io
invalidApiKeyThe API key provided is invalid or has been revokedCheck the key is correct. Create a new key if needed
invalidCredentialHashThe credential hash is not valid (must be 32-byte SHA-256)Ensure you're hashing with SHA-256 and sending 32 bytes
invalidMetadataSizeMetadata exceeds the 16KB limitReduce your metadata size to under 16KB
invalidInputA parameter is invalid (message includes details)Check the error message for specifics
usageLimitExceededYou've exceeded your monthly receipt quotaUpgrade your plan or wait for next billing period
rateLimitedToo many requests in a short periodWait a moment and retry. Implement exponential backoff
tierChangeCooldown24-hour cooldown between tier changes not elapsedWait until cooldown expires or contact support
receiptNotFoundThe requested receipt ID doesn't existVerify the receipt ID is correct
batchNotFoundThe Merkle batch doesn't existThe batch may not be anchored yet. Try again later
idempotencyConflictA receipt with this idempotency key already existsThis is expected for duplicate requests. Use the existing receipt
internalErrorAn unexpected error occurredRetry the request. If persistent, contact support

Handling Errors in Code

// Example error handling
const result = await actor.certify(apiKey, request);

if ('err' in result) {
  const error = result.err;
  
  if ('usageLimitExceeded' in error) {
    // Prompt user to upgrade or wait
    showUpgradeModal();
  } else if ('rateLimited' in error) {
    // Implement retry with backoff
    await sleep(2000);
    return retry(request);
  } else if ('userFrozen' in error) {
    // Show account status message
    showFrozenNotice();
  } else if ('invalidApiKey' in error) {
    // API key issue - prompt to create new one
    redirectToApiKeys();
  } else {
    // Handle other errors
    console.error('Unexpected error:', error);
  }
}

if ('ok' in result) {
  // Success - save the receipt
  saveReceipt(result.ok);
}

Best Practices

  • Always check for errors: The API returns Result<T, Error> - handle both cases
  • Implement retry logic: For rateLimited and transient errors, use exponential backoff
  • Monitor usage: Track your receipt count to avoid hitting limits unexpectedly
  • Use idempotency keys: Prevent duplicate receipts when retrying failed requests
  • Log errors: Keep logs for debugging and support requests

Need Help?

If you're encountering errors you can't resolve, reach out for assistance.