Appearance
Variables
Write {{name}} anywhere a request accepts text, and Collapy replaces it with that variable's value from the active environment when you send. For example, {{baseUrl}}/users/{{userId}} becomes https://api.example.com/users/42.
Syntax
- Wrap the variable's key in double curly braces:
{{apiToken}}. - Spaces inside the braces are ignored, so
{{ apiToken }}works the same as{{apiToken}}. - Keys are case-sensitive and must match the Key in the environment exactly.
- Values are inserted as-is. A value that contains
{{another}}isn't resolved a second time.
Where you can use variables
| Part of the request | What resolves |
|---|---|
| URL | Anywhere in the URL |
| Query params | Keys and values |
| Path variables | Values. See Path variables. |
| Headers | Keys and values |
| Auth | Bearer Token token, Basic Auth username and password, API Key key and value. See Authentication. |
| Body: Raw (JSON/Text) | Anywhere in the text |
| Body: Form Data and URL Encoded | Field keys and values |
A collection's auth can use variables too. They resolve when a request inherits that auth.
Insert a variable
Type {{ in any of the fields above and a list of variables appears under the field. It never interrupts your typing: keep typing and the list filters, or ignore it and carry on.
- With an active environment, the list shows its variables, with a preview of each value (secret values show as dots).
- With no active environment, the list says No environment selected and shows the variables of every environment in the workspace, each labelled with its environment. Picking one inserts it and makes its environment active. Choose… lists the environments instead, so you can pick one first.
- Use
↑/↓andEnter(orTab) to insert a variable, or click it. PressEscto close the list.
Variables are highlighted in the field so you can spot them. A variable the active environment doesn't define is shown in red with a dashed outline.
Define a variable where you use it
You don't have to leave the request to add a variable. Any of these opens a small Define form:
- In the
{{list, choose Define{{name}}in environment — or Define{{name}}… when no environment is active, and Define a new variable… before you've typed a name. It's offered when no variable matches exactly what you typed. - Click a red, undefined variable in the URL, the Params, Headers or Auth tab, or a Form Data / URL Encoded body, while you're not typing in that field.
- Click Define… in the message under the URL bar.
- Click Add to environment next to an undefined variable in the REQUEST VARIABLES panel.
- Click Define name… in the RESPONSE panel after a send was stopped because of it.
In the form:
- Enter the Value.
- Check the Environment. It's the active one by default; click it to pick another.
- Turn Secret on if the value is a credential. It's already on for names that look like one, such as
apiToken,password,clientSecretorapiKey. See Secret variables. - Click Add, or press
Enter.
To keep the value to yourself instead, pick Only me — local value as the target. See Local values.
The variable is saved to the environment straight away, for everyone who can see it. If no environment was active, the one you added it to becomes active.
If the workspace has no environments yet, the form creates one: the Environment field reads New environment Default (you can change the name), and the button reads Create Default and add. The new environment is shared with the workspace, has the type Development and becomes active.
Preview resolved values
To check what a request will actually send, press and hold the eye button in the request editor (Hold to preview resolved values (Ctrl+E)). You can also hold Ctrl+E (macOS: Cmd+E). While you hold it, every field shows its resolved value, with the substituted parts highlighted. Release to go back to the {{...}} view.
- The preview includes your local values.
- Secret values show as dots.
- If no environment is active, the button is disabled and shows Select an environment to preview.
Undefined variables
Collapy checks every variable before it sends a request. If one isn't defined in the active environment, or the request uses variables and no environment is active, the request isn't sent. The RESPONSE panel names the missing variables, for example Can't send yet — token isn't defined., with a link to define it.
Define the missing variable, give it a local value, or switch to the right environment, then send again.
The REQUEST VARIABLES panel
The REQUEST VARIABLES panel lists every variable the open request uses, with its current value.
- Where it's used. A letter badge in front of each name shows where the variable appears: U (URL), Q (Query params), P (Path params), H (Headers), A (Auth) and B (Body). Hover over a badge to see the full name.
- Not defined. A warning icon (Not defined) and a
not definedplaceholder mark variables that the active environment doesn't define. Add to environment next to them opens the Define form, filled in with the value you typed, if any. - Secrets. Secret values show as dots, also while you type a new one.
- All variables. Expand this section to see the active environment's other variables, the ones this request doesn't use. Secret values show as dots.
Your own value for a variable
Click a variable's value in REQUEST VARIABLES and type to set your local value: it's only on this device, only for you, and wins over the environment's value when you send. A local badge marks it. See Local values.
FAQ
Can a variable's value contain another variable?
No. Variables are resolved once. {{a}} whose value is {{b}} is sent literally as {{b}}.
Are there global or collection-level variables?
No. Variables come from the active environment, plus any local values you set.
