Guide

Requests

A request is a method, an address, and what you expect back. One file holds as many as you like, each started by a line beginning with ###. This is the thing you will write most, so it is worth five minutes.

Here is one, whole. Put it in posts.stamp.

### List posts
GET https://jsonplaceholder.typicode.com/posts?_limit=3

> assert status == 200
> assert body.length == 3
> assert body[0].title != null

Four parts, read top to bottom.

### List postsStarts a request and titles it. The title becomes its name, listPosts, which is how other requests and the command line ask for it.
GET https://…The method and the address. A line beginning http://, https:// or {{ is taken as a GET, so the method can be left off.
the blank lineEnds the head of the request. Headers go above it, the body below.
> assert …Runs when the answer arrives. A script line can read status, body, headers, time and size.
stamp run posts.stamp

→ GET https://jsonplaceholder.typicode.com/posts?_limit=3  posts.stamp › listPosts
  200 OK  61 ms  897 bytes
  ✓ status == 200
  ✓ body.length == 3
  ✓ body[0].title != null

✓ 1 request, 3 assertions

What comes back is reported in the same order every time: the status, the time and the size, then one line per check. A check that fails is marked with a ✗ and the value found in its place, and on the command line that is what makes the exit code 1.

Seeing what came back

That summary is what a pipeline needs. When you want the response itself, add --verbose: it prints the headers and body it sent, then every response header, then the body, above the lines you already know.

stamp run posts.stamp --verbose

→ GET https://jsonplaceholder.typicode.com/posts?_limit=3  posts.stamp › listPosts
  200 OK  54 ms  897 bytes
  Cache-Control: max-age=43200
  Content-Type: application/json; charset=utf-8
  Etag: W/"381-oHCFPDbKuZj7PWOE7Pi1OYchMYY"
  x-total-count: 100
  …
  [
    {
      "userId": 1,
      "id": 1,
      "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
      "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum…"
    }
  ]
  ✓ status == 200
  ✓ body.length == 3
  ✓ body[0].title != null

✓ 1 request, 3 assertions

The headers and the posts are cut short above; a real run prints all of them. Three things take the place of scrolling through it:

-o posts.jsonwrites the last response body to a file, or into a folder, and says how many bytes it wrote
> print body[0].titleprints one value with the checks, which beats reading a whole body to find it
stamp run . -qleaves out the lines for checks that held

The exit code is 0 when every check held and 1 when one did not, and 2 when a file could not be parsed, which is the whole of what Running in CI needs.

Sending something. The same shape with two more parts: headers, then a blank line, then the body. Add this to the same file, under the first request.

### Create an order
POST https://jsonplaceholder.typicode.com/posts
Content-Type: application/json

{ "title": "Two boxes of tea", "userId": 1 }

> assert status == 201
> assert body.title == "Two boxes of tea"
> set orderId = body.id
stamp run posts.stamp createAnOrder

→ POST https://jsonplaceholder.typicode.com/posts  posts.stamp › createAnOrder
  201 Created  177 ms  61 bytes
  ✓ status == 201
  ✓ body.title == "Two boxes of tea"

✓ 1 request, 2 assertions

Content-Type is a header like any other. A body that opens with { or [ is sent as JSON even when the header is missing, but writing the header leaves less to guess at. The last line, set orderId = body.id, keeps the new id for everything that runs after it.

One request using another. Most APIs want you signed in first. set puts a value in the session, @needs makes sure the request that produced it has run, and @auth turns the value into the header. A new file, account.stamp:

@baseUrl = https://dummyjson.com

### Log in
POST {{baseUrl}}/auth/login
Content-Type: application/json

{ "username": "emilys", "password": "emilyspass" }

> assert status == 200
> set token = body.accessToken

### My carts
@needs logIn
@auth bearer {{token}}
GET {{baseUrl}}/carts/user/{{logIn.body.id}}

> assert status == 200
> print "carts: " + body.carts.length
@baseUrl = …Written above the first ###, so it belongs to the file and every request below can use it.
@needs logInRuns logIn first if it has not run yet in this session, so asking for the second request alone still works.
@auth bearer {{token}}Writes the Authorization header. There are forms for basic, JWT, API keys and OAuth 2 too. Above the first ### it covers every request in the file, and a request can still override it.
{{logIn.body.id}}A request that has already run can be read by its name. Its body, headers and status are all there.
stamp run account.stamp myCarts

→ POST https://dummyjson.com/auth/login  account.stamp › logIn
  200 OK  106 ms  930 bytes
  ✓ status == 200

→ GET https://dummyjson.com/carts/user/1  account.stamp › myCarts
  200 OK  57 ms  1 KB
  ✓ status == 200
  │ carts: 1

✓ 2 requests, 2 assertions

Asking for myCarts alone still logs in first, because @needs says so. What print writes goes to the console, on a line of its own.

That is a request. What follows is the rest of the shape, for when you meet it. Nothing here is needed to send your first one.

The order of the parts is fixed. The parser reads them in this order and will not take them in another.

1variables and directives, the lines starting with @ or let
2the request line
3headers
4a blank line, then the body
5the > script lines

All five at once:

### Create an order
@name createOrder
@timeout 10s
POST https://jsonplaceholder.typicode.com/posts
Content-Type: application/json
Accept-Language: en-GB
# X-Debug: 1

{ "title": "{{fake.product}}", "userId": {{randomInt(1, 10)}} }

> assert status == 201
> assert body.id != null, "the new order has no id"
> set orderId = body.id
  • @name createOrder names the request when the title is not the name you want. A request with no title at all is named after its file.
  • @timeout 10s replaces the default of 30 seconds. @no-redirect stops it following a 301, and @insecure accepts a certificate that does not check out.
  • A commented header is kept, switched off. Accept-Language is sent; X-Debug is not, and it stays in the file instead of being deleted and retyped.
  • An assertion can carry a message after a comma, which is what gets printed when it fails.
  • {{fake.product}} and {{randomInt(1, 10)}} fill the body with plausible data. Add @seed = orders at the top of the file and the same values come back on every run.

A body can come from a file instead. One line, < ./bodies/order.json, and the path is read relative to the .stamp file.

### Create an order from a file
POST https://jsonplaceholder.typicode.com/posts
Content-Type: application/json

< ./bodies/order.json

With a form content type the body is name = value lines. In a multipart form, photo = < ./beach.jpg attaches a file.

### Sign up
POST https://httpbingo.org/post
Content-Type: application/x-www-form-urlencoded

email = {{fake.email}}
plan = standard

> assert body.form.plan contains "standard"

A file holding a single request needs no ### line at all, which is what makes a one-line .http file valid.

The request line takes more than the HTTP methods. GRAPHQL sends the body as an operation, WS opens a WebSocket and the script talks over it, STUN and TURN check the ICE servers a call depends on, and MCP connects to a Model Context Protocol server. They are in WebSockets, GraphQL and WebRTC and MCP servers.

stamp run .                             # every request in every file
stamp run posts.stamp createOrder       # one by name, with whatever it needs
stamp run . --verbose                   # response headers and bodies too
stamp run . -o response.json            # save the last body

In the app

Nothing above has to be typed as text. Press ⌘N for a new request and build the same thing in the window.

  1. Name it. The title at the top is a field: what you write there becomes the ### line, and the name @needs and a plan's run use. List posts becomes listPosts.
  2. Set the method and the address in the capsule below it. The bold word on its left is a menu: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS and GRAPHQL in the first group, then WS, then STUN and TURN, then MCP. Type the address beside it, {{ }} and all. The line underneath shows that address with the variables filled in, so a name you got wrong is visible before anything is sent.
  3. Add what the request carries, one tab at a time.
    • Params is the query string as rows. Adding _limit and 3 writes ?_limit=3 onto the address, and editing the address writes rows back.
    • Headers is the same for header lines, with a tick beside each one: turning it off comments the line out rather than losing it.
    • Body is an editor with the content type named under it and Format JSON beside that, for the body you pasted from somewhere else.
    • Auth writes the @auth line, which is Authentication, and Tests holds the > lines, which is Scripts and assertions.
    The number on a tab counts what is in it, so Headers 2 and Tests 3 say where the request keeps its weight.
  4. Press ⌘↩ to send, ⌥⌘↩ for Run All in File, ⌘. to stop. The answer opens under the request that asked for it and stays there while you change something and send again.
  5. Switch the picker in the toolbar from Form to Source when you want the text. It is the same file: the form is a reading of it, not a second copy, so a change in either shows up in the other. Anything with no row of its own, @timeout 10s or @needs, is written there.

The form is where a request is built and Source is where it is read, which is also what makes a request reviewable: a colleague sees the lines you changed, not a screenshot of a form.

A request: the method, the address, Send, and the form view with its Params, Headers, Auth, Body and Tests tabs
A request: the method, the address, Send, and the form view with its Params, Headers, Auth, Body and Tests tabs

Next: Scripts and assertions for everything the > lines can do, Variables and dimensions for pointing the same request at staging, and Authentication for the rest of the @auth forms.

Updated

Back: Workspaces Next: Bringing collections in