How to Properly Use Base URLs in Apidog

Simplify API management in Apidog by organizing services into modules and assigning base URLs per environment. Ideal for teams and microservices.

Oliver Kingsley

Oliver Kingsley

25 July 2025

How to Properly Use Base URLs in Apidog

A base URL in Apidog lets you extract the repeated part of your endpoint addresses for unified management.

For example, if your endpoint is https://api.example.com/v1/users, you can set https://api.example.com/v1 as the base URL. Then in your endpoint definition, you only need to write /users.

When sending a request, Apidog will automatically concatenate the base URL and the endpoint path to form the complete request address. The benefit is that if the server address changes, you only need to update the base URL—no need to modify each endpoint individually.

endpoint address combination

Steps to Set a Base URL

Open your Apidog project and find "Environment Management" in the upper right corner. Apidog will create several common environments by default, such as development, testing, and production. You can use these presets or create new environments as needed.

environment management page in Apidog

After selecting an environment, you'll see the "Base URL" input box. Enter the base address starting with the protocol (http:// or https://), such as https://test.server.com, or include a version number like https://api.example.com/v1.

base urls in Apidog

Be sure not to add a trailing slash. According to the OpenAPI specification, the base URL should not end with a /, while the endpoint path should start with a /.

We recommend following the OpenAPI specification for better compatibility and a more complete feature experience in Apidog.

Using the Base URL in Endpoints

Now, when you create a new endpoint, you only need to enter the endpoint path in the URL field. For example, to test the user list endpoint, just enter /users, and Apidog will automatically combine it into the complete request URL https://api.example.com/v1/users.

If your endpoint path includes multiple levels, like /users/123/profile, you can follow the same method—Apidog will automatically combine the base URL with your path to form the complete request URL.

Note: If you enter a full address (starting with http:// or https://) in the endpoint URL, the base URL will not be used. Apidog will prioritize the full address you provide.

Managing Base URLs Across Multiple Environments

Most projects have multiple environments (development, testing, production), each with a different server address. You can set a different base URL for each environment.

For example:

When you switch environments from the top-right corner, all endpoints will automatically use the server address for the selected environment.

switch environments in Apidog

You can also choose the environment directly in the endpoint address bar, where the default base URL for each environment is displayed. This works the same as switching environments in the "Environment Management" panel.

select the environment directly in the endpoint address bar

Note: If an environment has multiple base URLs, only the default one will appear in the address bar. To use a non-default base URL for specific endpoints, you’ll need to either set it manually within the endpoint or manage it through modules.

This multi-base URL setup is common in microservice architectures, where different endpoints need to use different service addresses.

Managing Base URLs in Microservices

If your project uses a microservice architecture and not all endpoints share the same base URL, you have two ways to manage base URLs in Apidog.

Manually Specify Base URLs within a Module

You can group endpoints from different services into a single module and assign different base URLs to specific folders or individual endpoints. This setup is flexible and works well for teams that prefer centralized management.

For example, you can configure a module with multiple base URLs for different services.

a module is configured with multiple base URLs

Then, assign the "User Service" base URL to the user folder and the "Order Service" base URL to the order folder. All endpoints within each folder will automatically use the corresponding base URL.

If you don’t want to configure by folder, you can also set the base URL for individual endpoints. Just open the endpoint’s “Edit” page and select the desired base URL from the dropdown menu.

However, as the number of services grows, managing base URLs this way can become tedious and harder to maintain. It may work well for smaller projects, but larger projects can quickly become difficult to manage.

For better scalability and clarity, we recommend a more structured approach:
separate each service into its own module and set the base URL at the module level. This keeps your project organized and much easier to maintain.

Create a separate module for each service and configure its base URL under "Environment Management" for every environment. This approach is more organized and ideal for team collaboration and long-term maintenance.

For example, you can create separate modules for the User Service, Order Service, and Product Service, each linked to its own Swagger or OpenAPI spec file.

Once the modules are set up, go to the "Environment Management" page, where you'll see base URL settings neatly grouped by module.

Each environment shares the same module structure, but the base URL for each module can vary by environment. This allows you to assign specific base URLs for every module in each environment. For example:

Environment Product Service User Service Order Service
Production https://product.example.com https://user.example.com https://order.example.com
Testing http://192.168.1.10:8080 http://192.168.1.11:8080 http://192.168.1.12:8080
Development http://localhost:3000 http://localhost:3001 http://localhost:3002
configure a specific base URL for every module within each environment

With this setup, whenever you create a new endpoint within a module, it will automatically use the correct base URL for the current environment—no need to select it manually. For example:

how base URLs in Module work

Think of the "Module + Environment" pairing as a coordinate system that accurately determines the request URL. As long as your modules and environments are properly organized, Apidog will automatically choose the correct base URL for each request.

You won’t have to wonder, "Which address is this endpoint using?"—just select the appropriate module and environment, and Apidog handles the rest.Ask ChatGPT

💡
To learn more about "modules", check the official documentation.

Practical Tips for Using Base URLs

  1. If your API includes a version number, add it directly to the base URL—for example: https://api.example.com/v2. This way, when you upgrade the API version, you only need to update the base URL, not every endpoint.
  2. For special cases, like calling third-party services, you can enter the full URL directly in the endpoint. This will override the default base URL automatically.

Conclusion

Managing base URLs effectively is key to keeping your API projects clean, scalable, and easy to maintain—especially as they grow in complexity. Whether you're working with a simple single-service project or a large microservices architecture, Apidog offers flexible options that adapt to your workflow.

By organizing your services into modules and configuring base URLs per environment, you ensure that each endpoint always points to the right server—without manual overhead. With smart defaults, environment switching, and modular design, Apidog simplifies the process and eliminates guesswork.

Explore more

How to Debug Your Code with AI Using Cursor Bugbot

How to Debug Your Code with AI Using Cursor Bugbot

Learn how to debug your code efficiently with AI using Cursor Bugbot. Discover its features, setup process, and best practices for optimal results.

25 July 2025

Is Qwen3-MT the Game-Changing Translation Model We've Been Waiting For

Is Qwen3-MT the Game-Changing Translation Model We've Been Waiting For

Discover Qwen3-MT, Alibaba's powerful new translation model supporting 92 languages.

25 July 2025

How to Auto-Trigger Apidog Automated Tests After Code Submission?

How to Auto-Trigger Apidog Automated Tests After Code Submission?

Manually testing APIs after every commit is tedious. With Apidog’s CLI, you can automate API tests in your CI/CD pipeline. This guide explains how to set up automatic test triggers using GitHub Actions, GitLab CI, or Jenkins with Webhooks for seamless testing after every code push.

22 July 2025

Practice API Design-first in Apidog

Discover an easier way to build and use APIs