Skip to main content

Error Handling

The Okasie Partner API uses standard HTTP status codes and provides structured error responses.

Error Response Format

All errors follow a consistent format:
{
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable error message"
  }
}
For validation errors, additional details are provided:
{
  "error": {
    "code": "VALIDATION_FAILED",
    "message": "Payload validation failed",
    "issues": [
      {
        "path": "price",
        "message": "Required",
        "code": "invalid_type"
      }
    ]
  }
}

HTTP Status Codes

StatusMeaningAction
200SuccessProcess the response
201CreatedResource was created successfully
400Bad RequestCheck your request format
401UnauthorizedCheck your API secret
403ForbiddenYou don’t have access to this resource
404Not FoundResource doesn’t exist
422Validation ErrorCheck the issues array for details
429Rate LimitedWait and retry with backoff
500Server ErrorRetry later, contact support if persistent

Error Codes Reference

Authentication Errors

CodeStatusDescriptionSolution
UNAUTHORIZED401Invalid or missing API keyCheck your Authorization header
PROFILE_FORBIDDEN403No access to requested profileContact support for access

Validation Errors

CodeStatusDescriptionSolution
INVALID_JSON400Request body is not valid JSONCheck JSON syntax
INVALID_BODY400Request body must be an objectEnsure you’re sending a JSON object
INVALID_REFERENCE400External reference is missingProvide externalReference
VALIDATION_FAILED422Payload validation failedCheck issues for specific fields
INVALID_TITLE400Title is requiredProvide a non-empty title
INVALID_PRICE400Price required for active listingsProvide price when status is active
INVALID_LOCATION400Location fields requiredProvide postalCode, city, and province
INVALID_PROFILE400Profile ID/code requiredProvide dealerProfileId or dealerLocationCode

Resource Errors

CodeStatusDescriptionSolution
NOT_FOUND404Listing not foundCheck the external reference
FETCH_FAILED500Failed to fetch dataRetry, contact support if persistent
UPSERT_FAILED500Failed to save listingRetry, contact support if persistent
FEATURES_FAILED500Failed to sync featuresCheck feature format
IMAGES_FAILED500Failed to sync imagesCheck image URLs are accessible

Rate Limiting

CodeStatusDescriptionSolution
RATE_LIMITED429Too many requestsWait for Retry-After seconds

Bulk Operations

CodeStatusDescriptionSolution
EMPTY_PAYLOAD400No items providedInclude at least one item
TOO_MANY_ITEMS400Exceeded 100 itemsSplit into smaller batches

Handling Errors in Code

async function createListing(listing) {
  const response = await fetch(url, {
    method: 'PUT',
    headers: {
      'Authorization': `Bearer ${process.env.PARTNER_SECRET}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(listing)
  });

  if (!response.ok) {
    const error = await response.json();

    switch (response.status) {
      case 401:
        throw new Error('Invalid API credentials');
      case 403:
        throw new Error(`Access denied: ${error.error.message}`);
      case 422:
        const issues = error.error.issues.map(i =>
          `${i.path}: ${i.message}`
        ).join(', ');
        throw new Error(`Validation failed: ${issues}`);
      case 429:
        const retryAfter = response.headers.get('Retry-After');
        throw new Error(`Rate limited. Retry after ${retryAfter}s`);
      default:
        throw new Error(error.error.message || 'Unknown error');
    }
  }

  return response.json();
}

Request ID for Support

Every response includes a request ID in the header or response. Include this when contacting support:
X-Request-Id: req-abc123-def456
Log the X-Request-Id for all failed requests to help with debugging.

Next Steps