Skip to content

Request chaining

Request chaining lets one request use a value from another request’s response, such as a token from a login request. Courier uses the VS Code REST Client and httpyac syntax.

Reference a request by its # @name. Set it in the @ field next to the request tabs. A request with no name is referenced by its file name.

### Log in
# @name login
POST {{baseUrl}}/v1/auth/login
### Who am I
# @name me
GET {{baseUrl}}/v1/me
Authorization: Bearer {{login.response.body.$.access_token}}
Reference Value
{{login.response.body.$.user.id}} JSONPath into the response body: $.a.b, [0], [*], ['odd key']
{{login.response.body.*}} The whole response body
{{login.response.headers.X-Token}} A response header, matched in any case
{{login.response.status}} The status code
{{login.request.body.$.email}} The request body as it was sent
{{login.request.headers.Name}} A request header as it was sent
{{login.request.url}} The URL as it was sent

Right-click a value in a JSON response → Copy as reference and paste it.

Hover a reference to see its value and which run it came from.

Values come from the newest stored run of that request in this folder. By default, if the request has never run, Courier sends it first.

Change this in Settings → Requests → Run referenced requests first: When it has no stored response (the default), Every time, or Never (use the last response).

You can also declare dependencies in the file:

  • # @ref login runs login first when needed, even if nothing references it.
  • # @forceRef login runs login every time.

Courier catches loops, such as two requests referencing each other, and reports them.

courier run runs referenced requests first, once per run. # @forceRef runs every time.