HTTP requests
Open a .http or .rest file, put the caret in a request and press
⌘↩ (Run › Send Request). The response opens in its
own tab.
The format is the one JetBrains’ HTTP client and the VS Code REST Client read, so a request file works in three editors, and Postman or Insomnia exports convert to it.
A request file
Section titled “A request file”@host = https://api.example.com
### List usersGET {{host}}/usersAuthorization: Bearer {{token}}
### Create one# @name createPOST {{host}}/usersContent-Type: application/json
{"name": "Ada"}The format
Section titled “The format”- Blocks are separated by lines starting with
###. Text after the###names the request. - Inside a block: comment lines (
#or//), then the request line, then headers until a blank line, then the body. - The body can come from a file instead:
< ./file.json. # @name createnames a request explicitly.
Variables and environments
Section titled “Variables and environments”@name = value lines outside a request define variables, used as
{{name}}. Everything else comes from environment files beside the request
file or in a parent folder:
Directoryapi/
- http-client.env.json shared values, safe to commit
- http-client.private.env.json secrets, keep out of Git
- users.http
Both files are keyed by environment name:
{ "dev": { "host": "http://localhost:8080" }, "prod": { "host": "https://api.example.com" }}# @env prod in the request file picks the environment; otherwise the first
one in the file is used. A variable that is defined nowhere is reported by
name, with where to define it.