For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/jen.gilbert/astro-base/api/latest/widgets/create-a-widget.md. A documentation index is available at /llms.txt.
Language
Datadog site

Create a widget

POSThttps://api.datadoghq.com/api/v2/widgets/{experience_type}https://api.us3.datadoghq.com/api/v2/widgets/{experience_type}https://api.us5.datadoghq.com/api/v2/widgets/{experience_type}https://api.datadoghq.eu/api/v2/widgets/{experience_type}https://api.ap1.datadoghq.com/api/v2/widgets/{experience_type}https://api.ap2.datadoghq.com/api/v2/widgets/{experience_type}https://api.uk1.datadoghq.com/api/v2/widgets/{experience_type}https://api.ddog-gov.com/api/v2/widgets/{experience_type}https://api.us2.ddog-gov.com/api/v2/widgets/{experience_type}

Overview

Create a new widget for a given experience type.

This endpoint requires any of the following permissions:

  • cloud_cost_management_write
  • generate_log_reports
  • manage_log_reports
  • product_analytics_saved_widgets_write

Arguments

Path Parameters

Name
Type
Description
experience_type [required]
enum

The experience type for the widget.

Allowed enum values: ccm_reports, logs_reports, csv_reports, product_analytics

Request

Body Data (required)

Widget request body. The definition object's required fields vary by widget.definition.type: every type requires requests, and some types require additional fields (e.g. cloud_cost_summary requires graph_options, geomap requires style and view). The example below shows a complete cloud_cost_summary payload for the ccm_reports experience type.

Field
Type
Description
data [required]
object

Data for creating or updating a widget.

Response

OK

Response containing a single widget.

Field
Type
Description
data [required]
object

A widget resource object.

included
[object]

Array of user resources related to the widget.

Code Example

Create a widget
# Path parameters
export experience_type="ccm_reports"

# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/widgets/${experience_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "definition": {
        "graph_options": [
          {
            "type": "query_value",
            "view": "total"
          },
          {
            "type": "query_value",
            "view": "change"
          },
          {
            "display_type": "bars",
            "type": "timeseries"
          },
          {
            "type": "cloud_cost_table",
            "view": "summary"
          }
        ],
        "requests": [
          {
            "formulas": [
              {
                "formula": "query1"
              }
            ],
            "queries": [
              {
                "data_source": "cloud_cost",
                "name": "query1",
                "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
              }
            ],
            "response_format": "timeseries"
          }
        ],
        "time": {
          "type": "live",
          "unit": "day",
          "value": 30
        },
        "title": "AWS spend by service (last 30 days)",
        "type": "cloud_cost_summary"
      },
      "tags": [
        "finops",
        "aws"
      ]
    },
    "type": "widgets"
  }
}
EOF
# Path parameters
export experience_type="ccm_reports"

# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/widgets/${experience_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "definition": {
        "graph_options": [
          {
            "type": "query_value",
            "view": "total"
          },
          {
            "type": "query_value",
            "view": "change"
          },
          {
            "display_type": "bars",
            "type": "timeseries"
          },
          {
            "type": "cloud_cost_table",
            "view": "summary"
          }
        ],
        "requests": [
          {
            "formulas": [
              {
                "formula": "query1"
              }
            ],
            "queries": [
              {
                "data_source": "cloud_cost",
                "name": "query1",
                "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
              }
            ],
            "response_format": "timeseries"
          }
        ],
        "time": {
          "type": "live",
          "unit": "day",
          "value": 30
        },
        "title": "AWS spend by service (last 30 days)",
        "type": "cloud_cost_summary"
      },
      "tags": [
        "finops",
        "aws"
      ]
    },
    "type": "widgets"
  }
}
EOF
# Path parameters
export experience_type="ccm_reports"

# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/widgets/${experience_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "definition": {
        "graph_options": [
          {
            "type": "query_value",
            "view": "total"
          },
          {
            "type": "query_value",
            "view": "change"
          },
          {
            "display_type": "bars",
            "type": "timeseries"
          },
          {
            "type": "cloud_cost_table",
            "view": "summary"
          }
        ],
        "requests": [
          {
            "formulas": [
              {
                "formula": "query1"
              }
            ],
            "queries": [
              {
                "data_source": "cloud_cost",
                "name": "query1",
                "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
              }
            ],
            "response_format": "timeseries"
          }
        ],
        "time": {
          "type": "live",
          "unit": "day",
          "value": 30
        },
        "title": "AWS spend by service (last 30 days)",
        "type": "cloud_cost_summary"
      },
      "tags": [
        "finops",
        "aws"
      ]
    },
    "type": "widgets"
  }
}
EOF
# Path parameters
export experience_type="ccm_reports"

# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/widgets/${experience_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "definition": {
        "graph_options": [
          {
            "type": "query_value",
            "view": "total"
          },
          {
            "type": "query_value",
            "view": "change"
          },
          {
            "display_type": "bars",
            "type": "timeseries"
          },
          {
            "type": "cloud_cost_table",
            "view": "summary"
          }
        ],
        "requests": [
          {
            "formulas": [
              {
                "formula": "query1"
              }
            ],
            "queries": [
              {
                "data_source": "cloud_cost",
                "name": "query1",
                "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
              }
            ],
            "response_format": "timeseries"
          }
        ],
        "time": {
          "type": "live",
          "unit": "day",
          "value": 30
        },
        "title": "AWS spend by service (last 30 days)",
        "type": "cloud_cost_summary"
      },
      "tags": [
        "finops",
        "aws"
      ]
    },
    "type": "widgets"
  }
}
EOF
# Path parameters
export experience_type="ccm_reports"

# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/widgets/${experience_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "definition": {
        "graph_options": [
          {
            "type": "query_value",
            "view": "total"
          },
          {
            "type": "query_value",
            "view": "change"
          },
          {
            "display_type": "bars",
            "type": "timeseries"
          },
          {
            "type": "cloud_cost_table",
            "view": "summary"
          }
        ],
        "requests": [
          {
            "formulas": [
              {
                "formula": "query1"
              }
            ],
            "queries": [
              {
                "data_source": "cloud_cost",
                "name": "query1",
                "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
              }
            ],
            "response_format": "timeseries"
          }
        ],
        "time": {
          "type": "live",
          "unit": "day",
          "value": 30
        },
        "title": "AWS spend by service (last 30 days)",
        "type": "cloud_cost_summary"
      },
      "tags": [
        "finops",
        "aws"
      ]
    },
    "type": "widgets"
  }
}
EOF
# Path parameters
export experience_type="ccm_reports"

# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/widgets/${experience_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "definition": {
        "graph_options": [
          {
            "type": "query_value",
            "view": "total"
          },
          {
            "type": "query_value",
            "view": "change"
          },
          {
            "display_type": "bars",
            "type": "timeseries"
          },
          {
            "type": "cloud_cost_table",
            "view": "summary"
          }
        ],
        "requests": [
          {
            "formulas": [
              {
                "formula": "query1"
              }
            ],
            "queries": [
              {
                "data_source": "cloud_cost",
                "name": "query1",
                "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
              }
            ],
            "response_format": "timeseries"
          }
        ],
        "time": {
          "type": "live",
          "unit": "day",
          "value": 30
        },
        "title": "AWS spend by service (last 30 days)",
        "type": "cloud_cost_summary"
      },
      "tags": [
        "finops",
        "aws"
      ]
    },
    "type": "widgets"
  }
}
EOF
# Path parameters
export experience_type="ccm_reports"

# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/widgets/${experience_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "definition": {
        "graph_options": [
          {
            "type": "query_value",
            "view": "total"
          },
          {
            "type": "query_value",
            "view": "change"
          },
          {
            "display_type": "bars",
            "type": "timeseries"
          },
          {
            "type": "cloud_cost_table",
            "view": "summary"
          }
        ],
        "requests": [
          {
            "formulas": [
              {
                "formula": "query1"
              }
            ],
            "queries": [
              {
                "data_source": "cloud_cost",
                "name": "query1",
                "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
              }
            ],
            "response_format": "timeseries"
          }
        ],
        "time": {
          "type": "live",
          "unit": "day",
          "value": 30
        },
        "title": "AWS spend by service (last 30 days)",
        "type": "cloud_cost_summary"
      },
      "tags": [
        "finops",
        "aws"
      ]
    },
    "type": "widgets"
  }
}
EOF
# Path parameters
export experience_type="ccm_reports"

# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/widgets/${experience_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "definition": {
        "graph_options": [
          {
            "type": "query_value",
            "view": "total"
          },
          {
            "type": "query_value",
            "view": "change"
          },
          {
            "display_type": "bars",
            "type": "timeseries"
          },
          {
            "type": "cloud_cost_table",
            "view": "summary"
          }
        ],
        "requests": [
          {
            "formulas": [
              {
                "formula": "query1"
              }
            ],
            "queries": [
              {
                "data_source": "cloud_cost",
                "name": "query1",
                "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
              }
            ],
            "response_format": "timeseries"
          }
        ],
        "time": {
          "type": "live",
          "unit": "day",
          "value": 30
        },
        "title": "AWS spend by service (last 30 days)",
        "type": "cloud_cost_summary"
      },
      "tags": [
        "finops",
        "aws"
      ]
    },
    "type": "widgets"
  }
}
EOF
# Path parameters
export experience_type="ccm_reports"

# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/widgets/${experience_type}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "definition": {
        "graph_options": [
          {
            "type": "query_value",
            "view": "total"
          },
          {
            "type": "query_value",
            "view": "change"
          },
          {
            "display_type": "bars",
            "type": "timeseries"
          },
          {
            "type": "cloud_cost_table",
            "view": "summary"
          }
        ],
        "requests": [
          {
            "formulas": [
              {
                "formula": "query1"
              }
            ],
            "queries": [
              {
                "data_source": "cloud_cost",
                "name": "query1",
                "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)"
              }
            ],
            "response_format": "timeseries"
          }
        ],
        "time": {
          "type": "live",
          "unit": "day",
          "value": 30
        },
        "title": "AWS spend by service (last 30 days)",
        "type": "cloud_cost_summary"
      },
      "tags": [
        "finops",
        "aws"
      ]
    },
    "type": "widgets"
  }
}
EOF