Apidog Docs
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ ζ—₯本θͺž
HomeLearning Center
Support CenterAPI ReferencesDownloadChangelog
HomeLearning Center
Support CenterAPI ReferencesDownloadChangelog
Discord Community
Slack Community
X / Twitter
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ ζ—₯本θͺž
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ ζ—₯本θͺž
  1. Environments & Variables
  • Apidog Learning Center
  • Getting Started
    • Introduction to Apidog
    • Basic Concepts in Apidog
    • Navigating Apidog
    • Quick Start
      • Overview
      • Creating an Endpoint
      • Making a Request
      • Adding an Assertion
      • Creating Test Scenarios
      • Sharing API Documentation
      • Explore More
    • Migration to Apidog
      • Overview
      • Manual Import
      • Scheduled Import (Bind Data Sources)
      • Import Options
      • Export Data
      • Import From
        • Import from Postman
        • Import OpenAPI Spec
        • Import cURL
        • Import Markdowns
        • Import from Insomnia
        • Import from apiDoc
        • Import .har File
        • Import WSDL
  • Design APIs
    • Overview
    • Create a New API Project
    • Endpoint Basics
    • APl Design Guidelines
    • Module
    • Configure Multiple Request Body Examples
    • Components
    • Common Fields
    • Global Parameters
    • Endpoint Change History
    • Comments
    • Batch Endpoint Management
    • Custom Protocol API
    • Schemas
      • Overview
      • Create a New Schema
      • Build a Schema
      • Generate Schemas from JSON Etc
      • oneOf, allOf, anyOf
      • Using Discriminator
    • Security Schemes
      • Overview
      • Create a Security Scheme
      • Use the Security Scheme
      • Security Scheme in Online Documentation
    • Advanced Features
      • Custom Endpoint Fields
      • Associated Test Scenarios
      • Endpoint Status
      • Appearance of Parameter Lists
      • Endpoint Unique Identification
  • Develop and Debug APIs
    • Overview
    • Generating Requests
    • Sending Requests
    • Debugging Cases
    • Test Cases
    • Dynamic Values
    • Validating Responses
    • Design-First vs Request-First
    • Generating Code
    • Environments & Variables
      • Overview
      • Environment Management
      • Using Variables
    • Vault Secrets
      • Overview
      • HashiCorp Vault
      • Azure Key Vault
      • AWS Secrets Manager
    • Pre and Post Processors
      • Assertion
      • Extract Variable
      • Wait
      • Overview
      • Database Operations
        • Overview
        • MySQL
        • MongoDB
        • Redis
        • Oracle Client
      • Using Scripts
        • Overview
        • Pre Processor Scripts
        • Post Processor Scripts
        • Public Scripts
        • Postman Scripts Reference
        • Calling Other Programming Languages
        • Using JS Libraries
        • Visualizing Responses
        • Script Examples
          • Assertion Scripts
          • Using Variables
          • Modifying Requests
          • Other Examples
    • Dynamic Values Modules
  • Mock API Data
    • Overview
    • Smart Mock
    • Custom Mock
    • Mock Priority Sequence
    • Mock Scripts
    • Cloud Mock
    • Self-Hosted Runner Mock
    • Mock Language (Locales)
  • API Testing
    • Overview
    • Test Scenarios
      • Create a Test Scenario
      • Pass Data Between Requests
      • Flow Control Conditions
      • Sync Data from Endpoints and Endpoint Cases
      • Import Endpoints and Endpoint Cases from Other Projects
      • Export Test Scenarios
    • Run Test Scenarios
      • Run a Test Scenario
      • Run Test Scenarios in Batch
      • Manage Runtime Environment of APIs from Other Projects
      • Data-Driven Testing
      • Scheduled Tasks
    • Test Suite
      • Overview
      • Create A Test Suite
      • Orchestrate Test Suite
      • Run Test Suites Locally
      • Run Test Suites Via CLI
      • Scheduled tasks
    • Test Reports
      • Test Reports
    • Test APIs
      • Integration Testing
      • Performance Testing
      • End-to-End Testing
      • Regression Testing
      • Contract Testing
    • Apidog CLI
      • Overview
      • Installing and Running Apidog CLI
      • Apidog CLI Options
    • CI CD
      • Overview
      • Integrate with Gitlab
      • Integrate with Jenkins
      • Trigger Test by Git Commit
      • Integrate with Github Actions
  • Publish API Docs
    • Overview
    • API Technologies Supported
    • Quick Share
    • Viewing API Documentation
    • Markdown Documentation
    • Publishing Documentation Sites
    • Custom Layouts
    • Custom CSS, JavaScript, HTML
    • Custom Domain
    • LLM-Friendly Features
    • SEO Settings
    • Advanced Settings
      • Documentation Search
      • CORS Proxy
      • Integrating Google Analytics with Doc Sites
      • Folder Tree Settings
      • Visibility Settings
      • Embedding Values in Document URLs
    • API Versions
      • Overview
      • Creating API Versions
      • Publishing API Versions
      • Sharing Endpoints with API Versions
  • Send Requests
    • Overview
    • SSE Debugging
    • MCP Client
    • Socket.IO
    • WebSocket
    • Webhook
    • SOAP or WebService
    • GraphQL
    • gRPC
    • Use Request Proxy Agents for Debugging
    • Create Requests
      • Request History
      • Request Basics
      • Parameters and Body
      • Request Headers
      • Request Settings
      • Debug Requests
      • Saving Requests as Endpoints
      • HTTP/2
    • Response and Cookies
      • Viewing API Responses
      • Managing Cookies
      • Overview
    • Authentication and Authorization
      • Overview
      • CA and Client Certificates
      • Authorization Types
      • Digest Auth
      • OAuth 1.0
      • OAuth 2.0
      • Hawk Authentication
      • Kerberos
      • NTLM
      • Akamai EdgeGrid
  • Branches
    • Overview
    • Creating a Sprint Branch
    • Testing APIs in a Branch
    • Designing APIs in a Branch
    • Merging Sprint Branches
    • Managing Sprint Branches
  • AI Features
    • Overview
    • Enabling AI Features
    • Generating Test Cases
    • Modifying Schemas with AI
    • Endpoint Compliance Check
    • API Documentation Completeness Check
    • AI-Powered Field Naming
    • FAQs
  • Apidog MCP Server
    • Overview
    • Connect Apidog Project to AI
    • Connect Published Documentation to AI
    • Connect OpenAPI Files to AI
  • Best Practices
    • Handling API Signatures
    • Accessing OAuth 2.0 Protected APIs
    • Collaboration Workflow
    • Managing Authentication State
  • Offline Space
    • Overview
  • Administration
    • Managing Teams
      • Managing Teams
      • Managing Team Members
      • Member Roles & Permission Settings
      • Team Activities
      • Team Resources
        • General Runner
        • Team Variables
        • Request Proxy Agent
      • Real-time Collaborations
        • Team Collaboration
    • Onboarding Checklist
      • Basic Concepts
      • Onboarding Guide
    • Managing Projects
      • Managing Projects
      • Managing Project Members
      • Notification Settings
      • Project Resources
        • Database Connection
        • Git Connection
    • Managing Organization
      • Managing Organization
      • Single Sign-On (SSO)
        • SSO Overview
        • Configuring Microsoft Entra ID
        • Configuring Okta
        • Configuring SSO for an Organization
        • Managing User Accounts
        • Mapping Groups to Teams
      • SCIM Provisioning
        • Introduction to SCIM Provisioning
        • Microsoft Entra ID
        • Okta
      • Plans Management
        • Billing Managers in Organizations
      • Organization Resources
        • Self-Hosted Runner
  • Billing
    • Overview
    • Credits
    • Alternative Payment Methods
    • Managing Subscriptions
    • Upgrading Your Plan
    • Moving Paid Teams to Organizations
  • Data & Security
    • Data Storage and Security
    • User Data Privacy and Security
    • Request Routing and Data Security
  • Add-ons
    • API Hub
    • Apidog Intellij IDEA Plugin
    • Browser Extension
      • Chrome
      • Microsoft Edge
    • Request Proxy
      • Request Proxy in Web
      • Request Proxy in Shared Docs
      • Request Proxy in Client
  • Account & Preferences
    • Account Settings
    • Generating OpenAPI Access Token
    • Notification
    • Language Settings
    • Hot Keys
    • Network Proxy Configuration
    • Backing Up Data
    • Updating Apidog
    • Deleting Account
    • Experimental Features
  • References
    • API Design-First Approach
    • Apidog OpenAPI Specificaiton Extensions
    • JSONPath
    • XPath
    • Regular Expressions
    • JSON Schema
    • CSV File Format
    • Installing Java Environment
    • Runner Deployment Environment
    • Apidog flavored Markdown
  • Apidog Europe
    • Apidog Europe
  • Support Center
HomeLearning Center
Support CenterAPI ReferencesDownloadChangelog
HomeLearning Center
Support CenterAPI ReferencesDownloadChangelog
Discord Community
Slack Community
X / Twitter
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ ζ—₯本θͺž
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ ζ—₯本θͺž
  1. Environments & Variables

Using Variables

In Apidog, variables allow you to save and reuse values easily. Storing a value as a variable enables you to access it across various environments, requests, scripts, and test scenarios. Utilizing variables increases productivity and promotes teamwork among colleagues.

What are Variables?#

A variable is a symbolic representation of data that allows you to retrieve a value without manually inputting it every time it's needed. This is beneficial for reusing the same values across different locations.
Example:
If you have the same token in multiple requests and anticipate changes, save the token as a variable named {{my_token}}. Use {{my_token}} in the request parameter value. When the token changes, updating the variable value updates it everywhere.
Variable example
Variables can take effect in parameter values, bodies, URLs, or headers.
TIP
In Apidog's Tests module, variables can be used to pass data between requests.

Variable Scopes#

Apidog supports variables in various scopes to adjust to different development, testing, and collaboration requirements.
Priority (from lowest to highest): Global < Module < Environment < Data < Local
When a variable with the same name is defined in different scopes, the value from the narrowest scope takes precedence.
1.
Global Variables
Shared within Project: Accessible across an entire project. Useful for sharing data between endpoints (e.g., login token).
Shared within Team: Shared throughout the entire team across different projects (e.g., a token shared between a login project and a finance project).
Global project variables
Global team variables
NOTE
Permissions: To manage team variables, you need team admin permissions. Go to Team Resources > Variables.
Scripts: You can use pm.globals.set to update current values in scripts, but cannot change names or initial values.
2.
Module Variables
Defined within a module. Importing from Postman "Collection variables" maps to Module variables.
3.
Environment Variables
Tied to specific environments (Development, Testing, Production). Only the active environment's variables are effective.
4.
Data Variables
Sourced from external CSV or JSON files in Test Scenarios or CLI. Values do not persist after the run.
5.
Local Variables
Temporary variables confined to a single request or test scenario run. Disappear once completed.
TIP
Variables in Apidog are stored as strings. When saving objects or arrays, use JSON.stringify() to store and JSON.parse() to retrieve them.

Initial and Current Values#

Each variable has two states:
Initial Value: Sychronized with Apidog servers and shared with the team.
Current Value: Stored LOCALLY in your browser or client cache. Not shared.
Initial vs Current value
Best Practices:
Use Current Value for sensitive data (tokens, passwords) so they stay on your machine.
Leave Current Value empty to fall back to the Initial Value.
Click the link icon πŸ”— to sync Current Value with Initial Value.
WARNING
Cleaning Apidog cache will delete Current Values.
Current Values do NOT migrate automatically when switching devices (use Environment Export/Import).

Using Variables in Apidog CLI#

When running in the CLI, the Initial Value is used by default, whereas the Client uses the Current Value. This is a common cause for discrepancies between Client and CLI runs.
TIP
Learn more about the Apidog CLI.

Defining Variables#

1. Environment Management (Preset)#

Values for Global and Environment variables can be preset manually.
1
Click the Environment Management icon ≑.
2
Select Global Variables or a specific environment.
3
Add the variable name, initial value, and current value.
4
Click Save.

2. Extract Variables#

Visually extract values from API responses into variables without writing code.
1
In the Run tab (Design Mode), go to Post Processors.
2
Select Extract Variable.
Add extraction
3
Configure extraction source (JSON, XML, Header, etc.) and JSONPath.
Configure extraction
4
Send the request to execute and verify in the Console.
Console verification
TIP
Learn more about Extract Variable.

3. Scripts#

Use the pm object in Pre/Post-processors.
Syntax for set:
Storing Objects/Arrays:
TIP
Learn more about Script Syntax.

4. Database Operations#

Connect to a database to retrieve data and set it as a variable.
1
Add Database Operation in Post Processors.
Add DB op
2
Configure database connection.
Configure DB
3
Enter SQL command (supports {{variable}}).
4
Set Extract Result To Variable.
TIP
Learn more about Database Operations.

Using Variables#

Request Parameters#

Use double curly braces {{variable}} in URL, parameters, headers, or body.
Example URL:
http://127.0.0.1/pet/findByStatus?status={{CurrentStatus}}
Example JSON Body:
{
    "status": "{{CurrentStatus}}",
    "quantity": {{TotalPet}}
}
WARNING
Strings: Add double quotes "" around the variable for strings (e.g., "{{name}}").
Numbers/Booleans: Do NOT add quotes (e.g., {{count}}).

Accessing Sub-elements#

If a variable contains a JSON object/array, access properties via dot notation using JSONPath.
Object in {{user}}:
{ "id": 1, "name": "Jack" }
Request: {{user.name}}
Script: pm.variables.get("user.name")
Array in {{users}}:
[ { "name": "Jack" } ]
Request: {{users[0].name}}
Script: pm.variables.get("users[0].name")

Using Variables in Scripts#

In scripts, use pm.*.get() instead of {{}}.
Logging:
Check the Console tab to see output.

Using Data Variables#

In Test Scenarios, importing a CSV/JSON file creates "Data Variables". Use {{column_name}} to reference them. Each row in the file triggers a separate iteration.
TIP
Learn more about Data Driven Testing.

FAQ#

Q: Can I use variables in Mocks?
No. Variables are resolved when a request is sent. Mocks are static definitions or run on the mock server without a client-side "sending" context in the same way.
Q: How do I get the base URL in a script?
Use pm.request.getBaseUrl().
Avoid pm.environment.get('BASE_URL') as it might be inaccurate for non-default server endpoints.
Modified atΒ 2026-01-14 09:10:00
Previous
Environment Management
Next
Overview
Built with