Create Feedback(s)
This endpoint allows the creation of one or more feedback entries associated with specific tenant transactions.
Authorization
| Header | Value |
|---|---|
Api-key | string (tkn_ten_XXX..) |
Content-Type | application/json |
Endpoint
POST https://enrichment-prd-uae.lunedata.io/api/v2/feedbacks/
Request Body Schema
| Field | Type | Required | Description |
|---|---|---|---|
feedback | object | Yes | Wrapper object holding the feedback details. |
↳ transaction_ids | array[string] | Yes | Non-empty array of ref transaction IDs or global transaction IDs for which feedback is being submitted. |
↳ feedback_type | string | Yes | One of wrong_category, wrong_brand, wrong_logo. |
↳ category_id | integer | Conditional | The correct category. Used when feedback_type is wrong_category. Must be a valid ID from the categories lookup. |
↳ brand_id | integer | Optional | The correct brand ID being suggested. Typically used with feedback_type: "wrong_brand". |
↳ recommendation | string | Conditional | Required when feedback_type is wrong_brand, and when feedback_type is wrong_category and no category_id is provided. |
↳ description | string | No | Additional descriptive text for the feedback. |
Validation Rules
transaction_idsmust be a non-empty array ofref_idorglobal_tx_idvalues taken from an enrichment response.feedback_typemust be exactly one ofwrong_category,wrong_brand, orwrong_logo.- When
feedback_typeiswrong_category, supply either a validcategory_idor a non-blankrecommendation. - When
feedback_typeiswrong_brand,recommendationis required and cannot be blank. - Uniqueness Constraint: Each transaction can only have one pending feedback entry.
- Atomicity: All feedback entries are created within a single database transaction. If the creation of any single feedback fails (e.g., due to validation), all created feedback entries are rolled back.
- Duplicate transaction IDs provided in the transaction_ids array will be automatically deduplicated before processing.
Request Example
POST /api/v2/feedbacks/
Api-key: tkn_ten_XXX*************************
Content-Type: application/json
{
"feedback": {
"transaction_ids": ["bwq1-437c-c027", "437c-c027-bwq1", "c027-bwq1-437c"],
"feedback_type": "wrong_category",
"category_id": 5,
"brand_id": null,
"description": "Category is incorrect",
"recommendation": null
}
}
Success Response
201 Created
{
"success": true,
"message": "Feedback submitted successfully!",
"data": null
}
| Field | Type | Description |
|---|---|---|
success | boolean | Always true for a successful response. |
message | string | Success message. |
data | null | Not used by this endpoint. |
Error Responses
422 Unprocessable Entity is returned for validation failures and missing resources.
| Scenario | Response body |
|---|---|
| Transaction not found | { "success": false, "error": "Tenant Transaction with id [MISSING_ID] not found", "status_code": 422 } |
| Duplicate pending feedback | { "success": false, "error": "Failed to save feedback: Tenant transaction already has a pending feedback", "status_code": 422 } |
Missing recommendation | { "success": false, "error": "recommendation is required with the selected option", "status_code": 422 } |
Invalid feedback_type | { "success": false, "error": "Invalid feedback_type", "status_code": 422 } |
transaction_ids is not an array | { "success": false, "error": "transaction_ids should be a non empty array", "status_code": 422 } |
category_id does not exist | { "success": false, "error": "Invalid category_id", "status_code": 422 } |