Error handling

Check the HTTP status and code field. WordPress may reject a request during authentication or parameter validation before AAM’s handler runs, so error bodies vary by failure point.

{
  "code": "rest_invalid_argument",
  "message": "The supplied value is invalid.",
  "data": { "status": 400 }
}

This is a typical AAM handler error shape. A WordPress validation error may also include params and details under data.

AAM code Status What to check
rest_invalid_argument 400 Required parameter, type, enum, or ID format.
rest_unauthorized 401 or 406 Authentication, management capability, or rejected operation.
rest_not_found 404 Target resource or disabled route.
rest_workflow_error 409 A rule or WordPress state blocks the change.
rest_unexpected_error 500 Unexpected handler failure; inspect server logs.
rest_insufficient_storage 507 AAM could not persist a change.

This mapping comes from AAM’s REST service trait. WordPress may return its own codes, including rest_forbidden and rest_invalid_param. Use the HTTP status and check the returned resource or success field where available.