Docs

Response Body

2 min readUpdated September 19, 2026

Response Body documents what an endpoint actually returns: one or more status codes, each with its own example response body, optional response headers, and an optional schema table a visitor can switch to instead of the raw example.

Adding the block#

  1. In the block editor, open the block inserter and search for Response Body.
  2. Add it to the page, usually under an Endpoint, Parameters, and Request/Response block.
  3. Click + Add response for each status code you want to document.
  4. For each one, set the status code, content type, and response body, and add headers or schema fields if you need them.

Settings#

SettingWhat it does
Block titleHeading for the block. Defaults to “Response Body” if left blank.
Show line numbersAdds line numbers to every response body example.
ReturnsA short description shown above the list of responses.

Per response:

SettingWhat it does
Status codee.g. 200, 201, 404.
Content typee.g. application/json.
Response bodyThe example response for that status code.
Response headers (optional)Any number of headers, each with a name (e.g. Location), a type, and a description.
Schema fields (optional)Any number of fields, each with a name, type, whether it’s required, and a description. Adding at least one field turns on a Show Schema toggle for readers, so they can switch that response between the real example and a type-shape table.

Example#

One response: Status code 200, Content type application/json, with a short JSON body.

Response Body

Returns the resource if the request succeeded.

200 application/json
{
  "id": "123",
  "status": "ok"
}
Name Type Required Description
id string Required Unique identifier.
status string Required Current status.

The block#

In the editor, this is one response row filled in with a status code, content type, and body, no shortcode needed.

The shortcode#

The same block, added as a shortcode instead, for a widget, classic-editor content, or a page builder that only accepts shortcodes. Since responses is a JSON array, it can never go in a quoted attribute (a JSON array always contains a ], and the shortcode parser stops at the first literal ] it finds, quoted or not). It goes between the opening and closing tags instead:

[nahnu_code_block block="response-body" title="Response Body"]
[{"status":"200","contentType":"application/json","body":"{\"id\": 42, \"name\": \"Ada Lovelace\"}"}]
[/nahnu_code_block]

Putting the JSON between the tags, rather than in a quoted attribute, is what keeps the shortcode from cutting off partway through.

How it renders#

A 200 badge with application/json, and the JSON body shown underneath, formatted and highlighted like any other code sample.

Tips#

  • Document every status code a caller is likely to see, not just the success case. A 404 or 422 response is often as useful to a reader as the 200.
  • Only add schema fields when the shape is worth showing separately from the example. A short, obvious body usually doesn’t need one.
  • Keep the response body itself as a real, valid example. It’s what most readers will copy and paste.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only