Docs

Request / Response

2 min readUpdated September 19, 2026

Request/Response shows a tabbed set of request and response code examples for an endpoint, one tab per language. A reader can pick cURL, JavaScript, Python, or whichever language they work in, and see a matching request alongside the response it returns.

Adding the block#

  1. In the block editor, open the block inserter and search for Request / Response.
  2. Add it to the page, usually under an Endpoint and its Parameters block.
  3. Click + Add language for each language you want to show.
  4. For each one, pick the language, set a tab label, and paste in the request code and the response code.

Settings#

SettingWhat it does
Show line numbersAdds line numbers to every request and response sample in the block.

Per language tab:

SettingWhat it does
LanguageSets syntax highlighting for that tab. Covers cURL, JavaScript, Python, PHP, Ruby, Go, Java, C#, and Rust.
Tab labelThe text shown on the tab itself, e.g. cURL or Node.js.
Request codeThe sample request for that language.
Response codeThe sample response that request returns.

Example#

One language tab: Language set to cURL, Tab label set to cURL, with a request and its response.

curl -X GET https://api.example.com/v1/resource \
  -H "Authorization: Bearer YOUR_API_KEY"
{
  "id": "123",
  "status": "ok"
}
const res = await fetch('https://api.example.com/v1/resource', {
  headers: { Authorization: 'Bearer YOUR_API_KEY' }
});
const data = await res.json();
{
  "id": "123",
  "status": "ok"
}

The block#

In the editor, this is one language row filled in with a request and response, 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. Because examples is a list of example objects, it’s passed as a JSON string:

[nahnu_code_block block="request-response"]
[{"language":"bash","label":"cURL","requestCode":"curl https://api.example.com/customers/42","responseCode":"{\"id\": 42, \"name\": \"Ada Lovelace\"}"}]
[/nahnu_code_block]

The examples attribute is wrapped in single quotes, with the strings inside it in double quotes, and any double quote that appears inside the request or response text itself is escaped with a backslash. Keeping the quote characters distinct like this is what keeps the shortcode from cutting off early.

How it renders#

A single tab labeled “cURL”, with the request shown above the response it returns.

Tips#

  • Keep the request and response samples realistic. A reader will often copy the request as a starting point.
  • Add cURL first, then whichever other languages your readers are most likely to use.
  • Pair this block with Parameters directly above it, so a reader can see the inputs and the resulting request and response together.

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