---
title: Create a graph snapshot
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Reporting And Sharing
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Create a graph snapshot{% #create-a-graph-snapshot %}
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/snapshot |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/snapshot |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/snapshot      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/snapshot      |
| us2.ddog-gov.com  | POST https://api.us2.ddog-gov.com/api/v2/snapshot  |
| uk1.datadoghq.com | POST https://api.uk1.datadoghq.com/api/v2/snapshot |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/snapshot     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/snapshot |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/snapshot |

### Overview

Create a snapshot of a graph widget. The snapshot is rendered asynchronously; the returned URL can be polled until the image is ready.

### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field       | Field                               | Type     | Description                                                                                                                                                                                             |
| ------------------ | ----------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|                    | data [*required*]              | object   | Data envelope for snapshot creation.                                                                                                                                                                    |
| data               | attributes [*required*]        | object   | Attributes for snapshot creation.                                                                                                                                                                       |
| attributes         | additional_config                   | object   | Additional configuration options for snapshot creation.                                                                                                                                                 |
| additional_config  | template_variables                  | [object] | List of template variable definitions for snapshot rendering.                                                                                                                                           |
| template_variables | name [*required*]              | string   | The template variable name.                                                                                                                                                                             |
| template_variables | prefix [*required*]            | string   | The tag prefix associated with the template variable. For example, a prefix of `host` with a value of `web-server-1` scopes the snapshot to `host:web-server-1`.                                        |
| template_variables | values [*required*]            | [string] | The list of scoped values for this template variable.                                                                                                                                                   |
| additional_config  | timeseries_legend_type              | enum     | The legend display type for timeseries widgets. A value of `none` hides the legend entirely; omitting the field lets the frontend choose automatically. Allowed enum values: `compact,expanded,none`    |
| additional_config  | timezone_offset_minutes             | int64    | Timezone offset in minutes from UTC. Positive values are west of UTC (for example, `300` for UTC-5). Use `0` for UTC.                                                                                   |
| attributes         | end [*required*]               | int64    | End of the time window for the snapshot, in milliseconds since Unix epoch.                                                                                                                              |
| attributes         | height                              | int64    | The height of the rendered snapshot in pixels.                                                                                                                                                          |
| attributes         | is_authenticated                    | boolean  | Whether the snapshot requires authentication to view. Authenticated snapshots are scoped to the creating organization.                                                                                  |
| attributes         | start [*required*]             | int64    | Start of the time window for the snapshot, in milliseconds since Unix epoch.                                                                                                                            |
| attributes         | ttl                                 | enum     | The time-to-live for the snapshot. This value corresponds to storage lifecycle policies that automatically delete the snapshot after the specified period. Allowed enum values: `30d,60d,90d,1y,2y,inf` |
| attributes         | widget_definition [*required*] | object   | The widget definition to render as a snapshot. Must include a valid `type` field and non-empty `requests` array.                                                                                        |
| attributes         | width                               | int64    | The width of the rendered snapshot in pixels.                                                                                                                                                           |
| data               | type [*required*]              | enum     | The type identifier for snapshot creation resources. Allowed enum values: `create_snapshot`                                                                                                             |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "additional_config": {
        "template_variables": [
          {
            "name": "host",
            "prefix": "host",
            "values": [
              "web-server-1",
              "web-server-2"
            ]
          }
        ],
        "timeseries_legend_type": "expanded",
        "timezone_offset_minutes": 300
      },
      "end": 1692464800000,
      "height": 185,
      "is_authenticated": false,
      "start": 1692464000000,
      "ttl": "60d",
      "widget_definition": {
        "requests": [
          {
            "q": "avg:system.cpu.user{*}"
          }
        ],
        "type": "timeseries"
      },
      "width": 300
    },
    "type": "create_snapshot"
  }
}
```

{% /tab %}

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
Response body for a snapshot creation request.

| Parent field | Field                        | Type   | Description                                                                                 |
| ------------ | ---------------------------- | ------ | ------------------------------------------------------------------------------------------- |
|              | data [*required*]       | object | Data envelope for the snapshot creation response.                                           |
| data         | attributes [*required*] | object | Attributes of the created snapshot.                                                         |
| attributes   | url [*required*]        | string | The URL to access the rendered snapshot image.                                              |
| data         | id [*required*]         | string | The unique identifier of the created snapshot.                                              |
| data         | type [*required*]       | enum   | The type identifier for snapshot creation resources. Allowed enum values: `create_snapshot` |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "url": "https://app.datadoghq.com/api/v2/snapshot/view/public/60d/00000000-0000-0000-0000-000000000000/1692464400000-12345678-1234-5678-9abc-def123456789.png"
    },
    "id": "12345678-1234-5678-9abc-def123456789",
    "type": "create_snapshot"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% 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="401" %}
Unauthorized
{% 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="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" %}
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="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

##### 
                  \# Curl command curl -X POST "https://api.datadoghq.com/api/v2/snapshot" \
-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": {
      "additional_config": {
        "template_variables": [
          {
            "name": "host",
            "prefix": "host",
            "values": [
              "web-server-1",
              "web-server-2"
            ]
          }
        ]
      },
      "end": 1692464800000,
      "start": 1692464000000,
      "widget_definition": {
        "requests": [
          {
            "q": "avg:system.cpu.user{*}"
          }
        ],
        "type": "timeseries"
      }
    },
    "type": "create_snapshot"
  }
}
EOF 
                
##### 

```python
"""
Create a graph snapshot returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.reporting_and_sharing_api import ReportingAndSharingApi
from datadog_api_client.v2.model.create_snapshot_additional_config import CreateSnapshotAdditionalConfig
from datadog_api_client.v2.model.create_snapshot_data_attributes_request import CreateSnapshotDataAttributesRequest
from datadog_api_client.v2.model.create_snapshot_data_request import CreateSnapshotDataRequest
from datadog_api_client.v2.model.create_snapshot_request import CreateSnapshotRequest
from datadog_api_client.v2.model.create_snapshot_template_variable import CreateSnapshotTemplateVariable
from datadog_api_client.v2.model.create_snapshot_timeseries_legend_type import CreateSnapshotTimeseriesLegendType
from datadog_api_client.v2.model.create_snapshot_ttl import CreateSnapshotTTL
from datadog_api_client.v2.model.create_snapshot_type import CreateSnapshotType

body = CreateSnapshotRequest(
    data=CreateSnapshotDataRequest(
        attributes=CreateSnapshotDataAttributesRequest(
            additional_config=CreateSnapshotAdditionalConfig(
                template_variables=[
                    CreateSnapshotTemplateVariable(
                        name="host",
                        prefix="host",
                        values=[
                            "web-server-1",
                            "web-server-2",
                        ],
                    ),
                ],
                timeseries_legend_type=CreateSnapshotTimeseriesLegendType.EXPANDED,
                timezone_offset_minutes=300,
            ),
            end=1692464800000,
            height=185,
            is_authenticated=False,
            start=1692464000000,
            ttl=CreateSnapshotTTL.SIXTY_DAYS,
            widget_definition=dict([("requests", "[{'q': 'avg:system.cpu.user{*}'}]"), ("type", "timeseries")]),
            width=300,
        ),
        type=CreateSnapshotType.CREATE_SNAPSHOT,
    ),
)

configuration = Configuration()
configuration.unstable_operations["create_snapshot"] = True
with ApiClient(configuration) as api_client:
    api_instance = ReportingAndSharingApi(api_client)
    response = api_instance.create_snapshot(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="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
##### 

```ruby
# Create a graph snapshot returns "OK" response

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

body = DatadogAPIClient::V2::CreateSnapshotRequest.new({
  data: DatadogAPIClient::V2::CreateSnapshotDataRequest.new({
    attributes: DatadogAPIClient::V2::CreateSnapshotDataAttributesRequest.new({
      additional_config: DatadogAPIClient::V2::CreateSnapshotAdditionalConfig.new({
        template_variables: [
          DatadogAPIClient::V2::CreateSnapshotTemplateVariable.new({
            name: "host",
            prefix: "host",
            values: [
              "web-server-1",
              "web-server-2",
            ],
          }),
        ],
        timeseries_legend_type: DatadogAPIClient::V2::CreateSnapshotTimeseriesLegendType::EXPANDED,
        timezone_offset_minutes: 300,
      }),
      _end: 1692464800000,
      height: 185,
      is_authenticated: false,
      start: 1692464000000,
      ttl: DatadogAPIClient::V2::CreateSnapshotTTL::SIXTY_DAYS,
      widget_definition: {
        "requests": "[{'q': 'avg:system.cpu.user{*}'}]", "type": "timeseries",
      },
      width: 300,
    }),
    type: DatadogAPIClient::V2::CreateSnapshotType::CREATE_SNAPSHOT,
  }),
})
p api_instance.create_snapshot(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="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
##### 

```go
// Create a graph snapshot 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.CreateSnapshotRequest{
		Data: datadogV2.CreateSnapshotDataRequest{
			Attributes: datadogV2.CreateSnapshotDataAttributesRequest{
				AdditionalConfig: &datadogV2.CreateSnapshotAdditionalConfig{
					TemplateVariables: []datadogV2.CreateSnapshotTemplateVariable{
						{
							Name:   "host",
							Prefix: "host",
							Values: []string{
								"web-server-1",
								"web-server-2",
							},
						},
					},
					TimeseriesLegendType:  datadogV2.CREATESNAPSHOTTIMESERIESLEGENDTYPE_EXPANDED.Ptr(),
					TimezoneOffsetMinutes: datadog.PtrInt64(300),
				},
				End:             1692464800000,
				Height:          datadog.PtrInt64(185),
				IsAuthenticated: datadog.PtrBool(false),
				Start:           1692464000000,
				Ttl:             datadogV2.CREATESNAPSHOTTTL_SIXTY_DAYS.Ptr(),
				WidgetDefinition: map[string]interface{}{
					"requests": "[{'q': 'avg:system.cpu.user{*}'}]",
					"type":     "timeseries",
				},
				Width: datadog.PtrInt64(300),
			},
			Type: datadogV2.CREATESNAPSHOTTYPE_CREATE_SNAPSHOT,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.CreateSnapshot", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewReportingAndSharingApi(apiClient)
	resp, r, err := api.CreateSnapshot(ctx, body)

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `ReportingAndSharingApi.CreateSnapshot`:\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="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
##### 

```java
// Create a graph snapshot returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.ReportingAndSharingApi;
import com.datadog.api.client.v2.model.CreateSnapshotAdditionalConfig;
import com.datadog.api.client.v2.model.CreateSnapshotDataAttributesRequest;
import com.datadog.api.client.v2.model.CreateSnapshotDataRequest;
import com.datadog.api.client.v2.model.CreateSnapshotRequest;
import com.datadog.api.client.v2.model.CreateSnapshotResponse;
import com.datadog.api.client.v2.model.CreateSnapshotTTL;
import com.datadog.api.client.v2.model.CreateSnapshotTemplateVariable;
import com.datadog.api.client.v2.model.CreateSnapshotTimeseriesLegendType;
import com.datadog.api.client.v2.model.CreateSnapshotType;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;

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

    CreateSnapshotRequest body =
        new CreateSnapshotRequest()
            .data(
                new CreateSnapshotDataRequest()
                    .attributes(
                        new CreateSnapshotDataAttributesRequest()
                            .additionalConfig(
                                new CreateSnapshotAdditionalConfig()
                                    .templateVariables(
                                        Collections.singletonList(
                                            new CreateSnapshotTemplateVariable()
                                                .name("host")
                                                .prefix("host")
                                                .values(
                                                    Arrays.asList("web-server-1", "web-server-2"))))
                                    .timeseriesLegendType(
                                        CreateSnapshotTimeseriesLegendType.EXPANDED)
                                    .timezoneOffsetMinutes(300L))
                            .end(1692464800000L)
                            .height(185L)
                            .isAuthenticated(false)
                            .start(1692464000000L)
                            .ttl(CreateSnapshotTTL.SIXTY_DAYS)
                            .widgetDefinition(
                                Map.ofEntries(
                                    Map.entry("requests", "[{'q': 'avg:system.cpu.user{*}'}]"),
                                    Map.entry("type", "timeseries")))
                            .width(300L))
                    .type(CreateSnapshotType.CREATE_SNAPSHOT));

    try {
      CreateSnapshotResponse result = apiInstance.createSnapshot(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling ReportingAndSharingApi#createSnapshot");
      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="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
##### 

```rust
// Create a graph snapshot returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_reporting_and_sharing::ReportingAndSharingAPI;
use datadog_api_client::datadogV2::model::CreateSnapshotAdditionalConfig;
use datadog_api_client::datadogV2::model::CreateSnapshotDataAttributesRequest;
use datadog_api_client::datadogV2::model::CreateSnapshotDataRequest;
use datadog_api_client::datadogV2::model::CreateSnapshotRequest;
use datadog_api_client::datadogV2::model::CreateSnapshotTTL;
use datadog_api_client::datadogV2::model::CreateSnapshotTemplateVariable;
use datadog_api_client::datadogV2::model::CreateSnapshotTimeseriesLegendType;
use datadog_api_client::datadogV2::model::CreateSnapshotType;
use serde_json::Value;
use std::collections::BTreeMap;

#[tokio::main]
async fn main() {
    let body = CreateSnapshotRequest::new(CreateSnapshotDataRequest::new(
        CreateSnapshotDataAttributesRequest::new(
            1692464800000,
            1692464000000,
            BTreeMap::from([("type".to_string(), Value::from("timeseries"))]),
        )
        .additional_config(
            CreateSnapshotAdditionalConfig::new()
                .template_variables(vec![CreateSnapshotTemplateVariable::new(
                    "host".to_string(),
                    "host".to_string(),
                    vec!["web-server-1".to_string(), "web-server-2".to_string()],
                )])
                .timeseries_legend_type(CreateSnapshotTimeseriesLegendType::EXPANDED)
                .timezone_offset_minutes(300),
        )
        .height(185)
        .is_authenticated(false)
        .ttl(CreateSnapshotTTL::SIXTY_DAYS)
        .width(300),
        CreateSnapshotType::CREATE_SNAPSHOT,
    ));
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.CreateSnapshot", true);
    let api = ReportingAndSharingAPI::with_config(configuration);
    let resp = api.create_snapshot(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="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
##### 

```typescript
/**
 * Create a graph snapshot returns "OK" response
 */

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

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

const params: v2.ReportingAndSharingApiCreateSnapshotRequest = {
  body: {
    data: {
      attributes: {
        additionalConfig: {
          templateVariables: [
            {
              name: "host",
              prefix: "host",
              values: ["web-server-1", "web-server-2"],
            },
          ],
          timeseriesLegendType: "expanded",
          timezoneOffsetMinutes: 300,
        },
        end: 1692464800000,
        height: 185,
        isAuthenticated: false,
        start: 1692464000000,
        ttl: "60d",
        widgetDefinition: {
          requests: "[{'q': 'avg:system.cpu.user{*}'}]",
          type: "timeseries",
        },
        width: 300,
      },
      type: "create_snapshot",
    },
  },
};

apiInstance
  .createSnapshot(params)
  .then((data: v2.CreateSnapshotResponse) => {
    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="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
{% /tab %}
