Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.b402.ai/llms.txt

Use this file to discover all available pages before exploring further.

b402 APIs return structured error responses with machine-readable codes, human-readable messages, and documentation links.

Error Response Format

{
  "error": {
    "code": "signature_error",
    "message": "Invalid signature",
    "doc_url": "https://b402.ai#signature_error",
    "details": []
  }
}
FieldTypeDescription
codestringMachine-readable error code
messagestringHuman-readable explanation
doc_urlstringLink to documentation for this error
detailsarrayAdditional context (validation errors, etc.)

HTTP Error Codes

General Errors

CodeHTTP StatusDescriptionSolution
bad_request400Malformed request, missing fields, wrong typesCheck request format against the API reference
unauthorized401Missing or invalid authenticationAdd x-admin-api-key header for admin endpoints
forbidden403Valid auth but insufficient permissionsCheck your API key permissions
not_found404Resource not foundVerify the endpoint path and resource ID
unprocessable_entity422Invalid input data (Zod validation failure)Check details array for specific field errors
rate_limit_exceeded429Too many requests (30 per minute per IP)Wait and retry. Contact support for higher limits
internal_server_error500Unexpected server errorRetry later. If persistent, contact support

Payment Errors

CodeHTTP StatusDescriptionCommon Cause
validation_error400Request validation failedMissing required fields, invalid addresses, bad JSON
signature_error400EIP-712 signature invalidWrong signer, corrupted signature, wrong chain ID
nonce_error400Nonce already usedGenerate a new random bytes32 nonce
payment_verification_error400Payment payload invalidExpired time window, authorization not yet valid
payment_error400Payment-specific issueWrong fee amount, invalid recipient
payment_settlement_error500On-chain settlement failedInsufficient balance, reverted transaction
token_error400Token-related issueUnsupported token, insufficient balance/allowance

Blockchain Errors

CodeHTTP StatusDescriptionCommon Cause
blockchain_error500On-chain operation failedTransaction reverted, network congestion
configuration_error500Server misconfigurationMissing env vars, invalid network config

Smart Wallet Errors

CodeHTTP StatusDescriptionCommon Cause
wallet_error400Wallet operation failedWallet not deployed, already deployed, already paid
userop_error500UserOperation failedBundler rejection, gas estimation failure, paymaster error

Specific Error Messages

Signature & Nonce

ErrorMessage
ERR_INVALID_SIGNATUREInvalid signature
ERR_SIGNATURE_VERIFICATION_FAILEDSignature verification failed
ERR_NONCE_ALREADY_USEDNonce already used
ERR_AUTHORIZATION_NOT_VALID_YETAuthorization not yet valid
ERR_AUTHORIZATION_EXPIREDAuthorization expired

Wallet Deployment

ErrorMessage
ERR_WALLET_NOT_DEPLOYEDWallet not deployed
ERR_WALLET_ALREADY_DEPLOYEDWallet for this address has already been deployed
ERR_WALLET_ALREADY_PAIDPayment already exists for this wallet address
ERR_MISSING_DEPLOYMENT_PARAMSMissing deployment parameters (ownerAddress and salt required)
ERR_INVALID_WALLET_COUNTWallet count must be between 1 and 10
ERR_INCORRECT_DEPLOYMENT_FEEWrong deployment fee payment
ERR_WALLET_DEPLOYMENT_FAILEDFailed to deploy wallets
ERR_NO_PENDING_DEPLOYMENTSNo pending wallet deployments found for this payment transaction

Token & Balance

ErrorMessage
ERR_UNSUPPORTED_TOKENToken not supported
ERR_INSUFFICIENT_BALANCEInsufficient token balance
ERR_INSUFFICIENT_ALLOWANCEInsufficient token allowance
ERR_TOKEN_INFO_FETCH_FAILEDCould not fetch token information

Transaction Validation

ErrorMessage
ERR_EMPTY_TRANSACTIONSAt least one transaction required
ERR_TOO_MANY_TRANSACTIONSToo many transactions, maximum 20
ERR_MULTIPLE_TOKENS_NOT_ALLOWEDAll transactions must use the same token
ERR_ARRAY_LENGTH_MISMATCHRecipients and amounts arrays must have same length
ERR_INVALID_AMOUNTInvalid amount
ERR_ZERO_ADDRESS_RECIPIENTRecipient cannot be zero address

UserOperation (Smart Wallet)

ErrorMessage
ERR_USEROP_CREATION_FAILEDFailed to create UserOperation
ERR_INVALID_USEROPInvalid UserOperation structure
ERR_BUNDLER_SUBMISSION_FAILEDFailed to submit to bundler
ERR_PAYMASTER_SIGNING_FAILEDFailed to sign as paymaster
ERR_GAS_ESTIMATION_FAILEDGas estimation failed
ERR_NO_RECEIPTNo receipt returned from bundler

Handling Errors

const response = await fetch('https://facilitatorv3.b402.ai/verify', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify(payload),
});

if (!response.ok) {
  const { error } = await response.json();
  switch (error.code) {
    case 'nonce_error':
      // Generate new nonce and retry
      break;
    case 'signature_error':
      // Re-sign the payload
      break;
    case 'rate_limit_exceeded':
      // Wait and retry
      break;
    default:
      console.error(`${error.code}: ${error.message}`);
  }
}