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: src/content/docs/fundamentals/api/how-to/make-api-calls.mdx
+49-21Lines changed: 49 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -198,37 +198,33 @@ curl.exe --request PATCH `
198
198
199
199
## Environment variables
200
200
201
-
You can define environment variables for values that repeat between curl commands, such as the zone or account ID. The lifetime of an environment variable can be the current shell session, all future sessions of the current user, or even all future sessions of all users on the machine you are defining them.
201
+
You can define environment variables for values that repeat between commands, such as the zone or account ID. The lifetime of an environment variable can be the current shell session, all future sessions of the current user, or even all future sessions of all users on the machine you are defining them.
202
202
203
203
You can also use environment variables for keeping authentication credentials (API token, API key, and email) for reuse in different commands. However, make sure you define these values in the smallest possible scope (either the current shell session only or all new sessions for the current user).
204
204
205
-
The procedure for setting environment variables depends on your platform and shell.
205
+
The procedure for setting and referencing environment variables depends on your platform and shell.
206
206
207
-
<Tabs> <TabItemlabel="Linux and macOS">
207
+
### Define an environment variable
208
208
209
-
To define two environment variables for the current shell session, run the following commands:
209
+
<TabssyncKey="LinuxPowershellCmd"> <TabItemlabel="Linux and macOS">
210
+
211
+
To define a `ZONE_ID` environment variable for the current shell session, run the following command:
210
212
211
213
```sh
212
214
export ZONE_ID='f2ea6707005a4da1af1b431202e96ac5'
213
-
export CLOUDFLARE_API_TOKEN='<API_TOKEN>'
214
215
```
215
216
216
-
When referencing the variable in curl commands, add a `$` prefix to the variable name (for example, `$ZONE_ID`). Make sure that the full string referencing the variable is either unquoted or enclosed in double quotes (`""`).
217
-
218
-
To define an environment variable for all new shell sessions for the current user, add the command above at the end of your shell configuration file (for example, `~/.bashrc` for the `bash` shell and `~/.zshrc` for the `zsh` shell).
217
+
To define the variable for all new shell sessions for the current user, add the command above at the end of your shell configuration file (for example, `~/.bashrc` for the `bash` shell and `~/.zshrc` for the `zsh` shell).
219
218
220
219
</TabItem> <TabItemlabel="PowerShell">
221
220
222
-
To define two environment variables named `ZONE_ID`and `CLOUDFLARE_API_TOKEN` for the current PowerShell session, run the following commands:
221
+
To define a `ZONE_ID`environment variable for the current PowerShell session, run the following command:
223
222
224
223
```powershell
225
224
$Env:ZONE_ID='f2ea6707005a4da1af1b431202e96ac5'
226
-
$Env:CLOUDFLARE_API_TOKEN='<API_TOKEN>'
227
225
```
228
226
229
-
When referencing the variable in curl commands, add an `$Env:` prefix to the variable name (for example, `$Env:ZONE_ID`). Make sure that the full string referencing the variable is either unquoted or enclosed in double quotes (`""`).
230
-
231
-
To define an environment variable for all new PowerShell sessions of the current user, set the variable in your PowerShell profile. You can get the path to your PowerShell profile by running `echo $PROFILE`.
227
+
To define the environment variable for all new PowerShell sessions of the current user, set the variable in your PowerShell profile. You can get the path to your PowerShell profile by running `echo $PROFILE`.
232
228
233
229
Alternatively, set the variable for all new PowerShell sessions of the current user using the `SetEnvironmentVariable()` method of the `System.Environment` class. For example:
234
230
@@ -240,21 +236,53 @@ Running this command will not affect the current session. You will need to close
To define a two environment variables for the current Command Prompt session, run the following commands:
239
+
To define a `ZONE_ID` environment variable for the current Command Prompt session, run the following command:
244
240
245
-
```txt
246
-
C:\>set ZONE_ID=f2ea6707005a4da1af1b431202e96ac5
247
-
C:\>set CLOUDFLARE_API_TOKEN=<API_TOKEN>
241
+
```txt frame="terminal"
242
+
set ZONE_ID=f2ea6707005a4da1af1b431202e96ac5
248
243
```
249
244
250
-
When referencing a variable in curl commands, enclose the variable name in `%` characters (for example, `%ZONE_ID%`).
251
-
252
245
To define an environment variable for all future Command Prompt sessions of the current user, run the following command:
253
246
254
-
```txt
255
-
C:\>setx ZONE_ID f2ea6707005a4da1af1b431202e96ac5
247
+
```txt frame="terminal"
248
+
setx ZONE_ID f2ea6707005a4da1af1b431202e96ac5
256
249
```
257
250
258
251
Running this command will not affect the current window. You will need to either run the `set` command or close and start a new Command Prompt window.
259
252
260
253
</TabItem> </Tabs>
254
+
255
+
### Reference an environment variable
256
+
257
+
<TabssyncKey="LinuxPowershellCmd"> <TabItemlabel="Linux and macOS">
258
+
259
+
When referencing an environment variable in a command, add a `$` prefix to the variable name (for example, `$ZONE_ID`). Make sure that the full string referencing the variable is either unquoted (if it does not contain spaces) or enclosed in double quotes (`""`).
When referencing an environment variable in a command, add an `$Env:` prefix to the variable name (for example, `$Env:ZONE_ID`). Make sure that the full string referencing the variable is either unquoted or enclosed in double quotes (`""`).
0 commit comments