In the case of an error at a REST endpoint I've set up, I am accustomed to returning a WP_Error object, which is convenient because I can include a code, a message, and an HTTP status into a single returned object.

But what about in the case of success? Is there an equivalent class, for the sake of control and uniformity?

I'm looking at the constructors of WP_HTTP_Response and WP_HTTP_Requests but they don't seem to accept the same parameters as WP_Error.


1 Answer 1


I think you are looking for WP_REST_Response.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.