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

# Timezone Handling in Guest Token

> Pass a timezone parameter when generating a guest token to ensure SQL queries run in the correct timezone and date/time fields are consistently formatted across regions.

## Overview

Databrain allows you to pass a **timezone parameter (`params.timezone`)** while generating a guest token. This ensures that:

* SQL queries are executed in the correct timezone
* Date/time fields are consistently formatted
* Dashboard users across regions see accurate time-based insights

## Supported Data Sources

Timezone-aware execution is supported for:

* Clickhouse
* Trino
* Redshift
* CockroachDB
* Postgres
* MSSQL

## What is `params.timezone`?

```
params.timezone -- string
```

* Accepts a valid IANA timezone string
* Sets the database session timezone
* Ensures all date/time operations respect the specified timezone

## Common Timezone Values

| Timezone                | Description                |
| :---------------------- | :------------------------- |
| `"UTC"`                 | Coordinated Universal Time |
| `"America/New_York"`    | Eastern Time (US)          |
| `"America/Los_Angeles"` | Pacific Time (US)          |
| `"Europe/London"`       | GMT / BST                  |
| `"Asia/Kolkata"`        | Indian Standard Time       |
| `"Australia/Sydney"`    | Australian Eastern Time    |

## Guest Token Example with Timezone

```json theme={"dark"}
{
  "clientId": "user-456",
  "dataAppName": "sales-dashboard",
  "params": {
    "timezone": "America/New_York"
  }
}
```

## Step-by-Step Implementation

<Steps>
  <Step title="Create a DataApp and API Token">
    Create the required resources via the following APIs:

    * [Create DataApp](/developer-docs/helpers/api-reference/create-data-app)
    * [Create API Token for corresponding DataApp](/developer-docs/helpers/api-reference/create-api-token)
  </Step>

  <Step title="Create a Datamart via API">
    Ensure your dataset contains a timestamp column. Create a Datamart using the [Create Datamart API](/developer-docs/helpers/api-reference/create-datamart) and specify [isApplyTimezone](/developer-docs/helpers/api-reference/create-datamart#isApplyTimezone).
  </Step>

  <Step title="Create an Embed via API">
    Create an Embed using your created datamart via the [Create Embed API](/developer-docs/helpers/api-reference/create-dashboard-embed) inside the created DataApp.
  </Step>

  <Step title="Generate Guest Token with Timezone">
    Include the `params.timezone` field in your payload when calling the [Guest Token API](/developer-docs/helpers/api-reference/token).

    ```json theme={"dark"}
    {
      "clientId": "user-456",
      "dataAppName": "sales-dashboard",
      "params": {
        "timezone": "America/New_York"
      }
    }
    ```

    Use an appropriate IANA timezone (e.g., `"Asia/Kolkata"`).
  </Step>

  <Step title="Validate in Demo Link">
    Open your **demo link**, click **+ Create Metric**, and drag and drop the **date column** into the chart.

    Then:

    1. Open **Browser DevTools → Network Tab**
    2. Inspect the executed query

    Verify:

    * The timezone value is applied in the query/session
    * `"timezone": "<your-timezone>"` is present inside the request payload (`params`)
  </Step>
</Steps>

## How It Works Internally

The timezone is applied at the database session level. Queries run as if the database is operating in that timezone. Functions like `NOW()`, `DATE_TRUNC`, and `TIMESTAMP` conversions will all respect the passed timezone.
