Response Structure

All Unifically API responses follow a consistent structure:

Success Response

{
  "code": 200,
  "data": {
    // Response data
  }
}

Error Response

{
  "code": 400,
  "data": {
    "message": "Error message",
    "code": "error_code"
  }
}
Empty arrays and objects are omitted from responses when not needed.

HTTP Status Codes

CodeMeaningDescription
200SuccessTask successfully submitted
400Bad RequestTask generation failed
401UnauthorizedInvalid or missing API key
422Validation ErrorInvalid request parameters
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer error occurred

Error Response Format

When an error occurs, the API returns a simplified structure:
{
  "code": 400,
  "data": {
    "message": "Error message",
    "code": "error_code"
  }
}

Error Response Fields

code
integer
HTTP status code (200, 400, 401, 422, 429, 500)
data
object
Error details
message
string
Human-readable error message
code
string
Error code identifier

Common Error Codes

Error CodeHTTP StatusDescription
validation_error422Invalid request parameters
authentication_failed401Invalid or missing API key
generation_failed400Task generation failed
rate_limit_exceeded429Too many requests
internal_error500Server error

Example Error Responses

{
  "code": 401,
  "data": {
    "message": "Invalid API key provided",
    "code": "authentication_failed"
  }
}
Solution: Verify your API key is correct and properly formatted in the Authorization header:
Authorization: Bearer YOUR_ACTUAL_API_KEY
{
  "code": 429,
  "data": {
    "message": "Rate limit exceeded. Please try again later",
    "code": "rate_limit_exceeded"
  }
}
Solution: Implement exponential backoff and respect rate limits
{
  "code": 422,
  "data": {
    "message": "Missing required parameter: prompt",
    "code": "validation_error"
  }
}
Solution: Check the API documentation for required parameters and valid values
{
  "code": 400,
  "data": {
    "message": "Task generation failed",
    "code": "generation_failed"
  }
}
Solution: Review your request parameters and try again
{
  "code": 500,
  "data": {
    "message": "Internal server error occurred",
    "code": "internal_error"
  }
}
Solution: Retry the request after a brief delay. Contact support if the issue persists

Best Practices

Always Check Response Code

Check the code field in every response to determine success or failure

Implement Retry Logic

Retry failed requests with exponential backoff for 429 and 500 errors

Log Errors

Log all error responses including the error code and message for debugging

Handle Rate Limits

Implement rate limit handling to avoid 429 errors
Always parse the error.message field to provide helpful feedback to your users
Never expose your API key in client-side code or public repositories