Apidog Docs
🇺🇸 English
  • 🇺🇸 English
  • 🇯🇵 日本語
HomeLearning CenterSupport CenterAPI References
HomeLearning CenterSupport CenterAPI References
Discord Community
Slack Community
X / Twitter
🇺🇸 English
  • 🇺🇸 English
  • 🇯🇵 日本語
  1. Environments & variables
  • Apidog Learning Center
  • Get started
    • Introduce Apidog
    • Basic concepts in Apidog
    • Navigating Apidog
    • Quick Start
      • Overview
      • Specify a new endpoint
      • Make a request to the endpoint
      • Add an assertion
      • Create a test scenario
      • Share your API documentation
      • Explore more
      • Send a request and save as an endpoint
    • Migration
      • Overview
      • Manual import
      • Scheduled import
      • Import options
      • Export data
      • Import from...
        • Import from Postman
        • Import OpenAPI (Swagger) 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
    • Components
    • Common fields
    • Global parameters
    • Endpoint change history
    • Batch endpoint management
    • Configure multiple request body examples
    • Schemas
      • Generate Schemas from JSON etc.
      • Build a schema
      • Overview
      • Create a new schema
    • Security schemes
      • Overview
      • Create a security scheme
      • Use the security scheme
      • Security scheme in online documentation
    • Advanced features
      • Custom endpoint fields
      • Import endpoints as test steps
      • Endpoint status
      • Appearance of parameter lists
      • Endpoint unique idenfication
  • Develop and Debug APIs
    • Overview
    • Generate requests
    • Send requests
    • Endpoint cases
    • Dynamic values
    • Validate responses
    • Design-first Mode & Request-first Mode
    • Generate code
    • Environments & variables
      • Overview
      • Using variables
      • Environments & services
    • Vault secrets
      • Overview
      • HashiCorp Vault
      • Azure Key Vault
      • AWS Secrets Manager
    • Pre/Post processors
      • Overview
      • Assertion
      • Extract variable
      • Wait
      • Database operations
        • Overview
        • MongoDB
        • Redis
        • Oracle Client
      • Using scripts
        • Overview
        • Postman scripts reference
        • Pre processor scripts
        • Post processor scripts
        • Public scripts
        • Calling other programming languages
        • Using JS libraries
        • Visualizing responses
        • Script examples
          • Assertion scripts
          • Using variables in scripts
          • Using scripts to modify request messages
          • 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)
  • Automated tests
    • Overview
    • Test reports
    • Test scenarios
      • Create a test scenario
      • Pass data between requests
      • Flow control conditions
      • Import endpoints/endpoint cases from other projects
      • Sync data from endpoints/endpoint cases
      • Export test scenarios
    • Run test scenarios
      • Run a test scenario
      • Data-driven testing
      • Run test scenarios in batch
      • Scheduled tasks
      • Manage the runtime environment of APIs from other projects
    • Test APIs
      • Integration testing
      • Performance testing
      • End-to-end testing
      • Regression testing
    • Apidog CLI
      • Overview
      • Installing and running Apidog CLI
      • Apidog CLI Options
    • CI/CD
      • Overview
      • Integrate with Jenkins
      • Integration with Gitlab
  • Publish API Docs
    • Overview
    • API Technologies Supported
    • Quick share
    • View the API documentation
    • Publish docs sites
    • Folder tree settings
    • Custom layouts
    • Visibility settings
    • Endpoint SEO settings
    • Custom domain
    • Embedding values in document URLs
    • Documentation Search
    • Integrating Google Analytics with Doc Sites
    • CORS Proxy
    • API Versions
      • Overview
      • Create API versions
      • Publish API versions
      • Share endpoints with API versions
  • Send requests
    • Overview
    • gRPC
    • Use request proxy agents for debugging
    • SOAP/WebService
    • GraphQL
    • WebSocket
    • Socket.IO
    • SSE debugging
    • Create requests
      • Request History
      • Request basics
      • Parameters and body
      • Request headers
      • Request settings
      • HTTP/2
    • Authentication and authorization
      • Overview
      • CA and client certificates
      • Authorization types supported by Apidog
      • Digest Auth
      • OAuth 1.0
      • OAuth 2.0
      • Hawk Authentication
      • Kerberos
      • NTLM
      • Akamai EdgeGrid
    • Response and cookies
      • Overview
      • API response in Apidog
      • Create and send cookies
      • Debug requests
      • Save the request as an endpoint
  • Branches
    • Overview
    • Create a new sprint branch
    • Test APIs in a branch
    • Design API in a branch
    • Merge sprint branches
    • Manage sprint branches
  • Apidog MCP Server
    • Overview
    • Conntect API Specification within Apidog Project to AI via Apidog MCP Server
    • Conntect Online API Documentation Published by Apidog to AI via Apidog MCP Server
    • Conntect OpenAPI Files to AI via Apidog MCP Server
  • Best practices
    • How to handle API signatures
    • How to access OAuth 2.0 protected APIs
    • Apidog collaboration workflow
    • Managing authentication state in Apidog
  • Administration
    • Onboarding Checklist
      • Basic Concepts
      • Onboarding Guide
    • 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
    • Managing Projects
      • Managing Projects
      • Managing Project Members
      • Notification Settings
      • Project Resources
        • Database Connection
    • Managing Organizations
      • Single Sign-On (SSO)
        • SSO Overview
        • Configure Microsoft Entra ID
        • Configure Okta
        • Configure SSO for an Organization
        • Managing user accounts
        • Mapping Groups to Teams
      • SCIM Provisioning
        • Intro to SCIM Provisioning
        • Microsoft Entra ID
        • Okta
      • Organization Resources
        • Self-hosted Runner
  • Billing
    • Overview
    • Credits
    • Unable to use credit cards?
    • Managing subscriptions
    • Upgrade plan
  • Add-ons
    • API Hub
    • Apidog Intellij IDEA plugin
    • Browser Extension
      • Chrome
      • Microsoft Edge
    • Request Proxy
      • Request proxy in Apidog web
      • Request proxy in shared docs
      • Request proxy in Apidog client
  • Account & preferences
    • Language settings
    • Data backup
    • Network proxy configuration
    • Hot keys
    • Updating Apidog
    • Generate OpenAPI access token
    • Deleting account
    • Account settings
  • References
    • API-Design First Approach
    • Apidog OpenAPI/Swagger Specificaiton Extensions
    • JSONPath
    • XPath
    • Regular Expressions
    • JSON Schema
    • CSV File Format
    • Install Java Environment
    • Runner deployment environment
    • Apidog flavored Markdown
  • Apidog Europe
    • Apidog Europe
  • Support Center
  1. Environments & variables

Environments & services

When making API requests, it is often necessary to switch between development, testing, and production environments. Apidog makes it convenient to send requests to different environments - you simply need to click and select the desired environment at the top right corner of the interface.
An Apidog environment consists of two core elements. The first is the service (base URL), used to maintain the target of request delivery. The second element comprises a group of one or more variables that can be referenced in requests or scripts. When switching between environments, both the service (base URL) and environment variables will use the values defined in the current environment.

Create an environment#

1
Click on the "Environment Management" button ≡ in the top right corner of the interface.
2
Click on the last item in the left-side list labeled New Environment.
3
Enter a name for your new environment. Add Service base URL and variables.
image.png
4
Click Save.
5
To use the new environment, select it from the environment selector at the top right of the interface. This makes it the active environment and sets all variables to the values specified in the environment.
Environments in Apidog are distinct from those in Postman, where there is a tendency to associate each Base URL with a separate environment. This blurs the lines between environments and base URLs.
In contrast, Apidog's environments directly reflect real environments like development, testing, and production, rather than treating each base URL as one single environment.
For example, within a testing environment, there may be various services such as user service and order service all contained within the same testing environment. It is important that these services are not divided into separate user and order environments.

Services (base URLs)#

The Service (base URL) is the primary feature in an Apidog environment. In Apidog, an endpoint starts with a forward slash (/) and does not include the base URL; when sending an endpoint request, it is necessary to specify the destination base URL. This underlines the importance of the Service feature in the environment—selecting a particular environment is a prerequisite for sending an endpoint request.
A standardized base URL format begins with the protocol and without trailing slash (/), like
https://127.0.0.1
or
http://abc.com/v1
Every environment contains a default server; when an endpoint does not specify a specific service, the request is directed to the default server.
For instance, if the default server base URL for your production environment is http://abc.com/v1 and your endpoint path is /pet, then when you send a request in the production environment, the actual request sent would be
http://abc.com/v1/pet
If the endpoint path begins with http:// or https://, the base URL will not be appended to the request. Nonetheless, this practice is generally discouraged.
BASE_URL variable
In Apidog, there is a special environment variable called BASE_URL, which stores the base URL for the "Default Server" of the current environment.
It is generally discouraged to use this variable. For custom scripts, it is recommended to use pm.request.getBaseUrl() to fetch the base URL for the present endpoint. Avoid using pm.environment.get('BASE_URL'), as it may not correctly capture the base URL for the current endpoint if the endpoint does not employ the "Default Server."
If the user manually creates an environment variable labeled BASE_URL, it will supersede the system's predefined BASE_URL.
Scripts are unable to modify the base URL. The command pm.environment.set('BASE_URL', 'My_url') within a script will establish a genuine environment variable called BASE_URL instead of altering the base URL itself.

Utilize multiple services#

If your project involves multiple distinct services — for example, directing user-related requests to https://user.abc.com and order-related requests to https://order.abc.com - then you need to utilize multiple services. Here is the specific process:
1
Add multiple services and their respective base URLs to the environment.
image.png
2
Assign the endpoint to the designated service.
In DESIGN mode, select the service from the Service dropdown in the Edit tab.
image.png
In DEBUG mode, select the service from the Service dropdown in the Info tab.
image.png
3
Services can also be added by folder. Click on the folder name, and in the Folder settings, select the service from the Service dropdown. Then all endpoints under this folder will be directed to this service.
4
By selecting the environment at the top right corner of the interface and clicking send, the endpoint bound to the service will be directed to the corresponding base URL.
5
When you switch to different environments in the environment management section, you may notice that the User service and Order service are also added to other environments but with empty base URLs.
image.png
This is because in most teams, both test and develop environments have corresponding services. By setting the respective base URLs for each environment, when you switch environments at the top right corner, all endpoint requests will be directed to the correct services. In practice, this is the most efficient design approach.

Add environment variables#

When you add a variable to an environment, you can specify the Initial value (shared) and the Current value (local) for the variable.
Learn more about Using variables.

Switch between environments#

Apidog shows the current environment in the environment selector at the top right of the workbench. Whenever you make a request or execute a script, Apidog will use the current values for all variables in the selected environment.
To switch to a different environment, simply choose it from the environment selector.
In Apidog, endpoints and requests are two distinct concepts. An endpoint represents the API specification and does not include the base URL, whereas a request is the concrete API request, which includes the base URL. Therefore, the services defined in an Apidog environment only apply to endpoints, not to requests.
When using the requests functionality, you can leverage the environment variables in a similar way to Postman, by using the {{Base_url}} syntax.

Environment Migration#

In Apidog, the Initial value of variables is synchronized within the team, while the Current value is only stored locally. This means that when you use Apidog on another computer, you won't have access to the previously used Current values.
Therefore, Apidog provides the functionality to migrate environments. You can export the services and variables in environments as a JSON file and then import it on another computer. Here are the steps:
1
In the environment management, hover over the ... next to the Environments list, click Export to obtain a JSON file.
2
On another computer, open environment management, hover over the ... next to the Environments list, and click Import. Select the JSON file to import.
3
You can also import environments exported from Postman.

Visibility Scope of Environments#

Sometimes, you may need to create variables for personal use only and prefer they are not visible to others. In such cases, you can create a Private Environment.
In the top right corner of the environment, you can set the visibility scope of the environment. By default, it is shared, while you can make environments you create visible only to yourself. However, you cannot change the visibility of environments created by others.
Private Environments share the same Service list as other environments. Adding or removing services in a Private Environment will affect all environments simultaneously.
Modified at 2024-12-16 06:43:17
Previous
Using variables
Next
Overview
Built with