> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gleap.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Data regions

> Choose where your Gleap data lives and point the SDKs and the API at the right region

Gleap offers two data regions: **EU** (default) and **US**. You choose the region when you sign up, and your customer content is stored and processed in the selected region.

Each region has its own API, websocket, realtime and file hosts. If your project lives in the EU region, there is nothing to do: every SDK and all API examples in this documentation use the EU hosts by default. If your project lives in the US region, you need to

1. tell the SDK which region to use with **one call before `initialize`** (see [Select the region in the SDK](#select-the-region-in-the-sdk)), and
2. send your REST API and server-to-server requests to the US API host (see [REST API and server-to-server](#rest-api-and-server-to-server)).

<Note>
  Depending on the AI models you enable for your project, third-party AI model providers may process content outside of the selected region.
</Note>

## Hosts per region

These hosts are region specific. They store or process customer content for projects of that region only.

| Purpose                                     | EU (default)                                       | US                        |
| ------------------------------------------- | -------------------------------------------------- | ------------------------- |
| API                                         | `api.eu.gleap.ai` (legacy: `api.gleap.io`)         | `api.us.gleap.ai`         |
| Dashboard API                               | `dashapi.eu.gleap.ai` (legacy: `dashapi.gleap.io`) | `dashapi.us.gleap.ai`     |
| SDK websocket (session and event streaming) | `ws.eu.gleap.ai` (legacy: `ws.gleap.io`)           | `ws.us.gleap.ai`          |
| Realtime (conversations and notifications)  | `sockets.eu.gleap.ai` (legacy: `sockets.gleap.io`) | `sockets.us.gleap.ai`     |
| Files                                       | `files.gleap.io`                                   | `files.us.gleap.ai`       |
| Static files                                | `staticfiles.gleap.io`                             | `staticfiles.us.gleap.ai` |

<Info>
  The EU region is served on `*.eu.gleap.ai`. The native SDKs (iOS, Android and the wrappers built on them) use these hosts by default from v18; the JavaScript SDK keeps the `*.gleap.io` hosts as its EU default for now, so existing Content Security Policies keep working — allow `*.gleap.ai` in your CSP today so a later release can switch without any change on your side. The legacy `api.gleap.io`, `dashapi.gleap.io`, `ws.gleap.io` and `sockets.gleap.io` hosts keep working and point at the same EU region, so existing integrations and older SDK versions need no change.
</Info>

### Global hosts

The following hosts are the same for every region. They only serve static assets and apps and do not store customer content.

| Host                                                       | Purpose                          |
| ---------------------------------------------------------- | -------------------------------- |
| `sdk.gleap.io`                                             | JavaScript SDK                   |
| `messenger-app.gleap.io`                                   | Messenger app loaded by the SDKs |
| `js.gleap.io`, `static.gleap.io`, `outboundmedia.gleap.io` | Static assets                    |
| `app.gleap.io`                                             | Gleap dashboard                  |

<Info>
  Using a Content Security Policy or a firewall allowlist? Allow both `*.gleap.io` and `*.gleap.ai`. See [Content Security Policy (CSP)](/documentation/javascript/content-security-policy) for the full list of directives.
</Info>

## How do I know my region?

Open your project in the [Gleap dashboard](https://app.gleap.io) and navigate to the project settings. The data region of the project is shown next to the API token.

## Select the region in the SDK

SDK **v18.0.0** adds `setRegion` on all platforms. It sets the API, websocket and realtime hosts together and must be called **before** `initialize`. The default region is `eu`, so EU projects don't need to call it.

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    Gleap.setRegion("us");
    Gleap.initialize("API_KEY");
    ```

    When using the code snippet, add `window.Gleap.setRegion("us");` right before `window.Gleap.initialize("API_KEY")`.
  </Tab>

  <Tab title="iOS">
    ```swift theme={null}
    // Swift
    Gleap.setRegion("us")
    Gleap.initialize(withToken: "API-TOKEN")
    ```

    ```objectivec theme={null}
    // Objective-C
    [Gleap setRegion:@"us"];
    [Gleap initializeWithToken: @"API-TOKEN"];
    ```
  </Tab>

  <Tab title="Android">
    ```java theme={null}
    Gleap.getInstance().setRegion("us");
    Gleap.initialize("YOUR_API_KEY", this);
    ```
  </Tab>

  <Tab title="React Native / Expo">
    ```javascript theme={null}
    Gleap.setRegion("us");
    Gleap.initialize("Your_TOKEN");
    ```
  </Tab>

  <Tab title="Flutter">
    ```dart theme={null}
    await Gleap.setRegion(region: 'us');
    Gleap.initialize(token: 'YOUR_API_KEY');
    ```
  </Tab>

  <Tab title="Ionic / Capacitor">
    ```javascript theme={null}
    Gleap.setRegion({ region: "us" });
    Gleap.initialize("API_KEY");
    ```
  </Tab>
</Tabs>

<Note>
  FlutterFlow apps use the Flutter SDK, so the Flutter call applies. Data regions are not supported by the Cordova, Unity, .NET MAUI and Windows Desktop SDKs yet.
</Note>

### Order rule and manual host setters

`setRegion` is all you need in almost every setup. The manual host setters still exist for special cases (for example when you route Gleap traffic through your own proxy):

| Setter            | Host          |
| ----------------- | ------------- |
| `setApiUrl`       | API           |
| `setWSApiUrl`     | SDK websocket |
| `setRealtimeHost` | Realtime      |
| `setFrameUrl`     | Messenger app |
| `setBannerUrl`    | Banners       |
| `setModalUrl`     | Modals        |

The JavaScript SDK offers all of them; the native SDKs gain the same setters in v18.

The order matters:

* Call `setRegion` **before** `initialize`.
* A manual setter called **after** `setRegion` overrides that single host. All other hosts keep the value of the selected region.
* `setRegion` called after `setApiUrl`, `setWSApiUrl` or `setRealtimeHost` replaces these three hosts with the region's hosts again, so always call `setRegion` first.

```javascript theme={null}
Gleap.setRegion("us");
// Optional: override a single host after selecting the region.
Gleap.setApiUrl("https://gleap-proxy.example.com");
Gleap.initialize("API_KEY");
```

## REST API and server-to-server

The base URL of the [REST API](/documentation/server/api-overview), the [server-side event tracking API](/documentation/server/rest-api) and the [Conversations API (server-to-server)](/documentation/s2s/overview) is the API host of your region:

| Data region  | API host                  |
| ------------ | ------------------------- |
| EU (default) | `https://api.gleap.io`    |
| US           | `https://api.us.gleap.ai` |

```bash theme={null}
# US region
curl -X GET https://api.us.gleap.ai/v3/tickets \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Project: YOUR_PROJECT_ID"
```

<Warning>
  API tokens are per project and only valid in the project's region. A token does not work against the API host of another region.
</Warning>
