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

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

ToolImport syntaxPlainwire reads it
httpYac# @import ./file.httpYes
JetBrains HTTP Clientimport ./file.httpYes
JetBrains HTTP Clientrun #login, run ./file.httpKept in the file, not run. Chain with {{login.response...}} instead.
REST ClientnoneREST 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.