Post an event
https://event-management-intake.datadoghq.com/api/v2/eventshttps://event-management-intake.us3.datadoghq.com/api/v2/eventshttps://event-management-intake.us5.datadoghq.com/api/v2/eventshttps://event-management-intake.datadoghq.eu/api/v2/eventshttps://event-management-intake.ap1.datadoghq.com/api/v2/eventshttps://event-management-intake.ap2.datadoghq.com/api/v2/eventshttps://event-management-intake.uk1.datadoghq.com/api/v2/eventshttps://event-management-intake.ddog-gov.com/api/v2/eventshttps://event-management-intake.us2.ddog-gov.com/api/v2/eventsOverview
This endpoint allows you to publish events.
Note: To utilize this endpoint with our client libraries, please ensure you are using the latest version released on or after July 1, 2025. Earlier versions do not support this functionality.
Important: Upgrade to the latest client library version to use the updated endpoint at https://event-management-intake.{site}/api/v2/events. Older client library versions of the Post an event (v2) API send requests to a deprecated endpoint (https://api.{site}/api/v2/events).
Supported event categories are change and alert. For more information about change events, see Change Tracking.
Request
Body Data (required)
Event creation request payload.
data [required]An event object.
attributes [required]Event attributes.
aggregation_keyA string used for aggregation when correlating events. If you specify a key, events are deduplicated to alerts based on this key. Limited to 100 characters.
attributes [required]JSON object for category-specific attributes. Schema is different per event category.
Object 1Change event attributes.
authorThe entity that made the change. Optional, if provided it must include type and name.
name [required]The name of the user or system that made the change. Limited to 128 characters.
type [required]Author's type.
user, system, api, automationchange_metadataFree form JSON object with information related to the change event. Supports up to 100 properties per object and a maximum nesting depth of 10 levels.
changed_resource [required]A uniquely identified resource.
name [required]The name of the resource that was changed. Limited to 128 characters. Must contain at least one non-whitespace character.
type [required]The type of the resource that was changed.
feature_flag, configurationimpacted_resourcesA list of resources impacted by this change. It is recommended to provide an impacted resource to display
the change event at the correct location. Only resources of type service are supported. Maximum of 100 impacted resources allowed.
name [required]The name of the impacted resource. Limited to 128 characters.
type [required]The type of the impacted resource.
servicenew_valueFree form JSON object representing the new state of the changed resource.
prev_valueFree form JSON object representing the previous state of the changed resource.
Object 2Alert event attributes.
customFree form JSON object for arbitrary data. Supports up to 100 properties per object and a maximum nesting depth of 10 levels.
linksThe links related to the event. Maximum of 20 links allowed.
category [required]The category of the link.
runbook, documentation, dashboard, resourcetitleThe display text of the link. Limited to 300 characters.
url [required]The URL of the link. Limited to 2048 characters.
priorityThe priority of the alert.
51, 2, 3, 4, 5status [required]The status of the alert.
warn, error, okcategory [required]Event category identifying the type of event.
change, alerthostHost name to associate with the event. Any tags associated with the host are also applied to this event. Limited to 255 characters.
integration_idIntegration ID sourced from integration manifests.
custom-eventsmessageFree formed text associated with the event. It's suggested to use data.attributes.attributes.custom for well-structured attributes. Limited to 4000 characters.
tagsA list of tags associated with the event. Maximum of 100 tags allowed. Refer to Tags docs.
timestampTimestamp when the event occurred. Must follow ISO 8601 format.
For example "2017-01-15T01:30:15.010000Z".
Defaults to the timestamp of receipt. Limited to values no older than 18 hours.
title [required]The title of the event. Limited to 500 characters.
type [required]Entity type.
event{
"data": {
"attributes": {
"aggregation_key": "deduplication_key_here",
"attributes": {
"custom": {
"my-object-attribute": {
"my-array-attribute": [
1,
2,
3
],
"my-array-object-attribute": [
{
"name": "test-object-1"
},
{
"name": "test-object-2"
}
],
"my-integer-attribute": 1
},
"my-string-attribute": "my-custom-value"
},
"links": [
{
"category": "runbook",
"title": "Datadog website",
"url": "https://datadoghq.com"
}
],
"priority": "1",
"status": "error"
},
"category": "alert",
"message": "Something is broken!",
"tags": [
"service:my-test-service",
"datacenter:primary"
],
"title": "My Alerting Event"
},
"type": "event"
}
}{
"data": {
"attributes": {
"aggregation_key": "aggregation_key_123",
"attributes": {
"author": {
"name": "example@datadog.com",
"type": "user"
},
"change_metadata": {
"dd": {
"team": "datadog_team",
"user_email": "datadog@datadog.com",
"user_id": "datadog_user_id",
"user_name": "datadog_username"
},
"resource_link": "datadog.com/feature/fallback_payments_test"
},
"changed_resource": {
"name": "fallback_payments_test",
"type": "feature_flag"
},
"impacted_resources": [
{
"name": "payments_api",
"type": "service"
}
],
"new_value": {
"enabled": true,
"percentage": "50%",
"rule": {
"datacenter": "devcycle.us1.prod"
}
},
"prev_value": {
"enabled": true,
"percentage": "10%",
"rule": {
"datacenter": "devcycle.us1.prod"
}
}
},
"category": "change",
"host": "hostname",
"integration_id": "custom-events",
"message": "payment_processed feature flag has been enabled",
"tags": [
"env:api_client_test"
],
"timestamp": "2020-01-01T01:30:15.010000Z",
"title": "payment_processed feature flag updated"
},
"type": "event"
}
}{
"data": {
"attributes": {
"aggregation_key": "aggregation_key_123",
"attributes": {
"author": {
"name": "example@datadog.com",
"type": "user"
},
"change_metadata": {
"dd": {
"team": "datadog_team",
"user_email": "datadog@datadog.com",
"user_id": "datadog_user_id",
"user_name": "datadog_username"
},
"resource_link": "datadog.com/feature/fallback_payments_test"
},
"changed_resource": {
"name": "fallback_payments_test",
"type": "feature_flag"
},
"impacted_resources": [
{
"name": "payments_api",
"type": "service"
}
],
"new_value": {
"enabled": true,
"percentage": "50%",
"rule": {
"datacenter": "devcycle.us1.prod"
}
},
"prev_value": {
"enabled": true,
"percentage": "10%",
"rule": {
"datacenter": "devcycle.us1.prod"
}
}
},
"category": "change",
"host": "hostname",
"integration_id": "custom-events",
"message": "payment_processed feature flag has been enabled",
"tags": [
"env:api_client_test"
],
"timestamp": "2020-01-01T01:30:15.010000Z",
"title": "payment_processed feature flag updated"
},
"type": "event"
}
}Response
OK
Event creation response.
dataEvent object.
attributesEvent attributes.
attributesJSON object for category-specific attributes.
evtJSON object of event system attributes.
idDEPRECATED Event identifier. This field is deprecated and will be removed in a future version. Use the uid field instead.
uidA unique identifier for the event. You can use this identifier to query or reference the event.
typeEntity type.
linksLinks to the event.
selfThe URL of the event. This link is only functional when using the default subdomain.
{
"data": {
"attributes": {
"attributes": {
"evt": {
"id": "string",
"uid": "string"
}
}
},
"type": "event"
},
"links": {
"self": "string"
}
}Bad request
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort 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.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort 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.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Code Example
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
export DD_API_KEY="<DD_API_KEY>"
export DD_APP_KEY="<DD_APP_KEY>"
curl -X POST "https://event-management-intake.${DD_SITE}/api/v2/events" \
-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": {
"aggregation_key": "deduplication_key_here",
"attributes": {
"custom": {
"my-object-attribute": {
"my-array-attribute": [
1,
2,
3
],
"my-array-object-attribute": [
{
"name": "test-object-1"
},
{
"name": "test-object-2"
}
],
"my-integer-attribute": 1
},
"my-string-attribute": "my-custom-value"
},
"links": [
{
"category": "runbook",
"title": "Datadog website",
"url": "https://datadoghq.com"
}
],
"priority": "1",
"status": "error"
},
"category": "alert",
"message": "Something is broken!",
"tags": [
"service:my-test-service",
"datacenter:primary"
],
"title": "My Alerting Event"
},
"type": "event"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
export DD_API_KEY="<DD_API_KEY>"
export DD_APP_KEY="<DD_APP_KEY>"
curl -X POST "https://event-management-intake.${DD_SITE}/api/v2/events" \
-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": {
"aggregation_key": "deduplication_key_here",
"attributes": {
"custom": {
"my-object-attribute": {
"my-array-attribute": [
1,
2,
3
],
"my-array-object-attribute": [
{
"name": "test-object-1"
},
{
"name": "test-object-2"
}
],
"my-integer-attribute": 1
},
"my-string-attribute": "my-custom-value"
},
"links": [
{
"category": "runbook",
"title": "Datadog website",
"url": "https://datadoghq.com"
}
],
"priority": "1",
"status": "error"
},
"category": "alert",
"message": "Something is broken!",
"tags": [
"service:my-test-service",
"datacenter:primary"
],
"title": "My Alerting Event"
},
"type": "event"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
export DD_API_KEY="<DD_API_KEY>"
export DD_APP_KEY="<DD_APP_KEY>"
curl -X POST "https://event-management-intake.${DD_SITE}/api/v2/events" \
-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": {
"aggregation_key": "deduplication_key_here",
"attributes": {
"custom": {
"my-object-attribute": {
"my-array-attribute": [
1,
2,
3
],
"my-array-object-attribute": [
{
"name": "test-object-1"
},
{
"name": "test-object-2"
}
],
"my-integer-attribute": 1
},
"my-string-attribute": "my-custom-value"
},
"links": [
{
"category": "runbook",
"title": "Datadog website",
"url": "https://datadoghq.com"
}
],
"priority": "1",
"status": "error"
},
"category": "alert",
"message": "Something is broken!",
"tags": [
"service:my-test-service",
"datacenter:primary"
],
"title": "My Alerting Event"
},
"type": "event"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
export DD_API_KEY="<DD_API_KEY>"
export DD_APP_KEY="<DD_APP_KEY>"
curl -X POST "https://event-management-intake.${DD_SITE}/api/v2/events" \
-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": {
"aggregation_key": "deduplication_key_here",
"attributes": {
"custom": {
"my-object-attribute": {
"my-array-attribute": [
1,
2,
3
],
"my-array-object-attribute": [
{
"name": "test-object-1"
},
{
"name": "test-object-2"
}
],
"my-integer-attribute": 1
},
"my-string-attribute": "my-custom-value"
},
"links": [
{
"category": "runbook",
"title": "Datadog website",
"url": "https://datadoghq.com"
}
],
"priority": "1",
"status": "error"
},
"category": "alert",
"message": "Something is broken!",
"tags": [
"service:my-test-service",
"datacenter:primary"
],
"title": "My Alerting Event"
},
"type": "event"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
export DD_API_KEY="<DD_API_KEY>"
export DD_APP_KEY="<DD_APP_KEY>"
curl -X POST "https://event-management-intake.${DD_SITE}/api/v2/events" \
-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": {
"aggregation_key": "deduplication_key_here",
"attributes": {
"custom": {
"my-object-attribute": {
"my-array-attribute": [
1,
2,
3
],
"my-array-object-attribute": [
{
"name": "test-object-1"
},
{
"name": "test-object-2"
}
],
"my-integer-attribute": 1
},
"my-string-attribute": "my-custom-value"
},
"links": [
{
"category": "runbook",
"title": "Datadog website",
"url": "https://datadoghq.com"
}
],
"priority": "1",
"status": "error"
},
"category": "alert",
"message": "Something is broken!",
"tags": [
"service:my-test-service",
"datacenter:primary"
],
"title": "My Alerting Event"
},
"type": "event"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
export DD_API_KEY="<DD_API_KEY>"
export DD_APP_KEY="<DD_APP_KEY>"
curl -X POST "https://event-management-intake.${DD_SITE}/api/v2/events" \
-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": {
"aggregation_key": "deduplication_key_here",
"attributes": {
"custom": {
"my-object-attribute": {
"my-array-attribute": [
1,
2,
3
],
"my-array-object-attribute": [
{
"name": "test-object-1"
},
{
"name": "test-object-2"
}
],
"my-integer-attribute": 1
},
"my-string-attribute": "my-custom-value"
},
"links": [
{
"category": "runbook",
"title": "Datadog website",
"url": "https://datadoghq.com"
}
],
"priority": "1",
"status": "error"
},
"category": "alert",
"message": "Something is broken!",
"tags": [
"service:my-test-service",
"datacenter:primary"
],
"title": "My Alerting Event"
},
"type": "event"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
export DD_API_KEY="<DD_API_KEY>"
export DD_APP_KEY="<DD_APP_KEY>"
curl -X POST "https://event-management-intake.${DD_SITE}/api/v2/events" \
-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": {
"aggregation_key": "deduplication_key_here",
"attributes": {
"custom": {
"my-object-attribute": {
"my-array-attribute": [
1,
2,
3
],
"my-array-object-attribute": [
{
"name": "test-object-1"
},
{
"name": "test-object-2"
}
],
"my-integer-attribute": 1
},
"my-string-attribute": "my-custom-value"
},
"links": [
{
"category": "runbook",
"title": "Datadog website",
"url": "https://datadoghq.com"
}
],
"priority": "1",
"status": "error"
},
"category": "alert",
"message": "Something is broken!",
"tags": [
"service:my-test-service",
"datacenter:primary"
],
"title": "My Alerting Event"
},
"type": "event"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
export DD_API_KEY="<DD_API_KEY>"
export DD_APP_KEY="<DD_APP_KEY>"
curl -X POST "https://event-management-intake.${DD_SITE}/api/v2/events" \
-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": {
"aggregation_key": "deduplication_key_here",
"attributes": {
"custom": {
"my-object-attribute": {
"my-array-attribute": [
1,
2,
3
],
"my-array-object-attribute": [
{
"name": "test-object-1"
},
{
"name": "test-object-2"
}
],
"my-integer-attribute": 1
},
"my-string-attribute": "my-custom-value"
},
"links": [
{
"category": "runbook",
"title": "Datadog website",
"url": "https://datadoghq.com"
}
],
"priority": "1",
"status": "error"
},
"category": "alert",
"message": "Something is broken!",
"tags": [
"service:my-test-service",
"datacenter:primary"
],
"title": "My Alerting Event"
},
"type": "event"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
export DD_API_KEY="<DD_API_KEY>"
export DD_APP_KEY="<DD_APP_KEY>"
curl -X POST "https://event-management-intake.${DD_SITE}/api/v2/events" \
-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": {
"aggregation_key": "deduplication_key_here",
"attributes": {
"custom": {
"my-object-attribute": {
"my-array-attribute": [
1,
2,
3
],
"my-array-object-attribute": [
{
"name": "test-object-1"
},
{
"name": "test-object-2"
}
],
"my-integer-attribute": 1
},
"my-string-attribute": "my-custom-value"
},
"links": [
{
"category": "runbook",
"title": "Datadog website",
"url": "https://datadoghq.com"
}
],
"priority": "1",
"status": "error"
},
"category": "alert",
"message": "Something is broken!",
"tags": [
"service:my-test-service",
"datacenter:primary"
],
"title": "My Alerting Event"
},
"type": "event"
}
}
EOF// Post an event 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.EventCreateRequestPayload{
Data: datadogV2.EventCreateRequest{
Attributes: datadogV2.EventPayload{
AggregationKey: datadog.PtrString("aggregation_key_123"),
Attributes: datadogV2.EventPayloadAttributes{
ChangeEventCustomAttributes: &datadogV2.ChangeEventCustomAttributes{
Author: &datadogV2.ChangeEventCustomAttributesAuthor{
Name: "example@datadog.com",
Type: datadogV2.CHANGEEVENTCUSTOMATTRIBUTESAUTHORTYPE_USER,
},
ChangeMetadata: map[string]interface{}{
"dd": "{'team': 'datadog_team', 'user_email': 'datadog@datadog.com', 'user_id': 'datadog_user_id', 'user_name': 'datadog_username'}",
"resource_link": "datadog.com/feature/fallback_payments_test",
},
ChangedResource: datadogV2.ChangeEventCustomAttributesChangedResource{
Name: "fallback_payments_test",
Type: datadogV2.CHANGEEVENTCUSTOMATTRIBUTESCHANGEDRESOURCETYPE_FEATURE_FLAG,
},
ImpactedResources: []datadogV2.ChangeEventCustomAttributesImpactedResourcesItems{
{
Name: "payments_api",
Type: datadogV2.CHANGEEVENTCUSTOMATTRIBUTESIMPACTEDRESOURCESITEMSTYPE_SERVICE,
},
},
NewValue: map[string]interface{}{
"enabled": true,
"percentage": "50%",
"rule": "{'datacenter': 'devcycle.us1.prod'}",
},
PrevValue: map[string]interface{}{
"enabled": true,
"percentage": "10%",
"rule": "{'datacenter': 'devcycle.us1.prod'}",
},
}},
Category: datadogV2.EVENTCATEGORY_CHANGE,
IntegrationId: datadogV2.EVENTPAYLOADINTEGRATIONID_CUSTOM_EVENTS.Ptr(),
Host: datadog.PtrString("test-host"),
Message: datadog.PtrString("payment_processed feature flag has been enabled"),
Tags: []string{
"env:api_client_test",
},
Title: "payment_processed feature flag updated",
},
Type: datadogV2.EVENTCREATEREQUESTTYPE_EVENT,
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewEventsApi(apiClient)
resp, r, err := api.CreateEvent(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `EventsApi.CreateEvent`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `EventsApi.CreateEvent`:\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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"DD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"DD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"// Post an event returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.EventsApi;
import com.datadog.api.client.v2.model.ChangeEventCustomAttributes;
import com.datadog.api.client.v2.model.ChangeEventCustomAttributesAuthor;
import com.datadog.api.client.v2.model.ChangeEventCustomAttributesAuthorType;
import com.datadog.api.client.v2.model.ChangeEventCustomAttributesChangedResource;
import com.datadog.api.client.v2.model.ChangeEventCustomAttributesChangedResourceType;
import com.datadog.api.client.v2.model.ChangeEventCustomAttributesImpactedResourcesItems;
import com.datadog.api.client.v2.model.ChangeEventCustomAttributesImpactedResourcesItemsType;
import com.datadog.api.client.v2.model.EventCategory;
import com.datadog.api.client.v2.model.EventCreateRequest;
import com.datadog.api.client.v2.model.EventCreateRequestPayload;
import com.datadog.api.client.v2.model.EventCreateRequestType;
import com.datadog.api.client.v2.model.EventCreateResponsePayload;
import com.datadog.api.client.v2.model.EventPayload;
import com.datadog.api.client.v2.model.EventPayloadAttributes;
import com.datadog.api.client.v2.model.EventPayloadIntegrationId;
import java.util.Collections;
import java.util.Map;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
EventsApi apiInstance = new EventsApi(defaultClient);
EventCreateRequestPayload body =
new EventCreateRequestPayload()
.data(
new EventCreateRequest()
.attributes(
new EventPayload()
.aggregationKey("aggregation_key_123")
.attributes(
new EventPayloadAttributes(
new ChangeEventCustomAttributes()
.author(
new ChangeEventCustomAttributesAuthor()
.name("example@datadog.com")
.type(ChangeEventCustomAttributesAuthorType.USER))
.changeMetadata(
Map.ofEntries(
Map.entry(
"dd",
"{'team': 'datadog_team', 'user_email':"
+ " 'datadog@datadog.com', 'user_id':"
+ " 'datadog_user_id', 'user_name':"
+ " 'datadog_username'}"),
Map.entry(
"resource_link",
"datadog.com/feature/fallback_payments_test")))
.changedResource(
new ChangeEventCustomAttributesChangedResource()
.name("fallback_payments_test")
.type(
ChangeEventCustomAttributesChangedResourceType
.FEATURE_FLAG))
.impactedResources(
Collections.singletonList(
new ChangeEventCustomAttributesImpactedResourcesItems()
.name("payments_api")
.type(
ChangeEventCustomAttributesImpactedResourcesItemsType
.SERVICE)))
.newValue(
Map.ofEntries(
Map.entry("enabled", "True"),
Map.entry("percentage", "50%"),
Map.entry(
"rule", "{'datacenter': 'devcycle.us1.prod'}")))
.prevValue(
Map.ofEntries(
Map.entry("enabled", "True"),
Map.entry("percentage", "10%"),
Map.entry(
"rule",
"{'datacenter': 'devcycle.us1.prod'}")))))
.category(EventCategory.CHANGE)
.integrationId(EventPayloadIntegrationId.CUSTOM_EVENTS)
.host("test-host")
.message("payment_processed feature flag has been enabled")
.tags(Collections.singletonList("env:api_client_test"))
.title("payment_processed feature flag updated"))
.type(EventCreateRequestType.EVENT));
try {
EventCreateResponsePayload result = apiInstance.createEvent(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling EventsApi#createEvent");
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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"DD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"DD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java""""
Post an event returns "OK" response
"""
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.events_api import EventsApi
from datadog_api_client.v2.model.change_event_custom_attributes import ChangeEventCustomAttributes
from datadog_api_client.v2.model.change_event_custom_attributes_author import ChangeEventCustomAttributesAuthor
from datadog_api_client.v2.model.change_event_custom_attributes_author_type import ChangeEventCustomAttributesAuthorType
from datadog_api_client.v2.model.change_event_custom_attributes_changed_resource import (
ChangeEventCustomAttributesChangedResource,
)
from datadog_api_client.v2.model.change_event_custom_attributes_changed_resource_type import (
ChangeEventCustomAttributesChangedResourceType,
)
from datadog_api_client.v2.model.change_event_custom_attributes_impacted_resources_items import (
ChangeEventCustomAttributesImpactedResourcesItems,
)
from datadog_api_client.v2.model.change_event_custom_attributes_impacted_resources_items_type import (
ChangeEventCustomAttributesImpactedResourcesItemsType,
)
from datadog_api_client.v2.model.event_category import EventCategory
from datadog_api_client.v2.model.event_create_request import EventCreateRequest
from datadog_api_client.v2.model.event_create_request_payload import EventCreateRequestPayload
from datadog_api_client.v2.model.event_create_request_type import EventCreateRequestType
from datadog_api_client.v2.model.event_payload import EventPayload
from datadog_api_client.v2.model.event_payload_integration_id import EventPayloadIntegrationId
body = EventCreateRequestPayload(
data=EventCreateRequest(
attributes=EventPayload(
aggregation_key="aggregation_key_123",
attributes=ChangeEventCustomAttributes(
author=ChangeEventCustomAttributesAuthor(
name="example@datadog.com",
type=ChangeEventCustomAttributesAuthorType.USER,
),
change_metadata=dict(
[
(
"dd",
"{'team': 'datadog_team', 'user_email': 'datadog@datadog.com', 'user_id': 'datadog_user_id', 'user_name': 'datadog_username'}",
),
("resource_link", "datadog.com/feature/fallback_payments_test"),
]
),
changed_resource=ChangeEventCustomAttributesChangedResource(
name="fallback_payments_test",
type=ChangeEventCustomAttributesChangedResourceType.FEATURE_FLAG,
),
impacted_resources=[
ChangeEventCustomAttributesImpactedResourcesItems(
name="payments_api",
type=ChangeEventCustomAttributesImpactedResourcesItemsType.SERVICE,
),
],
new_value=dict(
[("enabled", "True"), ("percentage", "50%"), ("rule", "{'datacenter': 'devcycle.us1.prod'}")]
),
prev_value=dict(
[("enabled", "True"), ("percentage", "10%"), ("rule", "{'datacenter': 'devcycle.us1.prod'}")]
),
),
category=EventCategory.CHANGE,
integration_id=EventPayloadIntegrationId.CUSTOM_EVENTS,
host="test-host",
message="payment_processed feature flag has been enabled",
tags=[
"env:api_client_test",
],
title="payment_processed feature flag updated",
),
type=EventCreateRequestType.EVENT,
),
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = EventsApi(api_client)
response = api_instance.create_event(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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"DD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"DD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"# Post an event returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::EventsAPI.new
body = DatadogAPIClient::V2::EventCreateRequestPayload.new({
data: DatadogAPIClient::V2::EventCreateRequest.new({
attributes: DatadogAPIClient::V2::EventPayload.new({
aggregation_key: "aggregation_key_123",
attributes: DatadogAPIClient::V2::ChangeEventCustomAttributes.new({
author: DatadogAPIClient::V2::ChangeEventCustomAttributesAuthor.new({
name: "example@datadog.com",
type: DatadogAPIClient::V2::ChangeEventCustomAttributesAuthorType::USER,
}),
change_metadata: {
"dd": "{'team': 'datadog_team', 'user_email': 'datadog@datadog.com', 'user_id': 'datadog_user_id', 'user_name': 'datadog_username'}", "resource_link": "datadog.com/feature/fallback_payments_test",
},
changed_resource: DatadogAPIClient::V2::ChangeEventCustomAttributesChangedResource.new({
name: "fallback_payments_test",
type: DatadogAPIClient::V2::ChangeEventCustomAttributesChangedResourceType::FEATURE_FLAG,
}),
impacted_resources: [
DatadogAPIClient::V2::ChangeEventCustomAttributesImpactedResourcesItems.new({
name: "payments_api",
type: DatadogAPIClient::V2::ChangeEventCustomAttributesImpactedResourcesItemsType::SERVICE,
}),
],
new_value: {
"enabled": "True", "percentage": "50%", "rule": "{'datacenter': 'devcycle.us1.prod'}",
},
prev_value: {
"enabled": "True", "percentage": "10%", "rule": "{'datacenter': 'devcycle.us1.prod'}",
},
}),
category: DatadogAPIClient::V2::EventCategory::CHANGE,
integration_id: DatadogAPIClient::V2::EventPayloadIntegrationId::CUSTOM_EVENTS,
host: "test-host",
message: "payment_processed feature flag has been enabled",
tags: [
"env:api_client_test",
],
title: "payment_processed feature flag updated",
}),
type: DatadogAPIClient::V2::EventCreateRequestType::EVENT,
}),
})
p api_instance.create_event(body)
Instructions
First install the library and its dependencies 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"DD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"// Post an event returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_events::EventsAPI;
use datadog_api_client::datadogV2::model::ChangeEventCustomAttributes;
use datadog_api_client::datadogV2::model::ChangeEventCustomAttributesAuthor;
use datadog_api_client::datadogV2::model::ChangeEventCustomAttributesAuthorType;
use datadog_api_client::datadogV2::model::ChangeEventCustomAttributesChangedResource;
use datadog_api_client::datadogV2::model::ChangeEventCustomAttributesChangedResourceType;
use datadog_api_client::datadogV2::model::ChangeEventCustomAttributesImpactedResourcesItems;
use datadog_api_client::datadogV2::model::ChangeEventCustomAttributesImpactedResourcesItemsType;
use datadog_api_client::datadogV2::model::EventCategory;
use datadog_api_client::datadogV2::model::EventCreateRequest;
use datadog_api_client::datadogV2::model::EventCreateRequestPayload;
use datadog_api_client::datadogV2::model::EventCreateRequestType;
use datadog_api_client::datadogV2::model::EventPayload;
use datadog_api_client::datadogV2::model::EventPayloadAttributes;
use datadog_api_client::datadogV2::model::EventPayloadIntegrationId;
use serde_json::Value;
use std::collections::BTreeMap;
#[tokio::main]
async fn main() {
let body = EventCreateRequestPayload::new(EventCreateRequest::new(
EventPayload::new(
EventPayloadAttributes::ChangeEventCustomAttributes(Box::new(
ChangeEventCustomAttributes::new(ChangeEventCustomAttributesChangedResource::new(
"fallback_payments_test".to_string(),
ChangeEventCustomAttributesChangedResourceType::FEATURE_FLAG,
))
.author(ChangeEventCustomAttributesAuthor::new(
"example@datadog.com".to_string(),
ChangeEventCustomAttributesAuthorType::USER,
))
.change_metadata(BTreeMap::from([(
"resource_link".to_string(),
Value::from("datadog.com/feature/fallback_payments_test"),
)]))
.impacted_resources(vec![
ChangeEventCustomAttributesImpactedResourcesItems::new(
"payments_api".to_string(),
ChangeEventCustomAttributesImpactedResourcesItemsType::SERVICE,
),
])
.new_value(BTreeMap::from([
("enabled".to_string(), Value::from("True")),
("percentage".to_string(), Value::from("50%")),
]))
.prev_value(BTreeMap::from([
("enabled".to_string(), Value::from("True")),
("percentage".to_string(), Value::from("10%")),
])),
)),
EventCategory::CHANGE,
"payment_processed feature flag updated".to_string(),
)
.aggregation_key("aggregation_key_123".to_string())
.host("test-host".to_string())
.integration_id(EventPayloadIntegrationId::CUSTOM_EVENTS)
.message("payment_processed feature flag has been enabled".to_string())
.tags(vec!["env:api_client_test".to_string()]),
EventCreateRequestType::EVENT,
));
let configuration = datadog::Configuration::new();
let api = EventsAPI::with_config(configuration);
let resp = api.create_event(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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run/**
* Post an event returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v2.EventsApi(configuration);
const params: v2.EventsApiCreateEventRequest = {
body: {
data: {
attributes: {
aggregationKey: "aggregation_key_123",
attributes: {
author: {
name: "example@datadog.com",
type: "user",
},
changeMetadata: {
dd: "{'team': 'datadog_team', 'user_email': 'datadog@datadog.com', 'user_id': 'datadog_user_id', 'user_name': 'datadog_username'}",
resource_link: "datadog.com/feature/fallback_payments_test",
},
changedResource: {
name: "fallback_payments_test",
type: "feature_flag",
},
impactedResources: [
{
name: "payments_api",
type: "service",
},
],
newValue: {
enabled: "True",
percentage: "50%",
rule: "{'datacenter': 'devcycle.us1.prod'}",
},
prevValue: {
enabled: "True",
percentage: "10%",
rule: "{'datacenter': 'devcycle.us1.prod'}",
},
},
category: "change",
integrationId: "custom-events",
host: "test-host",
message: "payment_processed feature flag has been enabled",
tags: ["env:api_client_test"],
title: "payment_processed feature flag updated",
},
type: "event",
},
},
};
apiInstance
.createEvent(params)
.then((data: v2.EventCreateResponsePayload) => {
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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"https://api.datadoghq.com/api/v1/eventshttps://api.us3.datadoghq.com/api/v1/eventshttps://api.us5.datadoghq.com/api/v1/eventshttps://api.datadoghq.eu/api/v1/eventshttps://api.ap1.datadoghq.com/api/v1/eventshttps://api.ap2.datadoghq.com/api/v1/eventshttps://api.uk1.datadoghq.com/api/v1/eventshttps://api.ddog-gov.com/api/v1/eventshttps://api.us2.ddog-gov.com/api/v1/eventsOverview
This endpoint is deprecated and is available only to organizations that have previously used it. Use the V2 endpoint instead.
This endpoint allows you to post events to the stream. Tag them, set priority and event aggregate them with other events.
Request
Body Data (required)
Event request object
aggregation_keyAn arbitrary string to use for aggregation. Limited to 100 characters. If you specify a key, all events using that key are grouped together in the Event Stream.
alert_typeIf an alert event is enabled, set its type.
For example, error, warning, info, success, user_update,
recommendation, and snapshot.
error, warning, info, success, user_update, recommendation, snapshotdate_happenedPOSIX timestamp of the event. Must be sent as an integer (that is no quotes). Limited to events no older than 18 hours
device_nameA device name.
hostHost name to associate with the event. Any tags associated with the host are also applied to this event.
priorityThe priority of the event. For example, normal or low.
normal, lowrelated_event_idID of the parent event. Must be sent as an integer (that is no quotes).
source_type_nameThe type of event being posted. Option examples include nagios, hudson, jenkins, my_apps, chef, puppet, git, bitbucket, etc. A complete list of source attribute values available here.
tagsA list of tags to apply to the event.
text [required]The body of the event. Limited to 4000 characters. The text supports markdown.
To use markdown in the event text, start the text block with %%% \n and end the text block with \n %%%.
Use msg_text with the Datadog Ruby library.
title [required]The event title.
{
"priority": "normal",
"tags": [
"environment:test"
],
"text": "Oh boy!",
"title": "Did you hear the news today?"
}Response
OK
Object containing an event response.
eventObject representing an event.
alert_typeIf an alert event is enabled, set its type.
For example, error, warning, info, success, user_update,
recommendation, and snapshot.
error, warning, info, success, user_update, recommendation, snapshotdate_happenedPOSIX timestamp of the event. Must be sent as an integer (that is no quotes). Limited to events up to 18 hours in the past and two hours in the future.
device_nameA device name.
hostHost name to associate with the event. Any tags associated with the host are also applied to this event.
idInteger ID of the event.
id_strHandling IDs as large 64-bit numbers can cause loss of accuracy issues with some programming languages. Instead, use the string representation of the Event ID to avoid losing accuracy.
payloadPayload of the event.
priorityThe priority of the event. For example, normal or low.
normal, lowsource_type_nameThe type of event being posted. Option examples include nagios, hudson, jenkins, my_apps, chef, puppet, git, bitbucket, etc. The list of standard source attribute values available here.
tagsA list of tags to apply to the event.
textThe body of the event. Limited to 4000 characters. The text supports markdown.
To use markdown in the event text, start the text block with %%% \n and end the text block with \n %%%.
Use msg_text with the Datadog Ruby library.
titleThe event title.
urlURL of the event.
statusA status.
{
"event": {
"alert_type": "info",
"date_happened": "integer",
"device_name": "string",
"host": "string",
"id": "integer",
"id_str": "string",
"payload": "{}",
"priority": "normal",
"source_type_name": "string",
"tags": [
"environment:test"
],
"text": "Oh boy!",
"title": "Did you hear the news today?",
"url": "string"
},
"status": "string"
}Bad Request
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Too many requests
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Code Example
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
export DD_API_KEY="<DD_API_KEY>"
curl -X POST "https://api.${DD_SITE}/api/v1/events" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
"priority": "normal",
"tags": [
"environment:test"
],
"text": "Oh boy!",
"title": "Did you hear the news today?"
}
EOF# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
export DD_API_KEY="<DD_API_KEY>"
curl -X POST "https://api.${DD_SITE}/api/v1/events" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
"priority": "normal",
"tags": [
"environment:test"
],
"text": "Oh boy!",
"title": "Did you hear the news today?"
}
EOF# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
export DD_API_KEY="<DD_API_KEY>"
curl -X POST "https://api.${DD_SITE}/api/v1/events" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
"priority": "normal",
"tags": [
"environment:test"
],
"text": "Oh boy!",
"title": "Did you hear the news today?"
}
EOF# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
export DD_API_KEY="<DD_API_KEY>"
curl -X POST "https://api.${DD_SITE}/api/v1/events" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
"priority": "normal",
"tags": [
"environment:test"
],
"text": "Oh boy!",
"title": "Did you hear the news today?"
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
export DD_API_KEY="<DD_API_KEY>"
curl -X POST "https://api.${DD_SITE}/api/v1/events" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
"priority": "normal",
"tags": [
"environment:test"
],
"text": "Oh boy!",
"title": "Did you hear the news today?"
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
export DD_API_KEY="<DD_API_KEY>"
curl -X POST "https://api.${DD_SITE}/api/v1/events" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
"priority": "normal",
"tags": [
"environment:test"
],
"text": "Oh boy!",
"title": "Did you hear the news today?"
}
EOF# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
export DD_API_KEY="<DD_API_KEY>"
curl -X POST "https://api.${DD_SITE}/api/v1/events" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
"priority": "normal",
"tags": [
"environment:test"
],
"text": "Oh boy!",
"title": "Did you hear the news today?"
}
EOF# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
export DD_API_KEY="<DD_API_KEY>"
curl -X POST "https://api.${DD_SITE}/api/v1/events" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
"priority": "normal",
"tags": [
"environment:test"
],
"text": "Oh boy!",
"title": "Did you hear the news today?"
}
EOF# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
export DD_API_KEY="<DD_API_KEY>"
curl -X POST "https://api.${DD_SITE}/api/v1/events" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
"priority": "normal",
"tags": [
"environment:test"
],
"text": "Oh boy!",
"title": "Did you hear the news today?"
}
EOFPost an event returns "OK" response
// Post an event returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main() {
body := datadogV1.EventCreateRequest{
Title: "Example-Event",
Text: "A text message.",
Tags: []string{
"test:ExampleEvent",
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewEventsApi(apiClient)
resp, r, err := api.CreateEvent(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `EventsApi.CreateEvent`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `EventsApi.CreateEvent`:\n%s\n", responseContent)
}
Post an event with a long title returns "OK" response
// Post an event with a long title returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main() {
body := datadogV1.EventCreateRequest{
Title: "Example-Event very very very looooooooong looooooooooooong loooooooooooooooooooooong looooooooooooooooooooooooooong title with 100+ characters",
Text: "A text message.",
Tags: []string{
"test:ExampleEvent",
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewEventsApi(apiClient)
resp, r, err := api.CreateEvent(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `EventsApi.CreateEvent`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `EventsApi.CreateEvent`:\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.com" DD_API_KEY="<DD_API_KEY>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" go run "main.go"DD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" go run "main.go"DD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" go run "main.go"Post an event returns "OK" response
// Post an event returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.EventsApi;
import com.datadog.api.client.v1.model.EventCreateRequest;
import com.datadog.api.client.v1.model.EventCreateResponse;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
EventsApi apiInstance = new EventsApi(defaultClient);
EventCreateRequest body =
new EventCreateRequest()
.title("Example-Event")
.text("A text message.")
.tags(Collections.singletonList("test:ExampleEvent"));
try {
EventCreateResponse result = apiInstance.createEvent(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling EventsApi#createEvent");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Post an event with a long title returns "OK" response
// Post an event with a long title returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.EventsApi;
import com.datadog.api.client.v1.model.EventCreateRequest;
import com.datadog.api.client.v1.model.EventCreateResponse;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
EventsApi apiInstance = new EventsApi(defaultClient);
EventCreateRequest body =
new EventCreateRequest()
.title(
"Example-Event very very very looooooooong looooooooooooong"
+ " loooooooooooooooooooooong looooooooooooooooooooooooooong title with 100+"
+ " characters")
.text("A text message.")
.tags(Collections.singletonList("test:ExampleEvent"));
try {
EventCreateResponse result = apiInstance.createEvent(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling EventsApi#createEvent");
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.com" DD_API_KEY="<DD_API_KEY>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" java "Example.java"DD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" java "Example.java"DD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" java "Example.java"Post an event returns "OK" response
"""
Post an event returns "OK" response
"""
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.events_api import EventsApi
from datadog_api_client.v1.model.event_create_request import EventCreateRequest
body = EventCreateRequest(
title="Example-Event",
text="A text message.",
tags=[
"test:ExampleEvent",
],
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = EventsApi(api_client)
response = api_instance.create_event(body=body)
print(response)
Post an event with a long title returns "OK" response
"""
Post an event with a long title returns "OK" response
"""
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.events_api import EventsApi
from datadog_api_client.v1.model.event_create_request import EventCreateRequest
body = EventCreateRequest(
title="Example-Event very very very looooooooong looooooooooooong loooooooooooooooooooooong looooooooooooooooooooooooooong title with 100+ characters",
text="A text message.",
tags=[
"test:ExampleEvent",
],
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = EventsApi(api_client)
response = api_instance.create_event(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.com" DD_API_KEY="<DD_API_KEY>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" python3 "example.py"DD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" python3 "example.py"DD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" python3 "example.py"Post an event returns "OK" response
# Post an event returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V1::EventsAPI.new
body = DatadogAPIClient::V1::EventCreateRequest.new({
title: "Example-Event",
text: "A text message.",
tags: [
"test:ExampleEvent",
],
})
p api_instance.create_event(body)
Post an event with a long title returns "OK" response
# Post an event with a long title returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V1::EventsAPI.new
body = DatadogAPIClient::V1::EventCreateRequest.new({
title: "Example-Event very very very looooooooong looooooooooooong loooooooooooooooooooooong looooooooooooooooooooooooooong title with 100+ characters",
text: "A text message.",
tags: [
"test:ExampleEvent",
],
})
p api_instance.create_event(body)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"DD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"DD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"Post an event returns "OK" response
// Post an event returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_events::EventsAPI;
use datadog_api_client::datadogV1::model::EventCreateRequest;
#[tokio::main]
async fn main() {
let body = EventCreateRequest::new("A text message.".to_string(), "Example-Event".to_string())
.tags(vec!["test:ExampleEvent".to_string()]);
let configuration = datadog::Configuration::new();
let api = EventsAPI::with_config(configuration);
let resp = api.create_event(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Post an event with a long title returns "OK" response
// Post an event with a long title returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_events::EventsAPI;
use datadog_api_client::datadogV1::model::EventCreateRequest;
#[tokio::main]
async fn main() {
let body =
EventCreateRequest::new(
"A text message.".to_string(),
"Example-Event very very very looooooooong looooooooooooong loooooooooooooooooooooong looooooooooooooooooooooooooong title with 100+ characters".to_string(),
).tags(vec!["test:ExampleEvent".to_string()]);
let configuration = datadog::Configuration::new();
let api = EventsAPI::with_config(configuration);
let resp = api.create_event(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.com" DD_API_KEY="<DD_API_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" cargo runPost an event returns "OK" response
/**
* Post an event returns "OK" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v1.EventsApi(configuration);
const params: v1.EventsApiCreateEventRequest = {
body: {
title: "Example-Event",
text: "A text message.",
tags: ["test:ExampleEvent"],
},
};
apiInstance
.createEvent(params)
.then((data: v1.EventCreateResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Post an event with a long title returns "OK" response
/**
* Post an event with a long title returns "OK" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v1.EventsApi(configuration);
const params: v1.EventsApiCreateEventRequest = {
body: {
title:
"Example-Event very very very looooooooong looooooooooooong loooooooooooooooooooooong looooooooooooooooooooooooooong title with 100+ characters",
text: "A text message.",
tags: ["test:ExampleEvent"],
},
};
apiInstance
.createEvent(params)
.then((data: v1.EventCreateResponse) => {
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.com" DD_API_KEY="<DD_API_KEY>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" tsc "example.ts"from datadog import initialize, api
options = {
'api_key': '<DATADOG_API_KEY>',
'app_key': '<DATADOG_APPLICATION_KEY>'
}
initialize(**options)
title = "Something big happened!"
text = 'And let me tell you all about it here!'
tags = ['version:1', 'application:web']
api.Event.create(title=title, text=text, tags=tags)
# If you are programmatically adding a comment to this new event
# you might want to insert a pause of .5 - 1 second to allow the
# event to be available.
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" python "example.py"DD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" python "example.py"DD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" python "example.py"DD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" python "example.py"DD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" python "example.py"DD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" python "example.py"DD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" python "example.py"DD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" python "example.py"DD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" python "example.py"require 'rubygems'
require 'dogapi'
api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'
dog = Dogapi::Client.new(api_key, app_key)
# submitting events doesn 't require an application_key,
# so we don't bother setting it
dog = Dogapi::Client.new(api_key)
dog.emit_event(Dogapi::Event.new('msg_text', :msg_title => 'Title'))
# If you are programmatically adding a comment to this new event
# you might want to insert a pause of.5 - 1 second to allow the
# event to be available.Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"DD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"DD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" rb "example.rb"