---
title: Create a secure embed for a dashboard
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Dashboard Secure Embed
---

# Create a secure embed for a dashboard{% #create-a-secure-embed-for-a-dashboard %}
Copy pageCopied
{% tab title="v2" %}
**Note**: This endpoint is in preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
| Datadog site      | API endpoint                                                                           |
| ----------------- | -------------------------------------------------------------------------------------- |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/dashboard/{dashboard_id}/shared/secure-embed |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/dashboard/{dashboard_id}/shared/secure-embed |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/dashboard/{dashboard_id}/shared/secure-embed      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/dashboard/{dashboard_id}/shared/secure-embed      |
| us2.ddog-gov.com  | POST https://api.us2.ddog-gov.com/api/v2/dashboard/{dashboard_id}/shared/secure-embed  |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/dashboard/{dashboard_id}/shared/secure-embed     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/dashboard/{dashboard_id}/shared/secure-embed |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/dashboard/{dashboard_id}/shared/secure-embed |

### Overview

Create a secure embed share for a dashboard. The response includes a one-time `credential` used for HMAC-SHA256 signing. Store it securely — it cannot be retrieved again. This endpoint requires the `dashboards_embed_share` permission.

OAuth apps require the `dashboards_embed_share` authorization [scope](https://docs.datadoghq.com/api/latest/scopes.md#dashboard-secure-embed) to access this endpoint.



### Arguments

#### Path Parameters

| Name                           | Type   | Description              |
| ------------------------------ | ------ | ------------------------ |
| dashboard_id [*required*] | string | The ID of the dashboard. |

### Request

#### Body Data (required)

Secure embed creation request body.

{% tab title="Model" %}

| Parent field             | Field                                      | Type     | Description                                                                                                                                        |
| ------------------------ | ------------------------------------------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|                          | data [*required*]                     | object   | Data object for creating a secure embed.                                                                                                           |
| data                     | attributes [*required*]               | object   | Attributes for creating a secure embed shared dashboard.                                                                                           |
| attributes               | global_time [*required*]              | object   | Default time range configuration for the secure embed.                                                                                             |
| global_time              | live_span                                  | enum     | Dashboard global time live_span selection. Allowed enum values: `15m,1h,4h,1d,2d,1w,1mo,3mo`                                                       |
| attributes               | global_time_selectable [*required*]   | boolean  | Whether viewers can change the time range.                                                                                                         |
| attributes               | selectable_template_vars [*required*] | [object] | Template variables viewers can modify.                                                                                                             |
| selectable_template_vars | default_values                             | [string] | Default selected values for the variable.                                                                                                          |
| selectable_template_vars | name                                       | string   | Name of the template variable. Usually matches the prefix unless you want a different display name.                                                |
| selectable_template_vars | prefix                                     | string   | Tag prefix for the variable (e.g., `environment`, `service`).                                                                                      |
| selectable_template_vars | visible_tags                               | [string] | Restrict which tag values are visible to the viewer.                                                                                               |
| attributes               | status [*required*]                   | enum     | The status of the secure embed share. Active means the shared dashboard is available. Paused means it is not. Allowed enum values: `active,paused` |
| attributes               | title [*required*]                    | string   | Display title for the shared dashboard.                                                                                                            |
| attributes               | viewing_preferences [*required*]      | object   | Display settings for the secure embed shared dashboard.                                                                                            |
| viewing_preferences      | high_density                               | boolean  | Whether widgets are displayed in high density mode.                                                                                                |
| viewing_preferences      | theme                                      | enum     | The theme of the shared dashboard view. `system` follows the viewer's system default. Allowed enum values: `system,light,dark`                     |
| data                     | type [*required*]                     | enum     | Resource type for secure embed create requests. Allowed enum values: `secure_embed_request`                                                        |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "global_time": {
        "live_span": "1h"
      },
      "global_time_selectable": true,
      "selectable_template_vars": [
        {
          "default_values": [
            "1"
          ],
          "name": "org_id",
          "prefix": "org_id",
          "visible_tags": [
            "1"
          ]
        }
      ],
      "status": "active",
      "title": "Q1 Metrics Dashboard",
      "viewing_preferences": {
        "high_density": false,
        "theme": "system"
      }
    },
    "type": "secure_embed_request"
  }
}
```

{% /tab %}

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
Response for creating a secure embed shared dashboard.

| Parent field             | Field                        | Type     | Description                                                                                                                                        |
| ------------------------ | ---------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|                          | data [*required*]       | object   | Data object for a secure embed create response.                                                                                                    |
| data                     | attributes [*required*] | object   | Attributes of a newly created secure embed shared dashboard.                                                                                       |
| attributes               | created_at                   | string   | Creation timestamp.                                                                                                                                |
| attributes               | credential                   | string   | The secret credential used for HMAC signing. Returned only on creation. Store securely — it cannot be retrieved again.                             |
| attributes               | dashboard_id                 | string   | The source dashboard ID.                                                                                                                           |
| attributes               | global_time                  | object   | Default time range configuration for the secure embed.                                                                                             |
| global_time              | live_span                    | enum     | Dashboard global time live_span selection. Allowed enum values: `15m,1h,4h,1d,2d,1w,1mo,3mo`                                                       |
| attributes               | global_time_selectable       | boolean  | Whether time range is viewer-selectable.                                                                                                           |
| attributes               | id                           | string   | Internal share ID.                                                                                                                                 |
| attributes               | selectable_template_vars     | [object] | Template variables with their configuration.                                                                                                       |
| selectable_template_vars | default_values               | [string] | Default selected values for the variable.                                                                                                          |
| selectable_template_vars | name                         | string   | Name of the template variable. Usually matches the prefix unless you want a different display name.                                                |
| selectable_template_vars | prefix                       | string   | Tag prefix for the variable (e.g., `environment`, `service`).                                                                                      |
| selectable_template_vars | visible_tags                 | [string] | Restrict which tag values are visible to the viewer.                                                                                               |
| attributes               | share_type                   | enum     | The type of share. Always `secure_embed`. Allowed enum values: `secure_embed`                                                                      |
| attributes               | status                       | enum     | The status of the secure embed share. Active means the shared dashboard is available. Paused means it is not. Allowed enum values: `active,paused` |
| attributes               | title                        | string   | Display title.                                                                                                                                     |
| attributes               | token                        | string   | Public share token.                                                                                                                                |
| attributes               | url                          | string   | CDN URL for the shared dashboard.                                                                                                                  |
| attributes               | viewing_preferences          | object   | Display settings for the secure embed shared dashboard.                                                                                            |
| viewing_preferences      | high_density                 | boolean  | Whether widgets are displayed in high density mode.                                                                                                |
| viewing_preferences      | theme                        | enum     | The theme of the shared dashboard view. `system` follows the viewer's system default. Allowed enum values: `system,light,dark`                     |
| data                     | id [*required*]         | string   | Internal share ID.                                                                                                                                 |
| data                     | type [*required*]       | enum     | Resource type for secure embed create responses. Allowed enum values: `secure_embed_create_response`                                               |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "created_at": "2026-03-11T18:30:00.000000",
      "credential": "A1b2C3d4E5f6G7h8I9j0K1l2M3n4O5p6Q7r8S9t0U1v2",
      "dashboard_id": "abc-def-ghi",
      "global_time": {
        "live_span": "1h"
      },
      "global_time_selectable": true,
      "id": "12345",
      "selectable_template_vars": [
        {
          "default_values": [
            "1"
          ],
          "name": "org_id",
          "prefix": "org_id",
          "visible_tags": [
            "1"
          ]
        }
      ],
      "share_type": "secure_embed",
      "status": "active",
      "title": "Q1 Metrics Dashboard",
      "token": "s3cur3t0k3n-abcdef123456",
      "url": "https://p.datadoghq.com/sb/secure-embed/s3cur3t0k3n-abcdef123456",
      "viewing_preferences": {
        "high_density": false,
        "theme": "system"
      }
    },
    "id": "12345",
    "type": "secure_embed_create_response"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail                   | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                     | object   | Non-standard meta-information about the error                                   |
| errors       | source                   | object   | References to the source of the error.                                          |
| source       | header                   | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter                | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer                  | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status                   | string   | Status code of the response.                                                    |
| errors       | title                    | string   | Short human-readable summary of the error.                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="404" %}
Dashboard Not Found
{% tab title="Model" %}
API error response.

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail                   | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                     | object   | Non-standard meta-information about the error                                   |
| errors       | source                   | object   | References to the source of the error.                                          |
| source       | header                   | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter                | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer                  | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status                   | string   | Status code of the response.                                                    |
| errors       | title                    | string   | Short human-readable summary of the error.                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="409" %}
Conflict — max 1000 share URLs per dashboard exceeded
{% tab title="Model" %}
API error response.

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail                   | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                     | object   | Non-standard meta-information about the error                                   |
| errors       | source                   | object   | References to the source of the error.                                          |
| source       | header                   | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter                | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer                  | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status                   | string   | Status code of the response.                                                    |
| errors       | title                    | string   | Short human-readable summary of the error.                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \## default
# 
 \# Path parameters export dashboard_id="abc-def-ghi" \# Curl command curl -X POST "https://api.datadoghq.com/api/v2/dashboard/${dashboard_id}/shared/secure-embed" \
-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
{
  "data": {
    "attributes": {
      "global_time": {
        "live_span": "1h"
      },
      "global_time_selectable": true,
      "selectable_template_vars": [
        {
          "default_values": [
            "1"
          ],
          "name": "org_id",
          "prefix": "org_id",
          "visible_tags": [
            "1"
          ]
        }
      ],
      "status": "active",
      "title": "Q1 Metrics Dashboard",
      "viewing_preferences": {
        "high_density": false,
        "theme": "system"
      }
    },
    "type": "secure_embed_request"
  }
}
EOF 
                
##### 

```python
"""
Create a secure embed for a dashboard returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.dashboard_secure_embed_api import DashboardSecureEmbedApi
from datadog_api_client.v2.model.secure_embed_create_request import SecureEmbedCreateRequest
from datadog_api_client.v2.model.secure_embed_create_request_attributes import SecureEmbedCreateRequestAttributes
from datadog_api_client.v2.model.secure_embed_create_request_data import SecureEmbedCreateRequestData
from datadog_api_client.v2.model.secure_embed_global_time import SecureEmbedGlobalTime
from datadog_api_client.v2.model.secure_embed_global_time_live_span import SecureEmbedGlobalTimeLiveSpan
from datadog_api_client.v2.model.secure_embed_request_type import SecureEmbedRequestType
from datadog_api_client.v2.model.secure_embed_selectable_template_variable import SecureEmbedSelectableTemplateVariable
from datadog_api_client.v2.model.secure_embed_status import SecureEmbedStatus
from datadog_api_client.v2.model.secure_embed_viewing_preferences import SecureEmbedViewingPreferences
from datadog_api_client.v2.model.secure_embed_viewing_preferences_theme import SecureEmbedViewingPreferencesTheme

body = SecureEmbedCreateRequest(
    data=SecureEmbedCreateRequestData(
        attributes=SecureEmbedCreateRequestAttributes(
            global_time=SecureEmbedGlobalTime(
                live_span=SecureEmbedGlobalTimeLiveSpan.PAST_ONE_HOUR,
            ),
            global_time_selectable=True,
            selectable_template_vars=[
                SecureEmbedSelectableTemplateVariable(
                    default_values=[
                        "1",
                    ],
                    name="org_id",
                    prefix="org_id",
                    visible_tags=[
                        "1",
                    ],
                ),
            ],
            status=SecureEmbedStatus.ACTIVE,
            title="Q1 Metrics Dashboard",
            viewing_preferences=SecureEmbedViewingPreferences(
                high_density=False,
                theme=SecureEmbedViewingPreferencesTheme.SYSTEM,
            ),
        ),
        type=SecureEmbedRequestType.SECURE_EMBED_REQUEST,
    ),
)

configuration = Configuration()
configuration.unstable_operations["create_dashboard_secure_embed"] = True
with ApiClient(configuration) as api_client:
    api_instance = DashboardSecureEmbedApi(api_client)
    response = api_instance.create_dashboard_secure_embed(dashboard_id="dashboard_id", 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 secure embed for a dashboard returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.unstable_operations["v2.create_dashboard_secure_embed".to_sym] = true
end
api_instance = DatadogAPIClient::V2::DashboardSecureEmbedAPI.new

body = DatadogAPIClient::V2::SecureEmbedCreateRequest.new({
  data: DatadogAPIClient::V2::SecureEmbedCreateRequestData.new({
    attributes: DatadogAPIClient::V2::SecureEmbedCreateRequestAttributes.new({
      global_time: DatadogAPIClient::V2::SecureEmbedGlobalTime.new({
        live_span: DatadogAPIClient::V2::SecureEmbedGlobalTimeLiveSpan::PAST_ONE_HOUR,
      }),
      global_time_selectable: true,
      selectable_template_vars: [
        DatadogAPIClient::V2::SecureEmbedSelectableTemplateVariable.new({
          default_values: [
            "1",
          ],
          name: "org_id",
          prefix: "org_id",
          visible_tags: [
            "1",
          ],
        }),
      ],
      status: DatadogAPIClient::V2::SecureEmbedStatus::ACTIVE,
      title: "Q1 Metrics Dashboard",
      viewing_preferences: DatadogAPIClient::V2::SecureEmbedViewingPreferences.new({
        high_density: false,
        theme: DatadogAPIClient::V2::SecureEmbedViewingPreferencesTheme::SYSTEM,
      }),
    }),
    type: DatadogAPIClient::V2::SecureEmbedRequestType::SECURE_EMBED_REQUEST,
  }),
})
p api_instance.create_dashboard_secure_embed("dashboard_id", 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"
##### 

```go
// Create a secure embed for a 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/datadogV2"
)

func main() {
	body := datadogV2.SecureEmbedCreateRequest{
		Data: datadogV2.SecureEmbedCreateRequestData{
			Attributes: datadogV2.SecureEmbedCreateRequestAttributes{
				GlobalTime: datadogV2.SecureEmbedGlobalTime{
					LiveSpan: datadogV2.SECUREEMBEDGLOBALTIMELIVESPAN_PAST_ONE_HOUR.Ptr(),
				},
				GlobalTimeSelectable: true,
				SelectableTemplateVars: []datadogV2.SecureEmbedSelectableTemplateVariable{
					{
						DefaultValues: []string{
							"1",
						},
						Name:   datadog.PtrString("org_id"),
						Prefix: datadog.PtrString("org_id"),
						VisibleTags: []string{
							"1",
						},
					},
				},
				Status: datadogV2.SECUREEMBEDSTATUS_ACTIVE,
				Title:  "Q1 Metrics Dashboard",
				ViewingPreferences: datadogV2.SecureEmbedViewingPreferences{
					HighDensity: datadog.PtrBool(false),
					Theme:       datadogV2.SECUREEMBEDVIEWINGPREFERENCESTHEME_SYSTEM.Ptr(),
				},
			},
			Type: datadogV2.SECUREEMBEDREQUESTTYPE_SECURE_EMBED_REQUEST,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.CreateDashboardSecureEmbed", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewDashboardSecureEmbedApi(apiClient)
	resp, r, err := api.CreateDashboardSecureEmbed(ctx, "dashboard_id", body)

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `DashboardSecureEmbedApi.CreateDashboardSecureEmbed`:\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 secure embed for a dashboard returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.DashboardSecureEmbedApi;
import com.datadog.api.client.v2.model.SecureEmbedCreateRequest;
import com.datadog.api.client.v2.model.SecureEmbedCreateRequestAttributes;
import com.datadog.api.client.v2.model.SecureEmbedCreateRequestData;
import com.datadog.api.client.v2.model.SecureEmbedCreateResponse;
import com.datadog.api.client.v2.model.SecureEmbedGlobalTime;
import com.datadog.api.client.v2.model.SecureEmbedGlobalTimeLiveSpan;
import com.datadog.api.client.v2.model.SecureEmbedRequestType;
import com.datadog.api.client.v2.model.SecureEmbedSelectableTemplateVariable;
import com.datadog.api.client.v2.model.SecureEmbedStatus;
import com.datadog.api.client.v2.model.SecureEmbedViewingPreferences;
import com.datadog.api.client.v2.model.SecureEmbedViewingPreferencesTheme;
import java.util.Collections;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setUnstableOperationEnabled("v2.createDashboardSecureEmbed", true);
    DashboardSecureEmbedApi apiInstance = new DashboardSecureEmbedApi(defaultClient);

    SecureEmbedCreateRequest body =
        new SecureEmbedCreateRequest()
            .data(
                new SecureEmbedCreateRequestData()
                    .attributes(
                        new SecureEmbedCreateRequestAttributes()
                            .globalTime(
                                new SecureEmbedGlobalTime()
                                    .liveSpan(SecureEmbedGlobalTimeLiveSpan.PAST_ONE_HOUR))
                            .globalTimeSelectable(true)
                            .selectableTemplateVars(
                                Collections.singletonList(
                                    new SecureEmbedSelectableTemplateVariable()
                                        .defaultValues(Collections.singletonList("1"))
                                        .name("org_id")
                                        .prefix("org_id")
                                        .visibleTags(Collections.singletonList("1"))))
                            .status(SecureEmbedStatus.ACTIVE)
                            .title("Q1 Metrics Dashboard")
                            .viewingPreferences(
                                new SecureEmbedViewingPreferences()
                                    .highDensity(false)
                                    .theme(SecureEmbedViewingPreferencesTheme.SYSTEM)))
                    .type(SecureEmbedRequestType.SECURE_EMBED_REQUEST));

    try {
      SecureEmbedCreateResponse result =
          apiInstance.createDashboardSecureEmbed("abc-def-ghi", body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println(
          "Exception when calling DashboardSecureEmbedApi#createDashboardSecureEmbed");
      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"
##### 

```rust
// Create a secure embed for a dashboard returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_dashboard_secure_embed::DashboardSecureEmbedAPI;
use datadog_api_client::datadogV2::model::SecureEmbedCreateRequest;
use datadog_api_client::datadogV2::model::SecureEmbedCreateRequestAttributes;
use datadog_api_client::datadogV2::model::SecureEmbedCreateRequestData;
use datadog_api_client::datadogV2::model::SecureEmbedGlobalTime;
use datadog_api_client::datadogV2::model::SecureEmbedGlobalTimeLiveSpan;
use datadog_api_client::datadogV2::model::SecureEmbedRequestType;
use datadog_api_client::datadogV2::model::SecureEmbedSelectableTemplateVariable;
use datadog_api_client::datadogV2::model::SecureEmbedStatus;
use datadog_api_client::datadogV2::model::SecureEmbedViewingPreferences;
use datadog_api_client::datadogV2::model::SecureEmbedViewingPreferencesTheme;

#[tokio::main]
async fn main() {
    let body = SecureEmbedCreateRequest::new(SecureEmbedCreateRequestData::new(
        SecureEmbedCreateRequestAttributes::new(
            SecureEmbedGlobalTime::new().live_span(SecureEmbedGlobalTimeLiveSpan::PAST_ONE_HOUR),
            true,
            vec![SecureEmbedSelectableTemplateVariable::new()
                .default_values(vec!["1".to_string()])
                .name("org_id".to_string())
                .prefix("org_id".to_string())
                .visible_tags(vec!["1".to_string()])],
            SecureEmbedStatus::ACTIVE,
            "Q1 Metrics Dashboard".to_string(),
            SecureEmbedViewingPreferences::new()
                .high_density(false)
                .theme(SecureEmbedViewingPreferencesTheme::SYSTEM),
        ),
        SecureEmbedRequestType::SECURE_EMBED_REQUEST,
    ));
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.CreateDashboardSecureEmbed", true);
    let api = DashboardSecureEmbedAPI::with_config(configuration);
    let resp = api
        .create_dashboard_secure_embed("dashboard_id".to_string(), 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 secure embed for a dashboard returns "OK" response
 */

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

const configuration = client.createConfiguration();
configuration.unstableOperations["v2.createDashboardSecureEmbed"] = true;
const apiInstance = new v2.DashboardSecureEmbedApi(configuration);

const params: v2.DashboardSecureEmbedApiCreateDashboardSecureEmbedRequest = {
  body: {
    data: {
      attributes: {
        globalTime: {
          liveSpan: "1h",
        },
        globalTimeSelectable: true,
        selectableTemplateVars: [
          {
            defaultValues: ["1"],
            name: "org_id",
            prefix: "org_id",
            visibleTags: ["1"],
          },
        ],
        status: "active",
        title: "Q1 Metrics Dashboard",
        viewingPreferences: {
          highDensity: false,
          theme: "system",
        },
      },
      type: "secure_embed_request",
    },
  },
  dashboardId: "dashboard_id",
};

apiInstance
  .createDashboardSecureEmbed(params)
  .then((data: v2.SecureEmbedCreateResponse) => {
    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 %}
