Record response feedback
package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://api.ai.wpengine.com/v1/sessions/example/responses/example/feedback"
payload := strings.NewReader("{ \"rating\": true, \"message\": \"example\" }")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>") req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}const url = 'https://api.ai.wpengine.com/v1/sessions/example/responses/example/feedback';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"rating":true,"message":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}<?php
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.ai.wpengine.com/v1/sessions/example/responses/example/feedback', [ 'body' => '{ "rating": true, "message": "example" }', 'headers' => [ 'Authorization' => 'Bearer <token>', 'Content-Type' => 'application/json', ],]);
echo $response->getBody();curl --request POST \ --url https://api.ai.wpengine.com/v1/sessions/example/responses/example/feedback \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "rating": true, "message": "example" }'Records a thumbs-up or thumbs-down, with an optional comment, on a single agent response. response_event_id must name an agent.message event belonging to the session in the path; any other event type is rejected with 400. Feedback is immutable once recorded. Repeating the identical request succeeds with 200 so a client that retries a lost response is not punished for it, but changing a recorded rating or comment is rejected with 409. This endpoint consumes no credits. Accepts a service-token bearer authenticating a site or an API key, either of which must be authorized for the session’s project, or a browser session token holding the session_events scope (bound to the session’s agent and, when the session records an owner_id, to that same visitor).
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The session ID.
The id of the agent.message event being rated, as returned by GET /v1/sessions/{session_id}/events.
Request Bodyrequired
Section titled “Request Bodyrequired”object
True for a thumbs-up, false for a thumbs-down. Required — an omitted rating is rejected rather than defaulted, so a thumbs-down is never recorded by accident.
Optional free-text comment. Stored as plain text, with the comment’s own meaning preserved: tabs and line breaks are kept (every spelling of a line break — CRLF, CR, U+2028, U+2029 — is stored as a newline), while the control characters that are not whitespace and a bounded set of format characters that misrepresent the surrounding text (the bidi overrides and isolates U+202A–U+202E and U+2066–U+2069, the zero-width space U+200B, and the byte-order mark U+FEFF) are removed. Other invisible characters are kept, including the joiners that hold emoji sequences together and are ordinary orthography in several scripts. Unicode is then normalized (NFC) and surrounding whitespace is trimmed. A comment that is empty after that is stored as no comment at all. A comment longer than 2000 characters is rejected rather than truncated. Markup is never stripped: what is stored stays untrusted text, and each consumer must apply the output encoding its own rendering context calls for.
Examplegenerated
{ "rating": true, "message": "example"}Responses
Section titled “Responses”Feedback identical to what was already recorded; nothing changed.
object
The agent.message event this feedback is about.
True for a thumbs-up, false for a thumbs-down.
The comment as stored, or null when none was given. Always present so “rated without a comment” is unambiguous.
When the feedback was recorded.
Examplegenerated
{ "response_event_id": "example", "rating": true, "message": "example", "created_at": "2026-04-15T12:00:00Z"}Feedback recorded
object
The agent.message event this feedback is about.
True for a thumbs-up, false for a thumbs-down.
The comment as stored, or null when none was given. Always present so “rated without a comment” is unambiguous.
When the feedback was recorded.
Examplegenerated
{ "response_event_id": "example", "rating": true, "message": "example", "created_at": "2026-04-15T12:00:00Z"}Invalid request body or parameters
object
object
Correlation ID for this request, matching the X-Request-ID response header — a 32-character trace ID behind the load balancer, otherwise a UUID. Quote it in support reports.
Example
{ "error": { "type": "invalid_request_error", "request_id": "80f1e2c3a4b5c6d7e8f9a0b1c2d3e4f5" }}Missing or invalid bearer token
object
object
Correlation ID for this request, matching the X-Request-ID response header — a 32-character trace ID behind the load balancer, otherwise a UUID. Quote it in support reports.
Example
{ "error": { "type": "invalid_request_error", "request_id": "80f1e2c3a4b5c6d7e8f9a0b1c2d3e4f5" }}Headers
Section titled “Headers”Example
Bearer realm="ai-services"The token is valid, but the request is forbidden. Error type “permission_error” means the token’s scope/permission is insufficient or the authenticated user is not authorized for the target account; “entitlement_required” means the account lacks the required product entitlement; and “account_required” means no billing account could be resolved. On /v1/chat/completions when content moderation is enabled, and on /v1/sessions/{session_id}/events, error type “content_policy_violation” instead means the request content was blocked by content moderation policy; that response never identifies which filter or category matched.
object
object
Correlation ID for this request, matching the X-Request-ID response header — a 32-character trace ID behind the load balancer, otherwise a UUID. Quote it in support reports.
Example
{ "error": { "type": "invalid_request_error", "request_id": "80f1e2c3a4b5c6d7e8f9a0b1c2d3e4f5" }}The requested resource was not found
object
object
Correlation ID for this request, matching the X-Request-ID response header — a 32-character trace ID behind the load balancer, otherwise a UUID. Quote it in support reports.
Example
{ "error": { "type": "invalid_request_error", "request_id": "80f1e2c3a4b5c6d7e8f9a0b1c2d3e4f5" }}Conflict. Feedback has already been recorded for this response with a different rating or comment, and recorded feedback cannot be changed.
object
object
Correlation ID for this request, matching the X-Request-ID response header — a 32-character trace ID behind the load balancer, otherwise a UUID. Quote it in support reports.
Example
{ "error": { "type": "invalid_request_error", "request_id": "80f1e2c3a4b5c6d7e8f9a0b1c2d3e4f5" }}Request body exceeds the 64 KiB limit
object
object
Correlation ID for this request, matching the X-Request-ID response header — a 32-character trace ID behind the load balancer, otherwise a UUID. Quote it in support reports.
Example
{ "error": { "type": "invalid_request_error", "request_id": "80f1e2c3a4b5c6d7e8f9a0b1c2d3e4f5" }}Rate limit exceeded. The request was throttled at the edge; wait and retry later. The response body is a short HTML page generated by the load balancer, not a structured JSON error — clients should rely on the 429 status code rather than parsing the body.
The server encountered an unexpected error while handling the request. Safe to retry once; if it persists, the cause is server-side and the request payload was not the problem.
object
object
Correlation ID for this request, matching the X-Request-ID response header — a 32-character trace ID behind the load balancer, otherwise a UUID. Quote it in support reports.
Example
{ "error": { "type": "invalid_request_error", "request_id": "80f1e2c3a4b5c6d7e8f9a0b1c2d3e4f5" }}A required dependency is temporarily unavailable. Retry after a short delay with exponential back-off. An entitlement lookup failure uses error type “entitlement_unavailable”.
object
object
Correlation ID for this request, matching the X-Request-ID response header — a 32-character trace ID behind the load balancer, otherwise a UUID. Quote it in support reports.
Example
{ "error": { "type": "invalid_request_error", "request_id": "80f1e2c3a4b5c6d7e8f9a0b1c2d3e4f5" }}