# Base URL

Base URL is the main URL to a web service that should be used for every module and remote procedure in an app, e.g. `https://mywebservice.com/api/v1.`

There might be situations when you need to have a variable base URL. For example, if the web service uses multiple domains you may want to let your users have access to the one they use.

## Base URL example: two types of accounts

This is an example of how to handle two types of accounts - `sandbox` and `production`.

{% stepper %}
{% step %}
Add a checkbox in your connection parameters that can be checked when the condition is met:

```json
[
   {
      "name": "sandbox",
      "type": "boolean",
      "label": "Sandbox"
   },
   ...
]
```

{% endstep %}

{% step %}
Implement a condition in both the connection and the base:

```json
{
    "baseUrl": "https://{{if(connection.sandbox,'sandbox.', '')}}yourapi.com/api"
}
```

{% endstep %}
{% endstepper %}

All modules and remote procedures can then use hard-coded `"url": "/uniqueEndpoint"`

## Base URL example: two environments

This is an example of how to handle two types of accounts - `eu` and `us`.

{% stepper %}
{% step %}
Set up `select` in your connection parameters, where you let your users choose from available environments:

```json
[
    {
        "name": "environment",
        "type": "select",
        "label": "Environment",
        "options": [
            {
                "label": "EU",
                "value": "eu"
            },
            {
                "label": "US",
                "value": "us"
            }
        ],
        "default": "production"
    },
    ...
]
```

{% endstep %}

{% step %}
Map the environment in both the connection and the base.

```json
{
    "baseUrl": "https://{{connection.environment}}.yourapi.com",
    ...
}
```

{% endstep %}
{% endstepper %}

All modules and remote procedures can then use hard-coded `"url": "/uniqueEndpoint"`

{% hint style="info" %}
See the [best practices for Base URL](/custom-apps-documentation/best-practices/base.md#base-url) for more information.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.make.com/custom-apps-documentation/app-components/base/base-url.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
