For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/api/latest/report-schedules/create-a-report-schedule.md. A documentation index is available at /llms.txt.

Create a report schedule

Note: This endpoint is in preview and is subject to change. If you have any feedback, contact Datadog support.

POST https://api.ap1.datadoghq.com/api/v2/reporting/schedulehttps://api.ap2.datadoghq.com/api/v2/reporting/schedulehttps://api.datadoghq.eu/api/v2/reporting/schedulehttps://api.ddog-gov.com/api/v2/reporting/schedulehttps://api.us2.ddog-gov.com/api/v2/reporting/schedulehttps://api.uk1.datadoghq.com/api/v2/reporting/schedulehttps://api.datadoghq.com/api/v2/reporting/schedulehttps://api.us3.datadoghq.com/api/v2/reporting/schedulehttps://api.us5.datadoghq.com/api/v2/reporting/schedule

Overview

Create a new scheduled report. A schedule renders a dashboard or integration dashboard on a recurring cadence and delivers it to the configured recipients over email, Slack, or Microsoft Teams. Requires the generate_dashboard_reports permission.

Request

Body Data (required)

Expand All

Field

Type

Description

data [required]

object

The JSON:API data object for a report schedule creation request.

attributes [required]

object

The configuration of the report schedule to create.

delivery_format

enum

How a PDF-export report is delivered. pdf attaches a PDF file, png embeds an inline PNG image, and pdf_and_png delivers both. Allowed enum values: pdf,png,pdf_and_png

description [required]

string

A description of the report, up to 4096 characters.

recipients [required]

[string]

The recipients of the report. Each entry is an email address, a Slack channel reference in the form slack:{team_id}.{channel_id}.{channel_name}, or a Microsoft Teams channel reference in the form teams:{tenant_id}|{team_id}|{channel_id}.

resource_id [required]

string

The identifier of the dashboard or integration dashboard to render in the report.

resource_type [required]

enum

The type of dashboard resource the report schedule targets. Allowed enum values: dashboard,integration_dashboard

rrule [required]

string

The recurrence rule for the schedule, expressed as an iCalendar RRULE string.

tab_id

uuid

The identifier of the dashboard tab to render, when the dashboard has tabs.

template_variables [required]

[object]

The dashboard template variables applied when rendering the report.

name [required]

string

The name of the template variable.

values [required]

[string]

The selected values for the template variable.

timeframe [required]

string

The relative timeframe of data to include in the report.

timezone [required]

string

The IANA time zone identifier the recurrence rule is evaluated in.

title [required]

string

The title of the report, between 1 and 78 characters.

type [required]

enum

JSON:API resource type for report schedules. Allowed enum values: schedule

{
  "data": {
    "attributes": {
      "delivery_format": "pdf",
      "description": "Weekly summary of infrastructure health.",
      "recipients": [
        "[email protected]",
        "slack:T01234567.C01234567.alerts",
        "teams:11111111-1111-1111-1111-111111111111|22222222-2222-2222-2222-222222222222|19:[email protected]"
      ],
      "resource_id": "abc-def-ghi",
      "resource_type": "dashboard",
      "rrule": "DTSTART;TZID=America/New_York:20260601T090000\nRRULE:FREQ=WEEKLY;BYDAY=MO;BYHOUR=9;BYMINUTE=0",
      "tab_id": "66666666-7777-8888-9999-000000000000",
      "template_variables": [
        {
          "name": "env",
          "values": [
            "prod"
          ]
        }
      ],
      "timeframe": "1w",
      "timezone": "America/New_York",
      "title": "Weekly Infrastructure Report"
    },
    "type": "schedule"
  }
}

Response

CREATED

Response containing a single report schedule.

Expand All

Field

Type

Description

data [required]

object

The JSON:API data object representing a report schedule.

attributes [required]

object

The configuration and derived state of a report schedule.

delivery_format

enum

The delivery format for dashboard report schedules, or null if not set. Allowed enum values: pdf,png,pdf_and_png

description [required]

string

The description of the report.

next_recurrence [required]

int64

The Unix timestamp, in milliseconds, of the next scheduled delivery, or null if none is scheduled.

recipients [required]

[string]

The recipients of the report (email addresses, Slack channel references, or Microsoft Teams channel references).

resource_id [required]

string

The identifier of the resource rendered in the report.

resource_type [required]

enum

The type of dashboard resource the report schedule targets. Allowed enum values: dashboard,integration_dashboard

rrule [required]

string

The recurrence rule for the schedule, expressed as an iCalendar RRULE string.

status [required]

enum

Whether the schedule is currently delivering reports (active) or paused (inactive). Allowed enum values: active,inactive

tab_id [required]

string

The identifier of the dashboard tab rendered in the report, or null if not set.

template_variables [required]

[object]

The dashboard template variables applied when rendering the report.

name [required]

string

The name of the template variable.

values [required]

[string]

The selected values for the template variable.

timeframe [required]

string

The relative timeframe of data included in the report, or null if not set.

timezone [required]

string

The IANA time zone identifier the recurrence rule is evaluated in.

title [required]

string

The title of the report.

id [required]

string

The unique identifier of the report schedule.

relationships [required]

object

Relationships for the report schedule.

author [required]

object

Relationship to the author of the report schedule.

data [required]

object

Relationship data for the author of the report schedule.

id [required]

string

The user UUID of the report schedule author.

type [required]

enum

JSON:API resource type for the included report author. Allowed enum values: users

type [required]

enum

JSON:API resource type for report schedules. Allowed enum values: schedule

included

[ <oneOf>]

Related resources included with the report schedule, such as the author.

Option 1

object

A user included as a related JSON:API resource.

attributes [required]

object

Attributes of the report author.

email [required]

string

The email address of the report author, or null if unavailable.

name [required]

string

The display name of the report author, or null if unavailable.

id [required]

string

The user UUID.

type [required]

enum

JSON:API resource type for the included report author. Allowed enum values: users

Option 2

object

A report target resource included as a related JSON:API resource.

attributes [required]

object

Attributes of an included report target resource.

resource_type [required]

enum

The type of dashboard resource the report schedule targets. Allowed enum values: dashboard,integration_dashboard

template_variables

[object]

Template variable metadata from the dashboard resource, when available.

available_values

[string]

Available values for the template variable.

defaults

[string]

Default values for the template variable.

name

string

The template variable name.

prefix

string

The tag prefix for the template variable, when available.

title

string

The title of the dashboard or integration dashboard resource, when available.

id [required]

string

The resource identifier.

type [required]

enum

JSON:API resource type for an included report resource. Allowed enum values: resource

{
  "data": {
    "attributes": {
      "delivery_format": "pdf",
      "description": "Weekly summary of infrastructure health.",
      "next_recurrence": 1780923600000,
      "recipients": [
        "[email protected]",
        "slack:T01234567.C01234567.alerts",
        "teams:11111111-1111-1111-1111-111111111111|22222222-2222-2222-2222-222222222222|19:[email protected]"
      ],
      "resource_id": "abc-def-ghi",
      "resource_type": "dashboard",
      "rrule": "DTSTART;TZID=America/New_York:20260601T090000\nRRULE:FREQ=WEEKLY;BYDAY=MO;BYHOUR=9;BYMINUTE=0",
      "status": "active",
      "tab_id": "66666666-7777-8888-9999-000000000000",
      "template_variables": [
        {
          "name": "env",
          "values": [
            "prod"
          ]
        }
      ],
      "timeframe": "1w",
      "timezone": "America/New_York",
      "title": "Weekly Infrastructure Report"
    },
    "id": "11111111-2222-3333-4444-555555555555",
    "relationships": {
      "author": {
        "data": {
          "id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
          "type": "users"
        }
      }
    },
    "type": "schedule"
  },
  "included": [
    {
      "attributes": {
        "email": "[email protected]",
        "name": "Example User"
      },
      "id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
      "type": "users"
    }
  ]
}

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short human-readable summary of the error.

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

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short human-readable summary of the error.

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

Not Found

API error response.

Expand All

Field

Type

Description

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short human-readable summary of the error.

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

Too many requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example

                  ## default
# 

# Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.uk1.datadoghq.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/reporting/schedule" \ -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": { "delivery_format": "pdf", "description": "Weekly summary of infrastructure health.", "recipients": [ "[email protected]", "slack:T01234567.C01234567.alerts", "teams:11111111-1111-1111-1111-111111111111|22222222-2222-2222-2222-222222222222|19:[email protected]" ], "resource_id": "abc-def-ghi", "resource_type": "dashboard", "rrule": "DTSTART;TZID=America/New_York:20260601T090000\nRRULE:FREQ=WEEKLY;BYDAY=MO;BYHOUR=9;BYMINUTE=0", "template_variables": [ { "name": "env", "values": [ "prod" ] } ], "timeframe": "1w", "timezone": "America/New_York", "title": "Weekly Infrastructure Report" }, "type": "schedule" } } EOF
"""
Create a report schedule returns "CREATED" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.report_schedules_api import ReportSchedulesApi
from datadog_api_client.v2.model.report_schedule_create_request import ReportScheduleCreateRequest
from datadog_api_client.v2.model.report_schedule_create_request_attributes import ReportScheduleCreateRequestAttributes
from datadog_api_client.v2.model.report_schedule_create_request_data import ReportScheduleCreateRequestData
from datadog_api_client.v2.model.report_schedule_delivery_format import ReportScheduleDeliveryFormat
from datadog_api_client.v2.model.report_schedule_resource_type import ReportScheduleResourceType
from datadog_api_client.v2.model.report_schedule_template_variable import ReportScheduleTemplateVariable
from datadog_api_client.v2.model.report_schedule_type import ReportScheduleType
from uuid import UUID

body = ReportScheduleCreateRequest(
    data=ReportScheduleCreateRequestData(
        attributes=ReportScheduleCreateRequestAttributes(
            delivery_format=ReportScheduleDeliveryFormat.PDF,
            description="Weekly summary of infrastructure health.",
            recipients=[
                "[email protected]",
                "slack:T01234567.C01234567.alerts",
                "teams:11111111-1111-1111-1111-111111111111|22222222-2222-2222-2222-222222222222|19:[email protected]",
            ],
            resource_id="abc-def-ghi",
            resource_type=ReportScheduleResourceType.DASHBOARD,
            rrule="DTSTART;TZID=America/New_York:20260601T090000\nRRULE:FREQ=WEEKLY;BYDAY=MO;BYHOUR=9;BYMINUTE=0",
            tab_id=UUID("66666666-7777-8888-9999-000000000000"),
            template_variables=[
                ReportScheduleTemplateVariable(
                    name="env",
                    values=[
                        "prod",
                    ],
                ),
            ],
            timeframe="1w",
            timezone="America/New_York",
            title="Weekly Infrastructure Report",
        ),
        type=ReportScheduleType.SCHEDULE,
    ),
)

configuration = Configuration()
configuration.unstable_operations["create_report_schedule"] = True
with ApiClient(configuration) as api_client:
    api_instance = ReportSchedulesApi(api_client)
    response = api_instance.create_report_schedule(body=body)

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
# Create a report schedule returns "CREATED" response

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

body = DatadogAPIClient::V2::ReportScheduleCreateRequest.new({
  data: DatadogAPIClient::V2::ReportScheduleCreateRequestData.new({
    attributes: DatadogAPIClient::V2::ReportScheduleCreateRequestAttributes.new({
      delivery_format: DatadogAPIClient::V2::ReportScheduleDeliveryFormat::PDF,
      description: "Weekly summary of infrastructure health.",
      recipients: [
        "[email protected]",
        "slack:T01234567.C01234567.alerts",
        "teams:11111111-1111-1111-1111-111111111111|22222222-2222-2222-2222-222222222222|19:[email protected]",
      ],
      resource_id: "abc-def-ghi",
      resource_type: DatadogAPIClient::V2::ReportScheduleResourceType::DASHBOARD,
      rrule: 'DTSTART;TZID=America/New_York:20260601T090000\nRRULE:FREQ=WEEKLY;BYDAY=MO;BYHOUR=9;BYMINUTE=0',
      tab_id: "66666666-7777-8888-9999-000000000000",
      template_variables: [
        DatadogAPIClient::V2::ReportScheduleTemplateVariable.new({
          name: "env",
          values: [
            "prod",
          ],
        }),
      ],
      timeframe: "1w",
      timezone: "America/New_York",
      title: "Weekly Infrastructure Report",
    }),
    type: DatadogAPIClient::V2::ReportScheduleType::SCHEDULE,
  }),
})
p api_instance.create_report_schedule(body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
// Create a report schedule returns "CREATED" 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"
	"github.com/google/uuid"
)

func main() {
	body := datadogV2.ReportScheduleCreateRequest{
		Data: datadogV2.ReportScheduleCreateRequestData{
			Attributes: datadogV2.ReportScheduleCreateRequestAttributes{
				DeliveryFormat: datadogV2.REPORTSCHEDULEDELIVERYFORMAT_PDF.Ptr(),
				Description:    "Weekly summary of infrastructure health.",
				Recipients: []string{
					"[email protected]",
					"slack:T01234567.C01234567.alerts",
					"teams:11111111-1111-1111-1111-111111111111|22222222-2222-2222-2222-222222222222|19:[email protected]",
				},
				ResourceId:   "abc-def-ghi",
				ResourceType: datadogV2.REPORTSCHEDULERESOURCETYPE_DASHBOARD,
				Rrule: `DTSTART;TZID=America/New_York:20260601T090000
RRULE:FREQ=WEEKLY;BYDAY=MO;BYHOUR=9;BYMINUTE=0`,
				TabId: datadog.PtrUUID(uuid.MustParse("66666666-7777-8888-9999-000000000000")),
				TemplateVariables: []datadogV2.ReportScheduleTemplateVariable{
					{
						Name: "env",
						Values: []string{
							"prod",
						},
					},
				},
				Timeframe: "1w",
				Timezone:  "America/New_York",
				Title:     "Weekly Infrastructure Report",
			},
			Type: datadogV2.REPORTSCHEDULETYPE_SCHEDULE,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.CreateReportSchedule", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewReportSchedulesApi(apiClient)
	resp, r, err := api.CreateReportSchedule(ctx, body)

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

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

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Create a report schedule returns "CREATED" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.ReportSchedulesApi;
import com.datadog.api.client.v2.model.ReportScheduleCreateRequest;
import com.datadog.api.client.v2.model.ReportScheduleCreateRequestAttributes;
import com.datadog.api.client.v2.model.ReportScheduleCreateRequestData;
import com.datadog.api.client.v2.model.ReportScheduleDeliveryFormat;
import com.datadog.api.client.v2.model.ReportScheduleResourceType;
import com.datadog.api.client.v2.model.ReportScheduleResponse;
import com.datadog.api.client.v2.model.ReportScheduleTemplateVariable;
import com.datadog.api.client.v2.model.ReportScheduleType;
import java.util.Arrays;
import java.util.Collections;
import java.util.UUID;

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

    ReportScheduleCreateRequest body =
        new ReportScheduleCreateRequest()
            .data(
                new ReportScheduleCreateRequestData()
                    .attributes(
                        new ReportScheduleCreateRequestAttributes()
                            .deliveryFormat(ReportScheduleDeliveryFormat.PDF)
                            .description("Weekly summary of infrastructure health.")
                            .recipients(
                                Arrays.asList(
                                    "[email protected]",
                                    "slack:T01234567.C01234567.alerts",
                                    "teams:11111111-1111-1111-1111-111111111111|22222222-2222-2222-2222-222222222222|19:[email protected]"))
                            .resourceId("abc-def-ghi")
                            .resourceType(ReportScheduleResourceType.DASHBOARD)
                            .rrule(
                                """
DTSTART;TZID=America/New_York:20260601T090000
RRULE:FREQ=WEEKLY;BYDAY=MO;BYHOUR=9;BYMINUTE=0
""")
                            .tabId(UUID.fromString("66666666-7777-8888-9999-000000000000"))
                            .templateVariables(
                                Collections.singletonList(
                                    new ReportScheduleTemplateVariable()
                                        .name("env")
                                        .values(Collections.singletonList("prod"))))
                            .timeframe("1w")
                            .timezone("America/New_York")
                            .title("Weekly Infrastructure Report"))
                    .type(ReportScheduleType.SCHEDULE));

    try {
      ReportScheduleResponse result = apiInstance.createReportSchedule(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling ReportSchedulesApi#createReportSchedule");
      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 and then save the example to Example.java and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
// Create a report schedule returns "CREATED" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_report_schedules::ReportSchedulesAPI;
use datadog_api_client::datadogV2::model::ReportScheduleCreateRequest;
use datadog_api_client::datadogV2::model::ReportScheduleCreateRequestAttributes;
use datadog_api_client::datadogV2::model::ReportScheduleCreateRequestData;
use datadog_api_client::datadogV2::model::ReportScheduleDeliveryFormat;
use datadog_api_client::datadogV2::model::ReportScheduleResourceType;
use datadog_api_client::datadogV2::model::ReportScheduleTemplateVariable;
use datadog_api_client::datadogV2::model::ReportScheduleType;
use uuid::Uuid;

#[tokio::main]
async fn main() {
    let body =
        ReportScheduleCreateRequest::new(
            ReportScheduleCreateRequestData::new(
                ReportScheduleCreateRequestAttributes::new(
                    "Weekly summary of infrastructure health.".to_string(),
                    vec![
                        "[email protected]".to_string(),
                        "slack:T01234567.C01234567.alerts".to_string(),
                        "teams:11111111-1111-1111-1111-111111111111|22222222-2222-2222-2222-222222222222|19:[email protected]".to_string()
                    ],
                    "abc-def-ghi".to_string(),
                    ReportScheduleResourceType::DASHBOARD,
                    r#"DTSTART;TZID=America/New_York:20260601T090000
RRULE:FREQ=WEEKLY;BYDAY=MO;BYHOUR=9;BYMINUTE=0"#.to_string(),
                    vec![ReportScheduleTemplateVariable::new("env".to_string(), vec!["prod".to_string()])],
                    "1w".to_string(),
                    "America/New_York".to_string(),
                    "Weekly Infrastructure Report".to_string(),
                )
                    .delivery_format(ReportScheduleDeliveryFormat::PDF)
                    .tab_id(Uuid::parse_str("66666666-7777-8888-9999-000000000000").expect("invalid UUID")),
                ReportScheduleType::SCHEDULE,
            ),
        );
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.CreateReportSchedule", true);
    let api = ReportSchedulesAPI::with_config(configuration);
    let resp = api.create_report_schedule(body).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}

Instructions

First install the library and its dependencies and then save the example to src/main.rs and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
/**
 * Create a report schedule returns "CREATED" response
 */

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

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

const params: v2.ReportSchedulesApiCreateReportScheduleRequest = {
  body: {
    data: {
      attributes: {
        deliveryFormat: "pdf",
        description: "Weekly summary of infrastructure health.",
        recipients: [
          "[email protected]",
          "slack:T01234567.C01234567.alerts",
          "teams:11111111-1111-1111-1111-111111111111|22222222-2222-2222-2222-222222222222|19:[email protected]",
        ],
        resourceId: "abc-def-ghi",
        resourceType: "dashboard",
        rrule:
          "DTSTART;TZID=America/New_York:20260601T090000\nRRULE:FREQ=WEEKLY;BYDAY=MO;BYHOUR=9;BYMINUTE=0",
        tabId: "66666666-7777-8888-9999-000000000000",
        templateVariables: [
          {
            name: "env",
            values: ["prod"],
          },
        ],
        timeframe: "1w",
        timezone: "America/New_York",
        title: "Weekly Infrastructure Report",
      },
      type: "schedule",
    },
  },
};

apiInstance
  .createReportSchedule(params)
  .then((data: v2.ReportScheduleResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"