Skip to main content

Errors

The neuroflash API uses standard HTTP status codes and returns structured error responses.

HTTP Status Codes

Status CodeMeaning
200OK — Request succeeded
201Created — Resource was created
204No Content — Request succeeded with no response body
400Bad Request — Invalid request parameters or body
401Unauthorized — Missing or invalid access token
403Forbidden — Insufficient permissions or limit reached
404Not Found — Resource does not exist
422Unprocessable Entity — Validation error
429Too Many Requests — Rate limit or quota exceeded
500Internal Server Error — Something went wrong on our end

Error Response Format

Error responses include an error field with a human-readable message and, where applicable, a code field for programmatic error handling:

{
"error": "Target audience limit reached for this workspace",
"code": "TARGET_AUDIENCE_LIMIT_REACHED"
}

Validation Errors

Some endpoints return detailed validation errors with field-level information:

{
"errors": [
{
"field": "name",
"message": "must be between 3 and 100 characters",
"type": "validation"
}
]
}

Common Error Codes

CodeDescription
TARGET_AUDIENCE_LIMIT_REACHEDWorkspace has reached its target audience creation limit
MAX_BRAND_VOICES_REACHEDWorkspace has reached its brand voice creation limit

Handling Errors

# Example: handle error responses
response=$(curl -s -w "\n%{http_code}" -X POST \
"https://app.neuroflash.com/api/audience-service/v1/workspaces/{workspace_id}/target-audiences" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "My Audience"}')

http_code=$(echo "$response" | tail -1)
body=$(echo "$response" | sed '$d')

if [ "$http_code" -eq 201 ]; then
echo "Created: $body"
else
echo "Error $http_code: $body"
fi