Use environments and variables
此内容尚不支持你的语言。
A request names values as {{name}}. They come from the file itself, from an environment file next
to it, or from what a response handler script stored. Environments with a private file:
Works.
Use a variable
Section titled “Use a variable”@host = https://api.example.com@limit = 10
GET {{host}}/products?limit={{limit}}Authorization: Bearer {{token}}Each {{name}} is resolved in this order: variables of the file (@name = value; a later
definition wins), then the chosen environment, then the globals that response handler scripts set.
Variables may use other variables, and spaces inside the braces are allowed: {{ host }}.
A request with an unresolved name is never sent, whichever way you run it. Output lists the
names that have no value, including an unclosed {{.
Generate values
Section titled “Generate values”These names produce a new value on every use (unless the file or environment defines the same name):
| Variable | Value |
|---|---|
{{$uuid}}, {{$random.uuid}} |
a random UUID (version 4) |
{{$timestamp}} |
the Unix time in seconds |
{{$isoTimestamp}} |
the time in UTC, such as 2026-12-04T09:30:00Z |
{{$randomInt}} |
a whole number from 0 to 1000 |
{{$random.integer(from, to)}} |
a whole number from from up to, not including, to; without arguments 0 to 999 |
{{$random.float(from, to)}} |
a decimal number from from up to, not including, to; without arguments 0 to under 1000 |
{{$random.alphabetic(n)}} |
n letters |
{{$random.alphanumeric(n)}} |
n letters, digits and _ |
{{$random.hexadecimal(n)}} |
n hexadecimal digits |
{{$random.email}} |
a random address at example.com |
n is 1 to 10,000. Arguments that do not fit, such as from not below to, leave the name
unresolved, so the request is not sent.
Define environments
Section titled “Define environments”Put http-client.env.json next to the .http file or in a folder above it, up to the project
root. Each top-level key is an environment:
{ "$shared": { "version": "v2" }, "local": { "host": "http://localhost:8080" }, "staging": { "host": "https://staging.example.com" }}$sharedapplies to every environment unless the environment defines the same name.- Strings, numbers and booleans become values; nested objects are skipped.
- The nearest folder that has an environment file wins.
Keep secrets in the private file
Section titled “Keep secrets in the private file”Put tokens and passwords in http-client.private.env.json beside it, with the same shape:
{ "local": { "token": "local-dev-token" }, "staging": { "token": "…" }}Private values win over shared ones. They are sent to the server and shown to you, but never
written to a file by Ferris IDEA, and the agent log shows {{token}} in their place.
Choose an environment
Section titled “Choose an environment”When the files define one environment, it is used. With several, choose one:
- Send a request from the file (or open the Services tool window).
- Click Env: none ▾ in the Services window. The HTTP environment list opens.
- Click the environment. The choice holds for that
.httpfile until you close the window; choosing sends nothing.
Until you choose, a request that needs an environment variable is not sent, and the status bar and Output say “Not sent: choose an HTTP environment: local, staging”. A request that uses no environment variable goes without one. Run All asks once for the whole file.
For agents
Section titled “For agents”Agents pass environment to the tools. Without the right secret-read, private values are masked
as {{name}} in what the tools return and listed under masked, and the private file cannot be
read. With several environments and none given, a call is refused with the names the files define.
http_requestsRequests of a.httpfile: name, line, method, URL, headers and body with variables resolved from the file, the environment ofhttp-client.env.json/http-client.private.env.jsonandenv, plus unresolved names,settings(# @no-redirect,# @timeout N),body_files(not read),noteson parts never sent, andscript: the response handler withstatusneeds approval(only a person approves it, in the window),approvedorrefused.send_http_requestSend one request of a.httpfile.
No tool matches. Try fewer words, or .