Syntax Cheatsheet
Use this page as the fast authoring reference before you move into the full Language Reference.
Collection shape
name = Example Collection
$ API_ORIGIN = https://api.example.com
$ USER_ID = [[ user_id ]]
---
Get user
GET {{ API_ORIGIN }}/users/{{ USER_ID }}
^ & status == 200
& body.id -> $FETCHED_USER_ID
- The preamble goes before the first
--- - Each request block starts after
--- - Request titles are used in output and dependencies
Variables and prompts
$ API_ORIGIN = https://api.example.com
$ TOKEN = $(./get_token.sh)
$ API_KEY = secret.env("HEN_API_KEY")
$ USER_ID = [[ user_id ]]
$ REGION = [[ region = us-east-1 ]]
$ USER = [alice,bob]
$ NAME = valuedefines a reusable scalar[[ name ]]prompts for a value[[ name = default ]]prompts with a default[a,b]maps a request across multiple values
Request target
GET https://example.com/users/123
POST {{ API_ORIGIN }}/users
The request line is usually METHOD URL.
Headers, query params, and form fields
* Authorization = Bearer {{ API_KEY }}
? page = 1
~ avatar = @./avatar.png
~ role = admin
*adds a header?adds a query parameter~adds a multipart form field
Body blocks
~~~json
{"id":"123"}
~~~
~~~ application/json
{
"username": "[[ username ]]"
}
~~~
Use ~~~ to start and end the request body.
Assertions
^ & status == 200
^ & body.user.id == "123"
^ & body.total === NUMBER
^ & body.message ~= "ok"
^starts an assertion==and!=compare values~=does structural or partial matching===validates against a schema target
Captures
& body.user.id -> $USER_ID
& header.content_type -> $CONTENT_TYPE
& status -> $STATUS
Captures export response values for later requests.
Dependencies
> requires: Login
Use dependencies when one request must run before another.
Sessions and environments
session = web
env local
$ API_ORIGIN = http://localhost:3000
session = ...reuses runtime state like cookies or protocol sessionsenv ...defines named scalar overrides in the preamble
Common commands
hen verify ./collection.hen
hen run ./collection.hen 0
hen run ./collection.hen all --non-interactive
hen inspect ./collection.hen --output json