Error Handling

The VisitNote API uses standard HTTP status codes and a consistent error response format. All error responses include a descriptive message to help you diagnose issues.

Error Response Format

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

The errors field is present only on 422 Validation Error responses and contains field-specific error messages.

HTTP Status Codes

StatusMeaningWhat to Do
200OKRequest succeeded. Parse the data field.
401UnauthorizedToken is missing, invalid, or expired. Re-authenticate.
403ForbiddenToken is valid but lacks permission for this resource.
404Not FoundResource does not exist. Verify the UUID/ID.
409ConflictDuplicate resource or conflicting state (e.g., already joined org).
413Payload Too LargeFile upload exceeds size limit. Reduce file size.
422Validation ErrorRequest body failed validation. Check the errors field.
429Rate LimitedToo many requests. Wait and retry with exponential backoff.
500Server ErrorInternal error. Retry after a short delay. If persistent, contact support.

Handling 401 Unauthorized

When you receive a 401 response, your JWT token has expired or is invalid. Recommended handling:

const response = await fetch(url, {
  headers: { Authorization: `Bearer ${token}` },
});

if (response.status === 401) {
  // Token expired — clear stored token and re-authenticate
  clearStoredToken();
  const newToken = await signIn(email, password);
  // Retry the original request with the new token
}

Handling Validation Errors (422)

Validation errors include per-field error messages. Display them to the user or use them to fix the request:

const response = await fetch(url, { method: 'POST', body, headers });
const data = await response.json();

if (response.status === 422 && data.errors) {
  // data.errors = { "email": ["Email already taken"], "password": [...] }
  for (const [field, messages] of Object.entries(data.errors)) {
    console.error(`${field}: ${messages.join(', ')}`);
  }
}

Retry Strategy

For transient errors (429, 500, network timeouts), use exponential backoff:

  • 1st retry: wait 1 second
  • 2nd retry: wait 2 seconds
  • 3rd retry: wait 4 seconds
  • Maximum 3 retries before failing

Do not retry 401, 403, 404, or 422 errors — these require fixing the request itself.

Timeouts

The API has a 30-second response timeout for most endpoints. File upload endpoints (audio upload, AI processing) have a 120-second timeout. Set your HTTP client timeout accordingly.