Skip to main content
POST
/
api
/
v1
/
user
/
messages
/
{messageId}
/
feedback
Submit message feedback (like/dislike)
curl --request POST \
  --url https://handauncle-backend-prod-205012263523.asia-south1.run.app/api/v1/user/messages/{messageId}/feedback \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "rating": 1,
  "feedback": "Very helpful and accurate response!"
}
'
{
  "success": true,
  "data": {
    "messageId": "507f1f77bcf86cd799439011",
    "rating": 1,
    "feedback": "Very helpful and accurate response!",
    "updatedAt": "2025-12-10T08:35:00.000Z"
  },
  "meta": {
    "timestamp": "2023-11-07T05:31:56Z",
    "requestId": "<string>"
  }
}
Submit user feedback (like/dislike rating and optional text comments) for a specific message. This endpoint supports both registered users (Auth0 JWT) and guest users (device-based authentication), making it accessible during free trial flows.

Authentication Methods

Unlike other conversation endpoints, this route accepts two authentication methods:
  1. Auth0 JWT (Registered users)
    • Header: Authorization: Bearer <token>
    • Standard authenticated flow
  2. Device-based (Guest users)
    • Headers: x-device-id, x-user-id, x-platform
    • Same authentication as /api/v1/ai/chat
    • Enables feedback during trial/guest sessions

Use Cases

  • Thumbs up/down on AI responses
  • Report inaccuracies with text feedback
  • Track user satisfaction for model improvements
  • A/B testing different prompts or models

Request Body

FieldTypeRequiredDescription
rating1 | -1✅ Yes1 for like (👍), -1 for dislike (👎)
feedbackstring❌ NoOptional text feedback (max 1000 chars)

Response

Returns the updated feedback data with a timestamp.
{
  "success": true,
  "data": {
    "messageId": "507f1f77bcf86cd799439011",
    "rating": 1,
    "feedback": "Very helpful explanation!",
    "updatedAt": "2025-12-10T08:35:00.000Z"
  },
  "meta": {
    "timestamp": "2025-12-10T08:35:00.000Z",
    "requestId": "req_abc123"
  }
}

Examples

curl -X POST \
  'https://api.handauncle.com/api/v1/user/messages/507f1f77bcf86cd799439011/feedback' \
  -H 'Authorization: Bearer YOUR_JWT_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "rating": 1,
    "feedback": "Great response!"
  }'

Error Responses

400 Bad Request - Invalid Rating

{
  "success": false,
  "error": {
    "message": "rating: Rating must be 1 (like) or -1 (dislike)",
    "code": "VALIDATION_ERROR"
  }
}

401 Unauthorized - Missing Authentication

{
  "success": false,
  "error": {
    "message": "Missing authentication. Provide either Authorization header or x-device-id header.",
    "code": "UNAUTHORIZED"
  }
}

403 Forbidden - Wrong User

{
  "success": false,
  "error": {
    "message": "You do not have access to this message",
    "code": "FORBIDDEN"
  }
}

404 Not Found - Message Doesn’t Exist

{
  "success": false,
  "error": {
    "message": "Message not found",
    "code": "NOT_FOUND"
  }
}

Validation Rules

  • rating must be exactly 1 or -1 (no other values accepted)
  • feedback is optional but limited to 1000 characters
  • messageId must be a valid 24-character MongoDB ObjectId
  • User must own the conversation containing the message

Notes

  • Idempotent: Submitting feedback multiple times overwrites previous feedback
  • Guest support: Same authentication pattern as chat API for seamless trial experience
  • Privacy: Only the message owner can submit feedback
  • Analytics: Feedback data can be used to improve AI model performance
  • No removal: Once submitted, feedback can only be updated (not deleted)

Authorizations

Authorization
string
header
required

Auth0 access token for registered users.

Path Parameters

messageId
string
required

MongoDB ObjectId of the message to rate

Pattern: ^[a-f0-9]{24}$
Example:

"507f1f77bcf86cd799439011"

Body

application/json
rating
enum<integer>
required

1 for like (👍), -1 for dislike (👎)

Available options:
1,
-1
Example:

1

feedback
string

Optional text feedback explaining the rating

Maximum string length: 1000
Example:

"Very helpful and accurate response!"

Response

Feedback submitted successfully.

success
enum<boolean>
required
Available options:
true
data
object
required
meta
object
required