---
title: Create a shared dashboard
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Dashboards
---

# Create a shared dashboard{% #create-a-shared-dashboard %}
Copy pageCopied
{% tab title="v1" %}

| Datadog site      | API endpoint                                               |
| ----------------- | ---------------------------------------------------------- |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v1/dashboard/public |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v1/dashboard/public |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v1/dashboard/public      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v1/dashboard/public      |
| us2.ddog-gov.com  | POST https://api.us2.ddog-gov.com/api/v1/dashboard/public  |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v1/dashboard/public     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v1/dashboard/public |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v1/dashboard/public |

### Overview

Share a specified private dashboard, generating a URL at which it can be publicly viewed. This endpoint requires any of the following permissions:
`dashboards_public_share``dashboards_embed_share``dashboards_invite_share` 


OAuth apps require the `dashboards_invite_share` authorization [scope](https://docs.datadoghq.com/api/latest/scopes.md#dashboards) to access this endpoint.



### Request

#### Body Data (required)

Create a shared dashboard request body.

{% tab title="Model" %}

| Parent field             | Field                            | Type      | Description                                                                                                                                          |
| ------------------------ | -------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|                          | author                           | object    | User who shared the dashboard.                                                                                                                       |
| author                   | handle                           | string    | Identifier of the user who shared the dashboard.                                                                                                     |
| author                   | name                             | string    | Name of the user who shared the dashboard.                                                                                                           |
|                          | created                          | date-time | Date the dashboard was shared.                                                                                                                       |
|                          | dashboard_id [*required*]   | string    | ID of the dashboard to share.                                                                                                                        |
|                          | dashboard_type [*required*] | enum      | The type of the associated private dashboard. Allowed enum values: `custom_timeboard,custom_screenboard`                                             |
|                          | embeddable_domains               | [string]  | The `SharedDashboard` `embeddable_domains`.                                                                                                          |
|                          | expiration                       | date-time | The time when an OPEN shared dashboard becomes publicly unavailable.                                                                                 |
|                          | global_time                      | object    | Object containing the live span selection for the dashboard.                                                                                         |
| global_time              | live_span                        | enum      | Dashboard global time live_span selection Allowed enum values: `15m,1h,4h,1d,2d,1w,1mo,3mo`                                                          |
|                          | global_time_selectable_enabled   | boolean   | Whether to allow viewers to select a different global time setting for the shared dashboard.                                                         |
|                          | invitees                         | [object]  | The `SharedDashboard` `invitees`.                                                                                                                    |
| invitees                 | access_expiration                | date-time | Time of the invitee expiration. Null means the invite will not expire.                                                                               |
| invitees                 | created_at                       | date-time | Time that the invitee was created.                                                                                                                   |
| invitees                 | email [*required*]          | string    | Email of the invitee.                                                                                                                                |
|                          | last_accessed                    | date-time | The last time the shared dashboard was accessed. Null if never accessed.                                                                             |
|                          | public_url                       | string    | URL of the shared dashboard.                                                                                                                         |
|                          | selectable_template_vars         | [object]  | List of objects representing template variables on the shared dashboard which can have selectable values.                                            |
| selectable_template_vars | default_value                    | string    | The default value of the template variable.                                                                                                          |
| selectable_template_vars | name                             | string    | Name of the template variable.                                                                                                                       |
| selectable_template_vars | prefix                           | string    | The tag/attribute key associated with the template variable.                                                                                         |
| selectable_template_vars | type                             | string    | The type of variable. This is to differentiate between filter variables (interpolated in query) and group by variables (interpolated into group by). |
| selectable_template_vars | visible_tags                     | [string]  | List of visible tag values on the shared dashboard.                                                                                                  |
|                          | share_list                       | [string]  | **DEPRECATED**: List of email addresses that can receive an invitation to access to the shared dashboard.                                            |
|                          | share_type                       | enum      | Type of sharing access (either open to anyone who has the public URL or invite-only). Allowed enum values: `open,invite,embed`                       |
|                          | status                           | enum      | Active means the dashboard is publicly available. Paused means the dashboard is not publicly available. Allowed enum values: `active,paused`         |
|                          | title                            | string    | Title of the shared dashboard.                                                                                                                       |
|                          | token                            | string    | A unique token assigned to the shared dashboard.                                                                                                     |
|                          | viewing_preferences              | object    | The viewing preferences for a shared dashboard.                                                                                                      |
| viewing_preferences      | high_density                     | boolean   | Whether the widgets on the shared dashboard should be displayed with high density.                                                                   |
| viewing_preferences      | theme                            | enum      | The theme of the shared dashboard view. "system" follows your system's default viewing theme. Allowed enum values: `system,light,dark`               |

{% /tab %}

{% tab title="Example" %}
##### 

```json
{
  "dashboard_id": "123-abc-456",
  "dashboard_type": "custom_timeboard",
  "share_type": "open",
  "global_time": {
    "live_span": "1h"
  }
}
```

##### 

```json
{
  "dashboard_id": "123-abc-456",
  "dashboard_type": "custom_timeboard",
  "share_type": "open",
  "global_time": {
    "live_span": "1h"
  },
  "selectable_template_vars": [
    {
      "default_value": "*",
      "name": "group_by_var",
      "type": "group",
      "visible_tags": [
        "selectableValue1",
        "selectableValue2"
      ]
    }
  ]
}
```

{% /tab %}

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
The metadata object associated with how a dashboard has been/will be shared.

| Parent field             | Field                            | Type      | Description                                                                                                                                          |
| ------------------------ | -------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|                          | author                           | object    | User who shared the dashboard.                                                                                                                       |
| author                   | handle                           | string    | Identifier of the user who shared the dashboard.                                                                                                     |
| author                   | name                             | string    | Name of the user who shared the dashboard.                                                                                                           |
|                          | created                          | date-time | Date the dashboard was shared.                                                                                                                       |
|                          | dashboard_id [*required*]   | string    | ID of the dashboard to share.                                                                                                                        |
|                          | dashboard_type [*required*] | enum      | The type of the associated private dashboard. Allowed enum values: `custom_timeboard,custom_screenboard`                                             |
|                          | embeddable_domains               | [string]  | The `SharedDashboard` `embeddable_domains`.                                                                                                          |
|                          | expiration                       | date-time | The time when an OPEN shared dashboard becomes publicly unavailable.                                                                                 |
|                          | global_time                      | object    | Object containing the live span selection for the dashboard.                                                                                         |
| global_time              | live_span                        | enum      | Dashboard global time live_span selection Allowed enum values: `15m,1h,4h,1d,2d,1w,1mo,3mo`                                                          |
|                          | global_time_selectable_enabled   | boolean   | Whether to allow viewers to select a different global time setting for the shared dashboard.                                                         |
|                          | invitees                         | [object]  | The `SharedDashboard` `invitees`.                                                                                                                    |
| invitees                 | access_expiration                | date-time | Time of the invitee expiration. Null means the invite will not expire.                                                                               |
| invitees                 | created_at                       | date-time | Time that the invitee was created.                                                                                                                   |
| invitees                 | email [*required*]          | string    | Email of the invitee.                                                                                                                                |
|                          | last_accessed                    | date-time | The last time the shared dashboard was accessed. Null if never accessed.                                                                             |
|                          | public_url                       | string    | URL of the shared dashboard.                                                                                                                         |
|                          | selectable_template_vars         | [object]  | List of objects representing template variables on the shared dashboard which can have selectable values.                                            |
| selectable_template_vars | default_value                    | string    | The default value of the template variable.                                                                                                          |
| selectable_template_vars | name                             | string    | Name of the template variable.                                                                                                                       |
| selectable_template_vars | prefix                           | string    | The tag/attribute key associated with the template variable.                                                                                         |
| selectable_template_vars | type                             | string    | The type of variable. This is to differentiate between filter variables (interpolated in query) and group by variables (interpolated into group by). |
| selectable_template_vars | visible_tags                     | [string]  | List of visible tag values on the shared dashboard.                                                                                                  |
|                          | share_list                       | [string]  | **DEPRECATED**: List of email addresses that can receive an invitation to access to the shared dashboard.                                            |
|                          | share_type                       | enum      | Type of sharing access (either open to anyone who has the public URL or invite-only). Allowed enum values: `open,invite,embed`                       |
|                          | status                           | enum      | Active means the dashboard is publicly available. Paused means the dashboard is not publicly available. Allowed enum values: `active,paused`         |
|                          | title                            | string    | Title of the shared dashboard.                                                                                                                       |
|                          | token                            | string    | A unique token assigned to the shared dashboard.                                                                                                     |
|                          | viewing_preferences              | object    | The viewing preferences for a shared dashboard.                                                                                                      |
| viewing_preferences      | high_density                     | boolean   | Whether the widgets on the shared dashboard should be displayed with high density.                                                                   |
| viewing_preferences      | theme                            | enum      | The theme of the shared dashboard view. "system" follows your system's default viewing theme. Allowed enum values: `system,light,dark`               |

{% /tab %}

{% tab title="Example" %}

```json
{
  "author": {
    "handle": "test@datadoghq.com",
    "name": "string"
  },
  "created": "2019-09-19T10:00:00.000Z",
  "dashboard_id": "123-abc-456",
  "dashboard_type": "custom_timeboard",
  "embeddable_domains": [
    "https://domain.atlassian.net/",
    "http://myserver.com/"
  ],
  "expiration": "2019-09-19T10:00:00.000Z",
  "global_time": {
    "live_span": "1h"
  },
  "global_time_selectable_enabled": false,
  "invitees": [
    {
      "access_expiration": "2019-09-19T10:00:00.000Z",
      "created_at": "2019-09-19T10:00:00.000Z",
      "email": "test@datadoghq.com"
    }
  ],
  "last_accessed": "2019-09-19T10:00:00.000Z",
  "public_url": "string",
  "selectable_template_vars": [
    {
      "default_value": "*",
      "name": "exampleVar",
      "prefix": "test",
      "type": "string",
      "visible_tags": [
        "selectableValue1",
        "selectableValue2"
      ]
    }
  ],
  "share_list": [
    "test@datadoghq.com",
    "test2@email.com"
  ],
  "share_type": "string",
  "status": "active",
  "title": "string",
  "token": "string",
  "viewing_preferences": {
    "high_density": false,
    "theme": "string"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="404" %}
Dashboard Not Found
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                          \## default
# 
 \# Curl command curl -X POST "https://api.datadoghq.com/api/v1/dashboard/public" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "dashboard_id": "123-abc-456",
  "dashboard_type": "custom_timeboard",
  "global_time": {
    "live_span": "1h"
  },
  "share_type": "open"
}
EOF \## json-request-body
# 
 \# Curl command curl -X POST "https://api.datadoghq.com/api/v1/dashboard/public" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "dashboard_id": "123-abc-456",
  "dashboard_type": "custom_timeboard",
  "share_type": "open"
}
EOF 
                        
##### 
                          \## default
# 
 \# Curl command curl -X POST "https://api.datadoghq.com/api/v1/dashboard/public" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "dashboard_id": "123-abc-456",
  "dashboard_type": "custom_timeboard",
  "global_time": {
    "live_span": "1h"
  },
  "share_type": "open"
}
EOF \## json-request-body
# 
 \# Curl command curl -X POST "https://api.datadoghq.com/api/v1/dashboard/public" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "dashboard_id": "123-abc-456",
  "dashboard_type": "custom_timeboard",
  "share_type": "open"
}
EOF 
                        
##### 

```go
// Create a shared dashboard returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)

func main() {
	// there is a valid "dashboard" in the system
	DashboardID := os.Getenv("DASHBOARD_ID")

	body := datadogV1.SharedDashboard{
		DashboardId:   DashboardID,
		DashboardType: datadogV1.DASHBOARDTYPE_CUSTOM_TIMEBOARD,
		ShareType:     *datadogV1.NewNullableDashboardShareType(datadogV1.DASHBOARDSHARETYPE_OPEN.Ptr()),
		GlobalTime: &datadogV1.DashboardGlobalTime{
			LiveSpan: datadogV1.DASHBOARDGLOBALTIMELIVESPAN_PAST_ONE_HOUR.Ptr(),
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewDashboardsApi(apiClient)
	resp, r, err := api.CreatePublicDashboard(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `DashboardsApi.CreatePublicDashboard`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `DashboardsApi.CreatePublicDashboard`:\n%s\n", responseContent)
}
```

##### 

```go
// Create a shared dashboard with a group template variable returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)

func main() {
	// there is a valid "dashboard" in the system
	DashboardID := os.Getenv("DASHBOARD_ID")

	body := datadogV1.SharedDashboard{
		DashboardId:   DashboardID,
		DashboardType: datadogV1.DASHBOARDTYPE_CUSTOM_TIMEBOARD,
		ShareType:     *datadogV1.NewNullableDashboardShareType(datadogV1.DASHBOARDSHARETYPE_OPEN.Ptr()),
		GlobalTime: &datadogV1.DashboardGlobalTime{
			LiveSpan: datadogV1.DASHBOARDGLOBALTIMELIVESPAN_PAST_ONE_HOUR.Ptr(),
		},
		SelectableTemplateVars: []datadogV1.SelectableTemplateVariableItems{
			{
				DefaultValue: datadog.PtrString("*"),
				Name:         datadog.PtrString("group_by_var"),
				Type:         *datadog.NewNullableString(datadog.PtrString("group")),
				VisibleTags: *datadog.NewNullableList(&[]string{
					"selectableValue1",
					"selectableValue2",
				}),
			},
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewDashboardsApi(apiClient)
	resp, r, err := api.CreatePublicDashboard(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `DashboardsApi.CreatePublicDashboard`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `DashboardsApi.CreatePublicDashboard`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// Create a shared dashboard returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.DashboardsApi;
import com.datadog.api.client.v1.model.DashboardGlobalTime;
import com.datadog.api.client.v1.model.DashboardGlobalTimeLiveSpan;
import com.datadog.api.client.v1.model.DashboardShareType;
import com.datadog.api.client.v1.model.DashboardType;
import com.datadog.api.client.v1.model.SharedDashboard;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    DashboardsApi apiInstance = new DashboardsApi(defaultClient);

    // there is a valid "dashboard" in the system
    String DASHBOARD_ID = System.getenv("DASHBOARD_ID");

    SharedDashboard body =
        new SharedDashboard()
            .dashboardId(DASHBOARD_ID)
            .dashboardType(DashboardType.CUSTOM_TIMEBOARD)
            .shareType(DashboardShareType.OPEN)
            .globalTime(
                new DashboardGlobalTime().liveSpan(DashboardGlobalTimeLiveSpan.PAST_ONE_HOUR));

    try {
      SharedDashboard result = apiInstance.createPublicDashboard(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DashboardsApi#createPublicDashboard");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

##### 

```java
// Create a shared dashboard with a group template variable returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.DashboardsApi;
import com.datadog.api.client.v1.model.DashboardGlobalTime;
import com.datadog.api.client.v1.model.DashboardGlobalTimeLiveSpan;
import com.datadog.api.client.v1.model.DashboardShareType;
import com.datadog.api.client.v1.model.DashboardType;
import com.datadog.api.client.v1.model.SelectableTemplateVariableItems;
import com.datadog.api.client.v1.model.SharedDashboard;
import java.util.Arrays;
import java.util.Collections;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    DashboardsApi apiInstance = new DashboardsApi(defaultClient);

    // there is a valid "dashboard" in the system
    String DASHBOARD_ID = System.getenv("DASHBOARD_ID");

    SharedDashboard body =
        new SharedDashboard()
            .dashboardId(DASHBOARD_ID)
            .dashboardType(DashboardType.CUSTOM_TIMEBOARD)
            .shareType(DashboardShareType.OPEN)
            .globalTime(
                new DashboardGlobalTime().liveSpan(DashboardGlobalTimeLiveSpan.PAST_ONE_HOUR))
            .selectableTemplateVars(
                Collections.singletonList(
                    new SelectableTemplateVariableItems()
                        .defaultValue("*")
                        .name("group_by_var")
                        .type("group")
                        .visibleTags(Arrays.asList("selectableValue1", "selectableValue2"))));

    try {
      SharedDashboard result = apiInstance.createPublicDashboard(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DashboardsApi#createPublicDashboard");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```python
"""
Create a shared dashboard returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.dashboards_api import DashboardsApi
from datadog_api_client.v1.model.dashboard_global_time import DashboardGlobalTime
from datadog_api_client.v1.model.dashboard_global_time_live_span import DashboardGlobalTimeLiveSpan
from datadog_api_client.v1.model.dashboard_share_type import DashboardShareType
from datadog_api_client.v1.model.dashboard_type import DashboardType
from datadog_api_client.v1.model.shared_dashboard import SharedDashboard

# there is a valid "dashboard" in the system
DASHBOARD_ID = environ["DASHBOARD_ID"]

body = SharedDashboard(
    dashboard_id=DASHBOARD_ID,
    dashboard_type=DashboardType.CUSTOM_TIMEBOARD,
    share_type=DashboardShareType.OPEN,
    global_time=DashboardGlobalTime(
        live_span=DashboardGlobalTimeLiveSpan.PAST_ONE_HOUR,
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = DashboardsApi(api_client)
    response = api_instance.create_public_dashboard(body=body)

    print(response)
```

##### 

```python
"""
Create a shared dashboard with a group template variable returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.dashboards_api import DashboardsApi
from datadog_api_client.v1.model.dashboard_global_time import DashboardGlobalTime
from datadog_api_client.v1.model.dashboard_global_time_live_span import DashboardGlobalTimeLiveSpan
from datadog_api_client.v1.model.dashboard_share_type import DashboardShareType
from datadog_api_client.v1.model.dashboard_type import DashboardType
from datadog_api_client.v1.model.selectable_template_variable_items import SelectableTemplateVariableItems
from datadog_api_client.v1.model.shared_dashboard import SharedDashboard

# there is a valid "dashboard" in the system
DASHBOARD_ID = environ["DASHBOARD_ID"]

body = SharedDashboard(
    dashboard_id=DASHBOARD_ID,
    dashboard_type=DashboardType.CUSTOM_TIMEBOARD,
    share_type=DashboardShareType.OPEN,
    global_time=DashboardGlobalTime(
        live_span=DashboardGlobalTimeLiveSpan.PAST_ONE_HOUR,
    ),
    selectable_template_vars=[
        SelectableTemplateVariableItems(
            default_value="*",
            name="group_by_var",
            type="group",
            visible_tags=[
                "selectableValue1",
                "selectableValue2",
            ],
        ),
    ],
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = DashboardsApi(api_client)
    response = api_instance.create_public_dashboard(body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# Create a shared dashboard returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::DashboardsAPI.new

# there is a valid "dashboard" in the system
DASHBOARD_ID = ENV["DASHBOARD_ID"]

body = DatadogAPIClient::V1::SharedDashboard.new({
  dashboard_id: DASHBOARD_ID,
  dashboard_type: DatadogAPIClient::V1::DashboardType::CUSTOM_TIMEBOARD,
  share_type: DatadogAPIClient::V1::DashboardShareType::OPEN,
  global_time: DatadogAPIClient::V1::DashboardGlobalTime.new({
    live_span: DatadogAPIClient::V1::DashboardGlobalTimeLiveSpan::PAST_ONE_HOUR,
  }),
})
p api_instance.create_public_dashboard(body)
```

##### 

```ruby
# Create a shared dashboard with a group template variable returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::DashboardsAPI.new

# there is a valid "dashboard" in the system
DASHBOARD_ID = ENV["DASHBOARD_ID"]

body = DatadogAPIClient::V1::SharedDashboard.new({
  dashboard_id: DASHBOARD_ID,
  dashboard_type: DatadogAPIClient::V1::DashboardType::CUSTOM_TIMEBOARD,
  share_type: DatadogAPIClient::V1::DashboardShareType::OPEN,
  global_time: DatadogAPIClient::V1::DashboardGlobalTime.new({
    live_span: DatadogAPIClient::V1::DashboardGlobalTimeLiveSpan::PAST_ONE_HOUR,
  }),
  selectable_template_vars: [
    DatadogAPIClient::V1::SelectableTemplateVariableItems.new({
      default_value: "*",
      name: "group_by_var",
      type: "group",
      visible_tags: [
        "selectableValue1",
        "selectableValue2",
      ],
    }),
  ],
})
p api_instance.create_public_dashboard(body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```rust
// Create a shared dashboard returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_dashboards::DashboardsAPI;
use datadog_api_client::datadogV1::model::DashboardGlobalTime;
use datadog_api_client::datadogV1::model::DashboardGlobalTimeLiveSpan;
use datadog_api_client::datadogV1::model::DashboardShareType;
use datadog_api_client::datadogV1::model::DashboardType;
use datadog_api_client::datadogV1::model::SharedDashboard;

#[tokio::main]
async fn main() {
    // there is a valid "dashboard" in the system
    let dashboard_id = std::env::var("DASHBOARD_ID").unwrap();
    let body = SharedDashboard::new(dashboard_id.clone(), DashboardType::CUSTOM_TIMEBOARD)
        .global_time(
            DashboardGlobalTime::new().live_span(DashboardGlobalTimeLiveSpan::PAST_ONE_HOUR),
        )
        .share_type(Some(DashboardShareType::OPEN));
    let configuration = datadog::Configuration::new();
    let api = DashboardsAPI::with_config(configuration);
    let resp = api.create_public_dashboard(body).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

##### 

```rust
// Create a shared dashboard with a group template variable returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_dashboards::DashboardsAPI;
use datadog_api_client::datadogV1::model::DashboardGlobalTime;
use datadog_api_client::datadogV1::model::DashboardGlobalTimeLiveSpan;
use datadog_api_client::datadogV1::model::DashboardShareType;
use datadog_api_client::datadogV1::model::DashboardType;
use datadog_api_client::datadogV1::model::SelectableTemplateVariableItems;
use datadog_api_client::datadogV1::model::SharedDashboard;

#[tokio::main]
async fn main() {
    // there is a valid "dashboard" in the system
    let dashboard_id = std::env::var("DASHBOARD_ID").unwrap();
    let body = SharedDashboard::new(dashboard_id.clone(), DashboardType::CUSTOM_TIMEBOARD)
        .global_time(
            DashboardGlobalTime::new().live_span(DashboardGlobalTimeLiveSpan::PAST_ONE_HOUR),
        )
        .selectable_template_vars(Some(vec![SelectableTemplateVariableItems::new()
            .default_value("*".to_string())
            .name("group_by_var".to_string())
            .type_(Some("group".to_string()))
            .visible_tags(Some(vec![
                "selectableValue1".to_string(),
                "selectableValue2".to_string(),
            ]))]))
        .share_type(Some(DashboardShareType::OPEN));
    let configuration = datadog::Configuration::new();
    let api = DashboardsAPI::with_config(configuration);
    let resp = api.create_public_dashboard(body).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * Create a shared dashboard returns "OK" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v1.DashboardsApi(configuration);

// there is a valid "dashboard" in the system
const DASHBOARD_ID = process.env.DASHBOARD_ID as string;

const params: v1.DashboardsApiCreatePublicDashboardRequest = {
  body: {
    dashboardId: DASHBOARD_ID,
    dashboardType: "custom_timeboard",
    shareType: "open",
    globalTime: {
      liveSpan: "1h",
    },
  },
};

apiInstance
  .createPublicDashboard(params)
  .then((data: v1.SharedDashboard) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

##### 

```typescript
/**
 * Create a shared dashboard with a group template variable returns "OK" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v1.DashboardsApi(configuration);

// there is a valid "dashboard" in the system
const DASHBOARD_ID = process.env.DASHBOARD_ID as string;

const params: v1.DashboardsApiCreatePublicDashboardRequest = {
  body: {
    dashboardId: DASHBOARD_ID,
    dashboardType: "custom_timeboard",
    shareType: "open",
    globalTime: {
      liveSpan: "1h",
    },
    selectableTemplateVars: [
      {
        defaultValue: "*",
        name: "group_by_var",
        type: "group",
        visibleTags: ["selectableValue1", "selectableValue2"],
      },
    ],
  },
};

apiInstance
  .createPublicDashboard(params)
  .then((data: v1.SharedDashboard) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}
