Skip to main content

HTTP Status Codes

The Drime Cloud API uses standard HTTP codes:
CodeMeaning
200Success
201Created successfully
400Bad request
401Unauthenticated
403Access denied
404Resource not found
422Validation error
429Too many requests
500Server error

Error Formats

Authentication Error (401)

{
  "message": "Unauthenticated."
}
Verify that your token is valid and sent in the Authorization: Bearer TOKEN header

Permission Error (403)

{
  "message": "This action is unauthorized."
}

Validation Error (422)

{
  "status": "error",
  "message": "The given data was invalid.",
  "errors": {
    "email": ["The email field is required."],
    "password": ["The password must be at least 8 characters."]
  }
}

Resource Not Found (404)

{
  "message": "No query results for model [App\\FileEntry] 123456"
}

Best Practices

const response = await fetch(url, options);

if (!response.ok) {
  const error = await response.json();
  throw new Error(error.message || 'Request failed');
}
if (response.status === 422) {
  const { errors } = await response.json();
  // Display errors per field
  Object.entries(errors).forEach(([field, messages]) => {
    console.error(`${field}: ${messages.join(', ')}`);
  });
}
if (response.status === 401) {
  // Token expired, reconnect the user
  await refreshToken();
  // Retry the request
}

Rate Limiting

The API limits request rates to ensure stability:
If you receive a 429 error, wait a few seconds before retrying.
async function fetchWithRetry(url, options, retries = 3) {
  for (let i = 0; i < retries; i++) {
    const response = await fetch(url, options);
    
    if (response.status === 429) {
      const waitTime = Math.pow(2, i) * 1000; // Exponential backoff
      await new Promise(r => setTimeout(r, waitTime));
      continue;
    }
    
    return response;
  }
  throw new Error('Max retries exceeded');
}