Skip to content

Directives

Directives are special instructions that control Sendpad behavior. There are two kinds:

  • File-level directives@key = value at the top of the file (before the first ###)
  • Request-level directives# @directive comment lines after the request (or after the body)
DirectiveFile typesDescription
@key = value.http .flow .wsDefine a file-scoped variable
# @cookies off.http .flow .wsDisable cookie jar for this entire file
# @format offanyDisable format-on-save for this file
DirectiveDescription
# @name <id>Name a step for use in flow reporting
# @skipSkip this request step entirely
# @retry <n>Retry this step up to N times on failure
DirectiveDescription
# @extract <var> = <jsonpath>Extract a value from the response body using JSONPath
# @extract event <var> = <name>Extract the last payload of a named SSE event
# @extract userId = $.id
# @extract first = $.users[0].name
# @extract token = $.auth.access_token
# @extract event completion = completion # SSE
DirectiveDescription
# @assert status == <code>Assert HTTP status code equals
# @assert status != <code>Assert status does not equal
# @assert status >= <n>Assert status is at least
# @assert status < <n>Assert status is less than
# @assert body contains <text>Assert response body contains substring
# @assert body equals <value>Assert response body exactly equals (both sides trimmed)
# @assert body matches <regex>Assert response body matches regex
# @assert header[<name>] contains <text>Assert a response header value
# @assert status == 201
# @assert body contains "success" # substring — passes if "success" appears anywhere
# @assert body equals OK # exact match — passes only if body is exactly "OK"
# @assert body equals {{expected}} # variables are resolved before comparing
# @assert body matches ^\{
# @assert header[content-type] contains json

body equals trims whitespace from both sides before comparing. Use it for simple response values (OK, true, null) or a full body captured in a variable.

Override global timeout, SSL, redirect, and proxy settings for a single request. These directives take precedence over the Settings panel for that request only.

DirectiveDescription
# @timeout <duration>Override request timeout. Duration: 500ms, 5s, 1.5s, 2m, 1h
# @no-verifySkip SSL certificate verification for this request
# @verify-ssl on|offExplicitly enable or disable SSL verification
# @follow-redirects on|offEnable or disable redirect following
# @proxy <url>Route this request through a specific HTTP/S proxy
### Fast liveness check
# @timeout 3s
GET {{baseUrl}}/health
### Internal service — self-signed cert
# @no-verify
GET https://internal.corp/metrics
### Capture redirect location without following
# @follow-redirects off
GET {{baseUrl}}/auth/login
### Via corporate proxy
# @proxy http://proxy.corp.local:8080
POST {{baseUrl}}/api/data
DirectiveDescription
# @persist <var>Write an extracted variable to <env>.env.local
# @persist <KEY> = <value>Write a literal value to <env>.env.local
DirectiveDescription
# @file <field> = <path>Attach a file as a multipart field
# @field <name> = <value>Add a plain-text multipart field
# @body = <path>Use a file as the raw request body
DirectiveDescriptionTier
KEY = valuePlain variableFree
@extends <path>Inherit from another .env; later extends + overrides in the current file winPro

Sensitive values live in <name>.env.local (auto-gitignored). Sendpad auto-masks variables whose name matches token/secret/key/password/auth, or that appear only in .env.local. No directive needed.

See .env reference.

SSE applies to any .http / .flow request whose response is Content-Type: text/event-stream (auto-detected).

DirectiveDescription
# @expect event <name>Require an SSE event of this type
# @expect event <name> within <ms>Require the event within a timeout
# @extract event <var> = <name>Capture the last payload of the named event
# @sse-timeout <ms>Override the default stream timeout
# @sse-reconnect on|offAuto-reconnect on disconnect (default: off)
DirectiveDescription
@broker = <mqtt-url>Broker URL (required) — mqtt://, mqtts://, ws://, wss://
@client-id = <id>Optional client ID (default: auto-generated)
@username = <u>Optional username
@password = <p>Optional password — reference {{VAR}} from .env.local for real credentials
@clean-session on|offSession handling (default: on)
@keepalive <seconds>Keepalive interval
DirectiveDescription
# @subscribe <topic>Subscribe to a topic
# @publish <topic>Publish to a topic; body follows
# @qos 0|1|2Quality-of-service for the next publish/subscribe
# @retain on|offRetain flag on the next publish
# @expect within <ms>Timeout for the next received message
# @assert body contains <text>Assert on received payload

See the .mqtt reference.

DirectiveDescription
@port <n>Bind the mock server to a port
@base-path <path>Prefix all routes with this path
@cors <origin>CORS allow-origin for all routes
@forward <upstream>Forward non-matching requests to an upstream URL
@delay <ms>Default delay for every matched response
DirectiveDescription
### METHOD <path>Declare a route — e.g. ### GET /users/:id
# @match <expression>Additional match condition (query, header, body)
# @status <code>Response status
# @header <name>: <value>Response header
# @delay <ms>Response delay
# @repeat <n>Response returned only first N requests
# @template <var>Declare a dynamic template variable for the body

See the .mock reference.

DirectiveDescription
@url = <wss-url>WebSocket URL (required)
@headersBegin connection headers — one header per line, indented
@protocol = <name>Sec-WebSocket-Protocol value
@reconnect on|offAuto-reconnect on disconnect (default: off)
@timeout = <ms>Connection timeout in milliseconds
DirectiveDescription
# @name <label>Name this message step
# @expect within <ms>Timeout for the next < receive (default: 5000ms)
# @extract <var> = <jsonpath>Extract from received message
# @assert body contains <text>Assert received message content
# @assert body matches <regex>Regex assertion on received message
# @close [code] ["reason"]Send a WebSocket close frame
# @binary <path>Send a binary frame from a file
# @pause <ms>Wait before the next step