DGuardAPI Docs

Error Codes

All DGuard API errors follow a consistent format with specific error codes per module. Use these codes to handle errors gracefully in your application.

Error Response Format

All error responses include the following structure:

json
{
  "error_code": "FRAUD_001",
  "message": "Transaction not found",
  "details": {
    "transaction_id": "txn_123"
  },
  "timestamp": "2025-01-14T18:00:00Z",
  "request_id": "req_abc123"
}

HTTP Status Codes

CodeMeaning
200Success
201Created
400Bad Request - Invalid parameters
401Unauthorized - Invalid or expired token
403Forbidden - Insufficient permissions
404Not Found
409Conflict - Duplicate resource
422Unprocessable Entity - Validation error
429Too Many Requests - Rate limited
500Internal Server Error
503Service Unavailable
504Gateway Timeout

Authentication Errors (AUTH_)

CodeHTTPDescription
AUTH_001401Invalid credentials
AUTH_002401Token expired
AUTH_003403Insufficient scope
AUTH_004429Too many login attempts

Fraud Detection Errors (FRAUD_)

CodeHTTPDescription
FRAUD_001400Invalid transaction data
FRAUD_002400Too many transactions in batch (max 1,000)
FRAUD_003404Transaction not found
FRAUD_004422Unsupported transaction type
FRAUD_005429Rate limit exceeded
FRAUD_006500ML model error

Refund Errors (REFUND_)

CodeHTTPDescription
REFUND_001400Invalid refund request
REFUND_002404Original transaction not found
REFUND_003404Refund not found
REFUND_004400Missing Idempotency-Key header (required for all refund requests)
REFUND_005409Invalid state transition (e.g., cannot cancel a processing/completed refund)
REFUND_006409Transaction already refunded
REFUND_007422Amount exceeds original transaction
REFUND_008503Payment provider unavailable
REFUND_009422Invalid beneficiary account details

Email Protection Errors (EMAIL_)

CodeHTTPDescription
EMAIL_001400Invalid email content
EMAIL_002400Missing required fields
EMAIL_003404Account not found
EMAIL_004409Account already connected
EMAIL_005401OAuth authorization failed
EMAIL_006429Rate limit exceeded
EMAIL_007500ML analysis error

URL Scanning Errors (URL_)

CodeHTTPDescription
URL_001400Invalid URL format
URL_002400Too many URLs in batch (max 100)
URL_003422URL not accessible
URL_004429Rate limit exceeded
URL_005504Scan timeout

SMS Protection Errors (SMS_)

CodeHTTPDescription
SMS_001400Empty or invalid message
SMS_002400Too many messages in batch (max 100)
SMS_003404Analysis not found
SMS_004422Unsupported platform
SMS_005429Rate limit exceeded
SMS_006500ML analysis error
SMS_007403SMS permissions not granted on device

VPN Service Errors (VPN_)

CodeHTTPDescription
VPN_001429Device limit reached (max 2)
VPN_002503No slots available in pool
VPN_003503Server under maintenance
VPN_004404Server not found
VPN_005404Session not found
VPN_006400Device already connected
VPN_007408Heartbeat timeout
VPN_008500OpenVPN configuration error
VPN_009403VPN permission rejected by user

Dark Web Monitoring Errors (DARKWEB_)

CodeHTTPDescription
DARKWEB_001400Invalid email format
DARKWEB_002404Monitor not found
DARKWEB_003409Email already being monitored
DARKWEB_004429Too many queries
DARKWEB_005503Verification service unavailable

Notification Errors (NOTIF_)

CodeHTTPDescription
NOTIF_001400Invalid push token
NOTIF_002404Device not registered
NOTIF_003404Notification not found
NOTIF_004404User not found
NOTIF_005422Unsupported platform
NOTIF_006422Invalid category
NOTIF_007429Rate limit exceeded
NOTIF_008503Push service unavailable

Webhook Errors (WEBHOOK_)

CodeHTTPDescription
WEBHOOK_001400Invalid webhook URL
WEBHOOK_002401Invalid signature verification
WEBHOOK_003404Webhook not found
WEBHOOK_004422Unsupported event type

General & SDK Errors (GEN_)

CodeHTTPDescription
GEN_001403SDK integration required for this feature
GEN_002403Missing required device permissions

Idempotency Keys

Certain endpoints require an Idempotency-Key header to prevent duplicate operations. This is critical for financial operations like refunds.

PropertyValue
Header NameIdempotency-Key
FormatUUID v4 recommended (e.g., 550e8400-e29b-41d4-a716-446655440000)
Validity Period24 hours from first use
Required EndpointsPOST /refund/request,Webhooks (X-DGuard-Event-ID)
bash
# Example request with Idempotency-Key
curl -X POST https://api.dguard.ai/v1/refund/request \
  -H "Authorization: Bearer {access_token}" \
  -H "Idempotency-Key: 550e8400-e29b-41d4-a716-446655440000" \
  -H "Content-Type: application/json" \
  -d '{"transaction_id": "txn_abc123", ...}'

Important: If you retry a request with the same Idempotency-Key within 24 hours, the API returns the original response instead of creating a duplicate. This ensures safe retries after network failures.

Best Practices

  • Always check the error_code field in error responses for precise error handling.
  • Use the request_id from error responses when contacting support for faster resolution.
  • Implement exponential backoff for 429 (Rate Limited) and 503 (Service Unavailable) errors.
  • Log all error responses with their request_id for debugging and monitoring.
  • Always include Idempotency-Key header for refund requests to enable safe retries.