Reference: shortcodes new in 1.0.2

All twelve blocks, at a glance

Every block Nahnu Code and API Block registers, grouped the way you will actually reach for them, plus the shortcode that drops each one anywhere the block editor cannot reach: a widget, a page builder, or classic editor content.

Code

1 block
Code Blocknahnu-code-block/code-block

Syntax-highlighted snippets for 20 plus languages, bundled Prism.js, auto light and dark, collapsible preview, copy button, line numbers.

user.py
class User:
    # Represents an application user.
    def __init__(self, name, email):
        self.name = name
        self.email = email
        self.created_at = datetime.utcnow()
    def to_dict(self):
        return dict(name=self.name, email=self.email)
[nahnu_code_block block="code-block" language="python" title="user.py" code="class User: # Represents an application user. def __init__(self, name, email): self.name = name self.email = email self.created_at = datetime.utcnow() def to_dict(self): return dict(name=self.name, email=self.email)"]
core20 plus languages

API reference

6 blocks
Endpointnahnu-code-block/endpoint

Method, path, summary, version, deprecation notice, auth flag, operation-ID anchor, related endpoints.

POST /v1/invoices 🔗 🔒 Auth Required v2

Create a new invoice for a customer.

Creates an invoice in a draft state for the given customer. Call finalize to send it.

[nahnu_code_block block="endpoint" method="POST" path="/v1/invoices" summary="Create a new invoice for a customer." description="Creates an invoice in a draft state for the given customer. Call finalize to send it." version="v2" operationId="createInvoice" authRequired="true"] [{"method":"GET","path":"/v1/invoices/{id}","label":"Retrieve an invoice"},{"method":"POST","path":"/v1/invoices/{id}/finalize","label":"Finalize an invoice"}] [/nahnu_code_block]
coredeep-link
Parametersnahnu-code-block/parameters

Type, location, format, defaults, validation, nested objects, and linkable type references, one row per field.

Parameters
Name Type In Required Description
customer 🔗stringqueryRequired Identifier of the customer to bill.
amount 🔗integerqueryRequired Amount to charge, in cents.
currency 🔗stringqueryOptional Three letter ISO currency code.
Defaultusd
address 🔗objectqueryOptional Billing address to print on the invoice.
Show 2 nested fields
line1 🔗stringqueryOptional Street address.
city 🔗stringqueryOptional City.
[nahnu_code_block block="parameters" title="Parameters"] [{"name":"customer","type":"string","required":true,"location":"query","description":"Identifier of the customer to bill."},{"name":"amount","type":"integer","required":true,"location":"query","description":"Amount to charge, in cents."},{"name":"currency","type":"string","required":false,"location":"query","default":"usd","description":"Three letter ISO currency code."},{"name":"address","type":"object","required":false,"location":"query","description":"Billing address to print on the invoice.","children":[{"name":"line1","type":"string","required":false,"description":"Street address."},{"name":"city","type":"string","required":false,"description":"City."}]}] [/nahnu_code_block]
corenested
Request / Responsenahnu-code-block/request-response

Tabbed examples per language: cURL, JS, Python, PHP, with synced language selection across the page.

curl https://api.example.com/v1/invoices \n  -u sk_live_dummy: \n  -d customer=cus_8f2a \n  -d amount=4200 \n  -d currency=usd
{
  "id": "in_123",
  "customer": "cus_8f2a",
  "amount": 4200,
  "currency": "usd",
  "status": "draft"
}
const invoice = await client.invoices.create({
  customer: "cus_8f2a",
  amount: 4200,
  currency: "usd"
});
{
  id: "in_123",
  customer: "cus_8f2a",
  amount: 4200,
  currency: "usd",
  status: "draft"
}
[nahnu_code_block block="request-response"] [{"language":"bash","label":"cURL","requestCode":"curl https://api.example.com/v1/invoices \\n -u sk_live_dummy: \\n -d customer=cus_8f2a \\n -d amount=4200 \\n -d currency=usd","responseCode":"{\n \"id\": \"in_123\",\n \"customer\": \"cus_8f2a\",\n \"amount\": 4200,\n \"currency\": \"usd\",\n \"status\": \"draft\"\n}"},{"language":"javascript","label":"JavaScript","requestCode":"const invoice = await client.invoices.create({\n customer: \"cus_8f2a\",\n amount: 4200,\n currency: \"usd\"\n});","responseCode":"{\n id: \"in_123\",\n customer: \"cus_8f2a\",\n amount: 4200,\n currency: \"usd\",\n status: \"draft\"\n}"}] [/nahnu_code_block]
coresynced tabs
Response Bodynahnu-code-block/response-body

Real bodies grouped by status code in an accordion, plus a "Show Schema" toggle for a type-shape view.

Response Body

The created Invoice object.

200 application/json
Header Type Description
Request-Id string Unique identifier for this API request.
{
  "id": "in_123",
  "customer": "cus_8f2a",
  "amount": 4200,
  "currency": "usd",
  "status": "draft"
}
Name Type Required Description
id string Required Unique invoice identifier.
customer string Required Customer this invoice bills.
amount integer Required Amount due, in cents.
status string Required draft, open, paid, or void.
402 application/json
{
  "error": {
    "type": "card_error",
    "code": "card_declined",
    "message": "Your card was declined."
  }
}
[nahnu_code_block block="response-body" returns="The created Invoice object."] [{"status":"200","contentType":"application/json","body":"{\n \"id\": \"in_123\",\n \"customer\": \"cus_8f2a\",\n \"amount\": 4200,\n \"currency\": \"usd\",\n \"status\": \"draft\"\n}","schema":[{"name":"id","type":"string","required":true,"description":"Unique invoice identifier."},{"name":"customer","type":"string","required":true,"description":"Customer this invoice bills."},{"name":"amount","type":"integer","required":true,"description":"Amount due, in cents."},{"name":"status","type":"string","required":true,"description":"draft, open, paid, or void."}],"headers":[{"name":"Request-Id","type":"string","description":"Unique identifier for this API request."}]},{"status":"402","contentType":"application/json","body":"{\n \"error\": {\n \"type\": \"card_error\",\n \"code\": \"card_declined\",\n \"message\": \"Your card was declined.\"\n }\n}","schema":[],"headers":[]}] [/nahnu_code_block]
coreaccordion
Status Codesnahnu-code-block/status-codes

A color-coded quick-scan table of every status the endpoint returns, with an optional example per row.

Response Codes
Code Meaning Description
200 OK The invoice was created.
402 Card Declined The card on file was declined.
404 Not Found The customer does not exist.
[nahnu_code_block block="status-codes"] [{"code":"200","meaning":"OK","description":"The invoice was created.","example":""},{"code":"402","meaning":"Card Declined","description":"The card on file was declined.","example":""},{"code":"404","meaning":"Not Found","description":"The customer does not exist.","example":""}] [/nahnu_code_block]
corecolor-coded
Authenticationnahnu-code-block/auth

Bearer, API key, Basic, or OAuth 2.0, the exact header a client sends, with its own copy button.

Authorization: Bearer YOUR_API_KEY

Send this header on every request. Keys are issued per environment, live and test.

[nahnu_code_block block="auth" scheme="bearer" headerName="Authorization" placeholder="YOUR_API_KEY" description="Send this header on every request. Keys are issued per environment, live and test."]
core

Interactive

1 block
Try It Consolenahnu-code-block/try-it

A real request, edited and sent from the visitor's own browser. Never proxied through your WordPress server.

This sends a real request, from your browser, directly to the URL below. It does not go through this site's server.
POST
[nahnu_code_block block="try-it" method="POST" url="https://api.example.com/v1/invoices" headers="Authorization: Bearer YOUR_API_KEY" body="{ customer: cus_8f2a, amount: 4200, currency: usd }"]
liveclient-side

Supporting

4 blocks
Error Codesnahnu-code-block/error-codes

Your API's own error taxonomy, distinct from HTTP status, each with an optional example error body.

Errors
Type Code Description
invalid_request_error 🔗 parameter_missing A required parameter was not provided.
card_error 🔗 card_declined The card was declined by the issuing bank.
[nahnu_code_block block="error-codes"] [{"type":"invalid_request_error","code":"parameter_missing","description":"A required parameter was not provided.","example":""},{"type":"card_error","code":"card_declined","description":"The card was declined by the issuing bank.","example":""}] [/nahnu_code_block]
reference
Eventsnahnu-code-block/events

Webhook or event names your resource emits, each with a description and expandable example payload.

Events
Event Description
invoice.created 🔗 Occurs whenever a new invoice is created.
invoice.paid 🔗 Occurs whenever an invoice is paid.
[nahnu_code_block block="events"] [{"name":"invoice.created","description":"Occurs whenever a new invoice is created.","example":""},{"name":"invoice.paid","description":"Occurs whenever an invoice is paid.","example":""}] [/nahnu_code_block]
referencedeep-link
API Navigationnahnu-code-block/api-navigation

Auto-generated jump-list of every Endpoint block on the current page. Scans this page only, so it will list the Endpoint card above.

Endpoints on this page

No endpoints found on this page.

[nahnu_code_block block="api-navigation"]
auto-generated
Serversnahnu-code-block/servers

Base URLs: production, sandbox, regional. Maps to OpenAPI's servers array.

Base URL
  • Production
    https://api.example.com
  • Sandbox
    https://sandbox.api.example.com
[nahnu_code_block block="servers"] [{"url":"https://api.example.com","description":"Production"},{"url":"https://sandbox.api.example.com","description":"Sandbox"}] [/nahnu_code_block]
reference
New in 1.0.2

Every block, outside the block editor too

A shortcode for a widget or page builder, or a template tag for a theme file. Both render exactly the same block, with the same theming, as if it were placed in the block editor.

  • Attributes pass straight through: block="endpoint" method="POST"
  • Per-instance color overrides, e.g. accentColor="#ff5500", without touching the site-wide palette
Widget / page builder / classic editor
[nahnu_code_block block="endpoint" method="POST" path="/v1/invoices"]

// with a one-off accent color:
[nahnu_code_block block="endpoint" method="POST"
  path="/v1/invoices" accentColor="#ff5500"]
theme-template.php
nahnu_code_block_the( 'endpoint', [
    'method' => 'POST',
    'path'   => '/v1/invoices',
] );
Developer reference

Block slugs, for hand-authoring or the build API

Every slug below works with nahnu_code_block_build_block_markup(), no nahnu-code-block/ prefix needed.

BlockSlugCategoryKey attributes
Code Blockcode-blockCodelanguage, code, lineNumbers
EndpointendpointAPI referencemethod, path, summary, deprecated
ParametersparametersAPI referenceparameters[]
Request / Responserequest-responseAPI referenceexamples[]
Response Bodyresponse-bodyAPI referencereturns, headers[], responses[]
Status Codesstatus-codesAPI referencecodes[]
AuthenticationauthAPI referencescheme, headerName
Try It Consoletry-itInteractivemethod, url, headers[]
Error Codeserror-codesSupportingerrors[]
EventseventsSupportingevents[]
API Navigationapi-navigationSupporting(auto-scanned, no attributes)
ServersserversSupportingservers[]

Start with the blocks you need today

Add one, or all twelve. Every block works on its own.

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