Error Codes

Error Codes

📋

Use appropriate HTTP status codes to communicate the outcome of requests from YGG Redeem.

💡

errorCode are optional, but recommended to use for error handling. It's very useful for debugging and error tracking.

HTTP Status Codes

Your API should return these standard HTTP status codes:

Status CodeMeaningWhen to UseResponse Signature Required
200 OKSuccessAlways use this for successful responsesYES - Must include X-API-SIGNATURE
400 Bad RequestInvalid requestInvalid request body or query parameters❌ No signature needed
401 UnauthorizedAuthentication failedMissing or invalid X-API-KEY or X-API-SIGNATURE❌ No signature needed
404 Not FoundResource not foundUser address doesn't exist in your system❌ No signature needed
409 ConflictConflictRequest already processed❌ No signature needed
422 Unprocessable EntityUnprocessable EntityBusiness logic failure❌ No signature needed
429 Too Many RequestsRate limitedToo many requests in a given time period❌ No signature needed
500 Internal Server ErrorServer errorUnexpected server error on your side❌ No signature needed
⚠️

Important: Use success: true | false for all JSON responses (including 200 OK, 4XX and 5XX) to indicate the actual result.

🔑

Critical: For 200 OK responses, you MUST generate X-API-SIGNATURE and include it in response headers. For all other HTTP status codes, no signature is required.

Response Format

Success Response Structure

{
  "success": true,
  // ... additional required fields per endpoint
}

Error Response Structure

{
  "success": false,
  "errorCode": "ERR-INSUFFICIENT-POINTS",
  "errorMessage": "User does not have enough points for this redemption"
}

Common Error Codes

Authentication Errors

Error CodeHTTP StatusDescriptionSolution
ERR-AUTH-FAILED401Invalid or missing API keyCheck X-API-KEY header
ERR-INVALID-SIGNATURE401HMAC signature mismatchVerify signature generation
ERR-MISSING-HEADERS401Required headers missingInclude all auth headers
ERR-EXPIRED-REQUEST401Request timestamp too oldCheck UUIDv7 timestamp

User & Address Errors

Error CodeHTTP StatusDescriptionSolution
ERR-USER-NOT-FOUND404Wallet address not foundUser needs to register first
ERR-INVALID-ADDRESS400Malformed wallet addressValidate address format
ERR-ADDRESS-MISMATCH400Address doesn't match recordsVerify user identity

Points & Balance Errors

Error CodeHTTP StatusDescriptionSolution
ERR-INSUFFICIENT-POINTS422Not enough points to deductUser needs more points
ERR-INVALID-AMOUNT422Invalid point amountCheck for negative or zero values
ERR-AMOUNT-MISMATCH422Deduct amount doesn't match originalVerify transaction amounts
ERR-ZERO-BALANCE422User has no pointsUser needs to earn points

Transaction Errors

Error CodeHTTP StatusDescriptionSolution
ERR-DUPLICATE-REQUEST409Request already processedCheck yggRedemptionId uniqueness
ERR-TRANSACTION-NOT-FOUND404Original transaction not foundVerify partnerTransactionId
ERR-ALREADY-REVERTED409Transaction already reversedCheck transaction status
ERR-TRANSACTION-FAILED500Database transaction failedRetry or check system health

System Errors

Error CodeHTTP StatusDescriptionSolution
ERR-INTERNAL500Unexpected server errorCheck server logs
ERR-DATABASE-ERROR500Database connection failedCheck database connectivity
ERR-TIMEOUT504Request processing timeoutRetry or check system load
ERR-MAINTENANCE503System under maintenanceWait and retry later

Error Handling Best Practices

1. Consistent Error Format

Always use the same error response structure:

{
  "success": false,
  "errorCode": "ERR-CODE-HERE",
  "errorMessage": "Human-readable description",
  "timestamp": "2025-08-06T06:50:32.426Z", // Optional
  "requestId": "uuid-from-x-api-request"    // Optional for debugging
}

2. Meaningful Error Messages

💡

Good: "User does not have enough points. Available: 500, Required: 1000"

Bad: "Error occurred"

3. Error Logging

Log all errors with sufficient context:

console.error({
  errorCode: 'ERR-INSUFFICIENT-POINTS',
  userId: user.id,
  address: request.address,
  availablePoints: user.points,
  requestedPoints: request.deductPoints,
  yggRedemptionId: request.yggRedemptionId,
  timestamp: new Date().toISOString()
});

4. Rate Limiting

When implementing rate limiting, provide helpful information:

{
  "success": false,
  "errorCode": "ERR-RATE-LIMITED",
  "errorMessage": "Too many requests. Try again in 60 seconds",
  "retryAfter": 60,
  "maxRequests": 100,
  "windowSeconds": 3600
}

HTTP Status Code Examples

Authentication Failure

HTTP/1.1 401 Unauthorized
Content-Type: application/json
 
{
  "success": false,
  "errorCode": "ERR-INVALID-SIGNATURE",
  "errorMessage": "HMAC signature validation failed"
}

Invalid Request

HTTP/1.1 400 Bad Request
Content-Type: application/json
 
 
{
  "success": false,
  "errorCode": "ERR-INVALID-REQUEST",
  "errorMessage": "Invalid request body"
}

Request Already Processed

HTTP/1.1 409 Conflict
Content-Type: application/json
 
 
{
  "success": false,
  "errorCode": "ERR-DUPLICATE-REQUEST",
  "errorMessage": "Request already processed"
}

Business Logic Failure

HTTP/1.1 422 Unprocessable Entity
Content-Type: application/json
 
{
  "success": false,
  "errorCode": "ERR-INSUFFICIENT-POINTS",
  "errorMessage": "User has 500 points but requested 1000"
}

Server Error

HTTP/1.1 500 Internal Server Error
Content-Type: application/json
 
{
  "success": false,
  "errorCode": "ERR-DATABASE-ERROR",
  "errorMessage": "Unable to connect to database"
}
🚨

Emergency Contact: If you encounter persistent errors, contact the YGG integration team immediately through our Slack channel #ext-redeem-partnerships.