Skip to content

Directives

A directive is a comment line starting with # @ (or // @), written above a request’s request line. Other tools treat Reqjet’s own directives (@reqjet.…) as plain comments, so files stay portable.

In the .http editor, Ctrl+Space after # @ lists them.

Directive What it does
# @name <name> Names the request, for chaining ({{name.response.body.$.id}}), for send("name") in scripts, and for snapshots.
# @prompt <name> [description] Asks for {{name}} each time the request is sent. Names such as password or token are masked.
# @timeout <seconds> How long to wait for the response.
# @connection-timeout <seconds> How long to wait to connect, separately from @timeout.
# @no-redirect Don’t follow redirects.
# @no-cookie-jar Don’t send or store cookies.
# @no-log Don’t keep the responses in History, for example because they hold tokens.
# @no-auto-encoding Send the URL exactly as written, without encoding it.
Directive What it does
# @reqjet.assert <subject> <operator> [value] A test on the response, for example status == 200.
# @reqjet.snapshot [ignore <paths>] Compares the response with its saved snapshot. ignore lists JSONPaths that change on every call.

Subjects: status, time (milliseconds), size (bytes), contentType, body, body.$.json.path (with [0], [*] and ['odd key']), and header.Name.

Operators: ==, !=, <, <=, >, >=, contains, not contains (or !contains), startsWith, endsWith, matches (a regular expression), exists, not exists (or !exists). {{variables}} in the value are filled in. Quotes around the value are optional: == "Rex" and == Rex are the same.

### Get a pet
# @reqjet.assert status == 200
# @reqjet.assert time < 500
# @reqjet.assert body.$.name == "Rex"
# @reqjet.assert header.Content-Type contains json
# @reqjet.snapshot ignore $.updatedAt $.owners[*].lastSeen
GET {{baseUrl}}/pets/7

These go in the file’s header, before its first ###, and apply to every request in the file.

Directive What it does
# @reqjet.openapi <file> Checks every response against an OpenAPI description (JSON or YAML, OpenAPI 3 or Swagger 2).
# @reqjet.data <file> Run all goes through the requests once per row of a CSV or JSON file, with the row’s values as {{variables}}.
# @reqjet.pre-request <file.js> Runs a script before every request in the file.

These go in a runbook’s ```http blocks.

Directive What it does
# @reqjet.capture <name> = <subject> Keeps a value from the response as {{name}} for later steps. The subject is as for @reqjet.assert.
# @reqjet.confirm <message> Asks before the step runs.
# @reqjet.until <assertion> Repeats the request until the assertion holds, for jobs you have to wait for.
# @reqjet.fail-if <assertion> Stops repeating straight away when the assertion holds, for example on a “Failed” status.
# @reqjet.every <time> How often to repeat, such as 30s. The default is 10s.
# @reqjet.give-up-after <time> When to stop repeating, such as 2h. The default is 30m.