Share variables and a login between .http files
Once a project has more than one .http file, every file starts with the same lines: the base URL, a content type, and a login request whose token the other requests use. Copying them into each file means fixing them in each file. With Plainwire you write them once and add one line to every other file:
# @import ./shared/auth.http
The importing file can then use the shared file’s variables and chain to its named requests. This works in the editor (Send, Run all, Copy as Code) and in the command-line runner, so CI runs the files the same way. Importing another file is the most-reacted open request for REST Client (issue #182, 84 reactions when we read it on 20 November 2026).
A complete example
The shared file holds the variables and the login:
# shared/auth.http
@contentType = application/json
@user = ada@example.com
### Log in
# @name login
POST {{baseUrl}}/auth/login
Content-Type: {{contentType}}
{ "email": "{{user}}", "password": "{{password}}" }
Every other file imports it and uses the token:
# orders/orders.http
# @import ../shared/auth.http
### List orders
# @assert status == 200
GET {{baseUrl}}/orders
Authorization: Bearer {{login.response.body.$.token}}
### Create an order
POST {{baseUrl}}/orders
Authorization: Bearer {{login.response.body.$.token}}
Content-Type: {{contentType}}
{ "sku": "A-1", "qty": 2 }
baseUrl and password come from your environment (http-client.env.json, with the password in http-client.private.env.json so it stays out of git). When you send List orders, Plainwire sees that it needs login, finds it in the imported file, sends it first, and then sends your request with the token. The second request reuses the same token: the login is sent once per session, not once per request.
The rules
- Syntax.
# @import ./path.httpor// @import ./path.http(the httpYac form), orimport ./path.http(the JetBrains HTTP Client form). Quotes around the path are allowed. Put imports at the top of the file. - Paths are relative to the file that contains the import line, or absolute. In VS Code, Ctrl+click (Cmd+click on macOS) the path to open the file.
- Imported variables are available everywhere in the importing file. If both files define the same variable, the importing file wins. Between two imports, the later import wins.
- Imported named requests can be chained with
{{name.response.body.$.path}}. A request in your own file wins over one with the same name in an import. The imported request is sent with its own file’s variables, so a shared login always logs in the same way, whoever imports it. - Nested imports work: a shared file can import another one. A file imported twice, or two files that import each other, are read once.
- A missing file is an error on each request of the importing file, naming the import line and the file, for example
Cannot import ./gone.http from orders.http. - Sessions. Run all starts with a fresh session, and the CLI keeps one session per file, so each file you run sends the login once. In the editor, the token is kept until you run the file again with Run all or reload the window.
In CI
The plainwire CLI follows imports the same way, so a pull request check needs nothing extra:
plainwire run orders/ --env ci --junit results.xml
The shared file is a normal .http file too. If you run a whole folder that contains it, its own requests run as well; keep it outside the folder you run, or add # @skip above requests that should only run when imported.
Compatibility
| Tool | Import syntax | Plainwire reads it |
|---|---|---|
| httpYac | # @import ./file.http | Yes |
| JetBrains HTTP Client | import ./file.http | Yes |
| JetBrains HTTP Client | run #login, run ./file.http | Kept in the file, not run. Chain with {{login.response...}} instead. |
| REST Client | none | REST Client ignores # @import lines as comments, so files with imports still open there (without the shared variables). |
FAQ
Can I import only the variables?
Yes. A file with only @name = value lines and no requests is a fine thing to import. It appears in the Plainwire sidebar as a file with no requests.
Does the online converter follow imports?
No. The .http to cURL converter runs in your browser with one file at a time, so variables from imported files are reported as unresolved. Copy as Code inside the editor resolves them.
Is it free?
Yes. Plainwire is MIT-licensed, needs no account and sends nothing except your requests. Install the .vsix from the latest release; see the home page for steps.