-
Notifications
You must be signed in to change notification settings - Fork 0
Environment Variables and Scripts
Ozkan Pakdil edited this page Dec 15, 2025
·
1 revision
Use Environment Variables and the Pre‑request Script to prepare requests dynamically (tokens, timestamps, base URLs) before sending.
- Open: Edit → Environment Variables (Shortcut: Ctrl+E / Cmd+E).
- Purpose: Store key–value pairs such as
BASE_URL,AUTH_TOKEN,TENANT, or any custom values. - Scope: User‑level. Values persist across sessions.
- Typical uses:
- Build URLs (e.g., different environments: dev/stage/prod).
- Compose headers (e.g., Authorization tokens).
- Provide defaults for parameters and body templates.
- Location: In each request tab → “Pre‑request Script” tab.
- When it runs: Right before the request is sent.
- What it can do:
- Read your environment variables.
- Compute or transform values (e.g., current timestamp, HMAC signatures, dynamic IDs).
- Set/override headers and parameters before the request goes out.
- Base URL + path: Keep
BASE_URLin Environment Variables and join with endpoint paths in the URL field. - Bearer tokens: Keep
AUTH_TOKENin Environment Variables, then apply toAuthorizationheader via Pre‑request Script. - Timestamps & nonces: Generate time‑based values in the Pre‑request Script and inject into headers or body.
- Never put secrets into project files; keep them in Environment Variables.
- Rotate tokens regularly and prefer short‑lived credentials.
- Consider using a system keychain/secret manager for long‑lived secrets; paste them only when needed.
- If a value isn’t applied:
- Verify it exists in Environment Variables and there are no leading/trailing spaces.
- Check that your Pre‑request Script tab is configured for the request you’re sending.
- Try sending with the Debug Console visible (View → Show/Hide Debug Console) to inspect logs.