You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/features/variables.mdx
+69-59Lines changed: 69 additions & 59 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,96 +4,106 @@ title: Variables
4
4
description: Dynamic placeholders for your API interactions.
5
5
---
6
6
7
-
Hoppscotch provides you the ability to create and use variable throughout the app. This helps you reuse values throughout Hoppscotch just by invoking the variable name.
7
+
Hoppscotch provides you the ability to create and use variable throughout the app. This helps you reuse values throughout Hoppscotch just by invoking the variable name.
8
8
9
9
Hoppscotch considers an objects within an angular brackets as a variable `<<variable>>`
10
10
11
11
## Variable Scopes
12
12
13
13
Hoppscotch provides you different variables scopes, allowing you to use different scopes for different contexts.
14
14
15
-
1.**Global Variables:** can be accessed throughout Hoppscotch and has the broadest scope of all variables.
15
+
1.**Global Variables:** can be accessed throughout Hoppscotch and has the broadest scope of all variables.
16
16
2.**Environment Variables:** allow your variables to be scoped to an environment. Environment variables are useful when you have the same set of variables for two environments such as production and staging.
17
17
3.**Request Variables:** are scoped to just an individual request, request variables are useful when you want to use variables in your URL path or when you want to embed a variable URL.
18
18
4.**Predefined Variables:** are automatically generated at runtime and can be accessed globally throughout Hoppscotch using the `$` symbol, such as `$guid` or `$timestamp`.
19
+
5.**Collection Variables:** are scoped to individual collection and child folders, perfect for sharing base URLs, tokens and defaults across a set of requests without leaking to other workspaces.
19
20
20
-
The scope of each variable can be identified from the color of the variable name
21
+
The scope of each variable can be identified from the color of the variable name. If a variable with same name exist it is resolved in the order of priority.
21
22
22
-
| Variable Scope | Color |
23
-
| --- | --- |
24
-
| Global | Blue |
25
-
| Environment | Green |
26
-
| Request | Orange |
27
-
| Predefined | Yellow |
28
-
| Non resolvable | Red |
23
+
| Variable Scope | Color | Priority |
24
+
| -------------- | ----- | -------- |
25
+
| Request | 🟠 | 1 |
26
+
| Collection | 🟣 | 2 |
27
+
| Predefined | 🟡 | 3 |
28
+
| Environment | 🟢 | 4 |
29
+
| Global | 🔵 | 5 |
30
+
| Non resolvable | 🔴 | - |
29
31
30
32
## Types of Variables
31
33
32
-
1.**A regular variable**: allows users to reference the variable throughout Hoppscotch, and anyone can see the value associated with the variable.
33
-
In a workspace, regular environment variable-value pairs will be synced to the server, making them available to all workspace members.
34
-
However, you have the option to choose whether to sync a regular variable value present in your personal workspace
35
-
2.**A secret variable:** enables users to specify secrets and reference the values as variables. The values of secret variables in any workspace will never be synced to the server or shared with any workspace members.
36
-
It is expected that in a collaborative workspace the user will populate the value of the variable at runtime.
37
-
All secret variable values in Hoppscotch will be masked using asterisks (***). Secret Variables cannot be scoped to a request and can only be scoped in an environment or globally
34
+
1.**A regular variable**: allows users to reference the variable throughout Hoppscotch, and anyone can see the value associated with the variable.
35
+
In a workspace, regular environment variable-value pairs will be synced to the server, making them available to all workspace members.
36
+
However, you have the option to choose whether to sync a regular variable value present in your personal workspace
37
+
2.**A secret variable:** enables users to specify secrets and reference the values as variables. The values of secret variables in any workspace will never be synced to the server or shared with any workspace members.
38
+
It is expected that in a collaborative workspace the user will populate the value of the variable at runtime.
39
+
All secret variable values in Hoppscotch will be masked using asterisks (\*\*\*). Secret Variables cannot be scoped to a request and can only be scoped in an environment or globally
38
40
39
-
<Note> Secret variables values will not be exported when an environment is exported.</Note>
41
+
<Note>
42
+
{""}
43
+
Secret variables values will not be exported when an environment is exported.
44
+
</Note>
40
45
41
-
3.**A predefined variable:** is automatically generated at runtime and provides dynamic, context-specific data. Predefined variables are available throughout your requests and responses and are useful for incorporating system-level information or dynamic values into your API interactions without manual configuration.
42
-
All predefined variables are accessible throughout Hoppscotch and can be retrieved using the `$` symbol. Below is the list of predefined variables whose values are dynamically generated during the request or collection run:
46
+
3.**A predefined variable:** is automatically generated at runtime and provides dynamic, context-specific data. Predefined variables are available throughout your requests and responses and are useful for incorporating system-level information or dynamic values into your API interactions without manual configuration.
47
+
All predefined variables are accessible throughout Hoppscotch and can be retrieved using the `$` symbol. Below is the list of predefined variables whose values are dynamically generated during the request or collection run:
0 commit comments