Skip to content
WP EngineDocumentation

Record response feedback

POST
/v1/sessions/{session_id}/responses/{response_event_id}/feedback
<?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();

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).

session_id
required
string

The session ID.

response_event_id
required
string

The id of the agent.message event being rated, as returned by GET /v1/sessions/{session_id}/events.

Media typeapplication/json
object
rating
required

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.

boolean
message

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.

string
nullable <= 2000 characters
Examplegenerated
{
"rating": true,
"message": "example"
}

Feedback identical to what was already recorded; nothing changed.

Media typeapplication/json
object
response_event_id
required

The agent.message event this feedback is about.

string
rating
required

True for a thumbs-up, false for a thumbs-down.

boolean
message

The comment as stored, or null when none was given. Always present so “rated without a comment” is unambiguous.

string
nullable
created_at
required

When the feedback was recorded.

string format: date-time
Examplegenerated
{
"response_event_id": "example",
"rating": true,
"message": "example",
"created_at": "2026-04-15T12:00:00Z"
}

Feedback recorded

Media typeapplication/json
object
response_event_id
required

The agent.message event this feedback is about.

string
rating
required

True for a thumbs-up, false for a thumbs-down.

boolean
message

The comment as stored, or null when none was given. Always present so “rated without a comment” is unambiguous.

string
nullable
created_at
required

When the feedback was recorded.

string format: date-time
Examplegenerated
{
"response_event_id": "example",
"rating": true,
"message": "example",
"created_at": "2026-04-15T12:00:00Z"
}

Invalid request body or parameters

Media typeapplication/json
object
error
required
object
message
required
string
type
required
string
code
required
integer
request_id
required

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.

string
Example
{
"error": {
"type": "invalid_request_error",
"request_id": "80f1e2c3a4b5c6d7e8f9a0b1c2d3e4f5"
}
}

Missing or invalid bearer token

Media typeapplication/json
object
error
required
object
message
required
string
type
required
string
code
required
integer
request_id
required

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.

string
Example
{
"error": {
"type": "invalid_request_error",
"request_id": "80f1e2c3a4b5c6d7e8f9a0b1c2d3e4f5"
}
}
WWW-Authenticate
string
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.

Media typeapplication/json
object
error
required
object
message
required
string
type
required
string
code
required
integer
request_id
required

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.

string
Example
{
"error": {
"type": "invalid_request_error",
"request_id": "80f1e2c3a4b5c6d7e8f9a0b1c2d3e4f5"
}
}

The requested resource was not found

Media typeapplication/json
object
error
required
object
message
required
string
type
required
string
code
required
integer
request_id
required

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.

string
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.

Media typeapplication/json
object
error
required
object
message
required
string
type
required
string
code
required
integer
request_id
required

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.

string
Example
{
"error": {
"type": "invalid_request_error",
"request_id": "80f1e2c3a4b5c6d7e8f9a0b1c2d3e4f5"
}
}

Request body exceeds the 64 KiB limit

Media typeapplication/json
object
error
required
object
message
required
string
type
required
string
code
required
integer
request_id
required

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.

string
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.

Media typetext/html
string

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.

Media typeapplication/json
object
error
required
object
message
required
string
type
required
string
code
required
integer
request_id
required

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.

string
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”.

Media typeapplication/json
object
error
required
object
message
required
string
type
required
string
code
required
integer
request_id
required

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.

string
Example
{
"error": {
"type": "invalid_request_error",
"request_id": "80f1e2c3a4b5c6d7e8f9a0b1c2d3e4f5"
}
}