Testing APIs
Environments and variables
Write {{name}} in a request and switch between Dev, UAT, and Prod without editing it. Keep secrets out of files.
Variables
Anywhere in a request — the URL, params, headers, body, or auth — you can write {{name}}. When you send, the app replaces it with a value. For example:
{{baseUrl}}/orders?status={{status}}
Authorization: Bearer {{token}}
If a variable has no value, the request is not sent; a warning next to the environment picker (on the right of the tabs) says which ones are missing, like {{baseUrl}} — point at it for not defined in UAT. A typo never reaches your API.
You don't need to remember the names. Type {{ in the URL, a param or header value, an auth field or the body, and a list shows every variable this request can use, grouped by where it comes from — Connections (with their address), Folder, Environment (secret values shown as dots), Saved values and Built-in — filtered as you keep typing. ↑ ↓ to choose, Enter or Tab to put it in, Esc to close.
A variable's value can use other variables: baseUrl = https://{{host}}/v2, or {{practiceApi}} to start with the practice API. They're filled in before the request goes — on Send, in collection runs, performance tests and on the command line.
Environments
An environment is a named set of values — Dev, UAT, Prod. Pick one in the Environment picker on the right of the request tabs; every request uses its values. None (Only built-in variables) uses no environment — only built-in ones like {{practiceApi}}.
- Open the environment picker (on the right of the tabs) and choose New environment… — or Manage environments… to change the ones you have.
- Click New environment, type its name over the suggested one, and fill in its variables (
baseUrl=https://api.example.com). Add variable adds a row. - Tick secret for tokens and passwords. The value is then hidden; the eye button shows it.
- Press Save environments.
In Manage environments:
- Duplicate copies the selected environment with all its values, as UAT copy — handy for a new server with the same variables.
- Delete removes the selected environment.
- × at the end of a row removes that variable.
- Nothing changes until you press Save environments. Cancel (or Escape) closes without saving; if you changed something, it asks first.
Variable names use letters, digits, _, . and -, start with a letter or _, and must be different within an environment — baseUrl, auth.token, api-key. A name that breaks these rules turns red, and that row is left out when you save.
Environments are saved in environments.json in your data folder.
Secret values are encrypted with a key that your operating system protects (Windows DPAPI, macOS Keychain, Linux keyring). They are never written into the environment file or any export. Without a keyring — and in npx apitestcenter ui — they are kept in memory only, until the app stops; see Secrets.
Choosing a base URL
Keep each server's address in an environment variable — baseUrl = https://gateway.example.com — and type only the path in the request bar: /orders/42. A Base URL picker appears between the method and the URL, listing every variable in the chosen environment whose value is a web address. Pick one, and the request becomes {{baseUrl}}/orders/42; the box then shows just the path. Switch the environment (UAT, Prod) and the same request goes to the other server.
To go back to a full address, choose No base URL in the picker, or paste an https://… address over the path.
The picker has groups that open and close in place:
- Connections — every connection; pick one and the request goes to it with its sign-in.
- The environment in use (UAT, say) — its web-address variables. switch next to its name opens the environment picker.
- Localhost — web servers running on your computer right now, each with its program and
httporhttps(localhost:5176 · Orders.Api · http), then ports you used before. Choose Another port… to type one; clickhttpto switch it tohttps.
Only the group you're using starts open.
To find running servers, the app asks your operating system which ports are open, then checks which of them answer like a web server. Background services (VPN agents, databases, system services) are left out. The check runs each time you open the picker, takes about a second, and stays on your computer. self-signed means the server's certificate isn't one the app trusts. To send to it, turn on skipping the certificate check in the request's Settings tab.
An environment can hold as many base URLs as you need — baseUrl, authUrl, paymentsUrl — each a variable whose value is a web address. The practice API's {{practiceApi}} is left out of the picker unless the request already uses it.
Save an address as a base URL
Typed a full address and pressed Send? A link under the URL offers **Save host as a base URL**. It asks for:
- Address — the server only (
https://gateway.example.com), or the server plus the first part of the path (https://gateway.example.com/v2); - Environment — the one in use, another, or a new one;
- Variable name —
baseUrl, or a name taken from the host whenbaseUrlis already used. If that name exists with another value, you are told it will be replaced.
The request becomes {{baseUrl}}/the/path. When other saved requests use the same address, tick **Also switch N other saved requests that use this address** (it lists the first few) to update those too. Requests with a secret that isn't available on this computer are left as they were, so nothing is lost. Save the current request to keep its change.
Built-in: {{practiceApi}}
{{practiceApi}} always points at the practice API inside the app, whatever port it is on. It is there so the examples work without setup.
Built-in values: {{$uuid}}, {{$timestamp}}, …
Values the app makes for you — a new one for every request, in a performance test too, so each simulated user sends its own id. They work in the URL, params, headers, body and auth, with or without an environment. Manage → Built-in values lists them with a copy button.
| Value | Gives |
|---|---|
{{$uuid}} (or {{$guid}}) | A random UUID, e.g. 3f2b8c1e-7a4d-4e2b-9c1f-5d6a7b8c9d0e |
{{$timestamp}} | Now, in seconds since 1970 (Unix time) |
{{$timestampMs}} | Now, in milliseconds |
{{$isoTimestamp}} | Now, as 2026-10-19T09:30:00.000Z (UTC) |
{{$isoDate}} | Today, as 2026-10-19 (UTC) |
{{$randomInt}} | A whole number from 0 to 1000; {{$randomInt(1,100)}} picks between the two numbers, both included |
{{$randomString}} | 8 letters and digits; {{$randomString(20)}} for 20 |
{{$randomEmail}} | An address at example.com, e.g. user.k3x9q2ma@example.com |
{{$randomFirstName}} · {{$randomLastName}} · {{$randomFullName}} | A name, e.g. Maria Okafor |
{{$randomBoolean}} | true or false |
Business test data
Made-up values that look like the real thing, for creating customers, employees, orders and invoices in a test system:
| Value | Gives |
|---|---|
{{$randomCompany}} | A company, e.g. Contoso Logistics GmbH |
{{$randomStreet}} · {{$randomPostalCode}} · {{$randomCity}} · {{$randomCountryCode}} | An address: 42 Station Road, 80331, Munich, DE (ISO 3166) |
{{$randomPhone}} | A number in the range kept for fiction, e.g. +1 555 0142 |
{{$randomIban}} | An IBAN with correct check digits: German by default, {{$randomIban(GB)}} or {{$randomIban(NL)}}. It passes format checks, but it's made up, not a bank's |
{{$randomEmployeeId}} · {{$randomCostCenter}} | E20417 · CC-4217 |
{{$randomPoNumber}} · {{$randomInvoiceNumber}} · {{$randomSku}} | PO-2026-004512 · INV-2026-01873 · SKU-30417 |
{{$randomAmount}} | Money with two decimals, 10 to 1000; {{$randomAmount(50,250)}} between the two |
{{$randomCurrency}} | EUR, USD, GBP, INR or CHF |
{{$randomJobTitle}} · {{$randomDepartment}} | Payroll Specialist · Finance |
{{$date}} | Today; {{$date(30)}} 30 days from now, {{$date(-7)}} a week ago |
{{$randomDate}} | A day in the past year; {{$randomDate(-30,30)}} between those days from today |
Dates come as 2026-01-31 unless you add a format last: us gives 1/31/2026 (NetSuite), eu gives 31.01.2026, sap gives /Date(1769817600000)/ (SAP OData v2) and datetime the full 2026-01-31T00:00:00.000Z. For example {{$date(30,us)}} or {{$randomDate(-365,0,sap)}}.
Each place a value appears gets its own: {{$uuid}} twice in one request gives two different ids. To use the same one twice, make it once in a Run first request and save it. In a JSON body, put a value in quotes — "id": "{{$uuid}}" — it is filled in as text.
Values saved from answers
A request can save values from its answer — the id of a new order, say — as {{orderId}} for the requests after it. After a Send, saved values appear next to the environment picker as Saved from answers: {{orderId}}, with Clear. They last until you close the app, and they win over an environment variable with the same name because they are newer. See Chaining.
Which value wins
From lowest to highest:
- Folder variables — an inner folder's win over an outer folder's
{{practiceApi}}(built in)- The chosen environment
- Values saved from answers (Send) — or, in a collection run, values saved earlier in that run
- Values filled while a test runs: Run first and Test data
On the command line, --var name=value sets or overrides a value — the way to pass CI secrets. See Command line and CI.