An 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_type
enum
If an alert event is enabled, set its type.
For example, error, warning, info, success, user_update,
recommendation, and snapshot.
Allowed enum values: error,warning,info,success,user_update,recommendation,snapshot
date_happened
int64
POSIX timestamp of the event. Must be sent as an integer (that is no quotes).
Limited to events no older than 18 hours
device_name
string
A device name.
host
string
Host name to associate with the event.
Any tags associated with the host are also applied to this event.
priority
enum
The priority of the event. For example, normal or low.
Allowed enum values: normal,low
related_event_id
int64
ID of the parent event. Must be sent as an integer (that is no quotes).
source_type_name
string
The 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.
tags
[string]
A list of tags to apply to the event.
text [required]
string
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]
string
The event title.
{"title":"Example-Event","text":"A text message.","tags":["test:ExampleEvent"]}
{"title":"Example-Event very very very looooooooong looooooooooooong loooooooooooooooooooooong looooooooooooooooooooooooooong title with 100+ characters","text":"A text message.","tags":["test:ExampleEvent"]}
If an alert event is enabled, set its type.
For example, error, warning, info, success, user_update,
recommendation, and snapshot.
Allowed enum values: error,warning,info,success,user_update,recommendation,snapshot
date_happened
int64
POSIX 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_name
string
A device name.
host
string
Host name to associate with the event.
Any tags associated with the host are also applied to this event.
id
int64
Integer ID of the event.
id_str
string
Handling 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.
payload
string
Payload of the event.
priority
enum
The priority of the event. For example, normal or low.
Allowed enum values: normal,low
source_type_name
string
The 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.
tags
[string]
A list of tags to apply to the event.
text
string
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
string
The event title.
url
string
URL of the event.
status
string
A 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"}
// Post an event returns "OK" responsepackagemainimport("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")funcmain(){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)iferr!=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" responsepackagemainimport("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")funcmain(){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)iferr!=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 returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v1.api.EventsApi;importcom.datadog.api.client.v1.model.EventCreateRequest;importcom.datadog.api.client.v1.model.EventCreateResponse;importjava.util.Collections;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();EventsApiapiInstance=newEventsApi(defaultClient);EventCreateRequestbody=newEventCreateRequest().title("Example-Event").text("A text message.").tags(Collections.singletonList("test:ExampleEvent"));try{EventCreateResponseresult=apiInstance.createEvent(body);System.out.println(result);}catch(ApiExceptione){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" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v1.api.EventsApi;importcom.datadog.api.client.v1.model.EventCreateRequest;importcom.datadog.api.client.v1.model.EventCreateResponse;importjava.util.Collections;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();EventsApiapiInstance=newEventsApi(defaultClient);EventCreateRequestbody=newEventCreateRequest().title("Example-Event very very very looooooooong looooooooooooong"+" loooooooooooooooooooooong looooooooooooooooooooooooooong title with 100+"+" characters").text("A text message.").tags(Collections.singletonList("test:ExampleEvent"));try{EventCreateResponseresult=apiInstance.createEvent(body);System.out.println(result);}catch(ApiExceptione){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();}}}
fromdatadogimportinitialize,apioptions={'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.
"""
Post an event returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v1.api.events_apiimportEventsApifromdatadog_api_client.v1.model.event_create_requestimportEventCreateRequestbody=EventCreateRequest(title="Example-Event",text="A text message.",tags=["test:ExampleEvent",],)configuration=Configuration()withApiClient(configuration)asapi_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
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v1.api.events_apiimportEventsApifromdatadog_api_client.v1.model.event_create_requestimportEventCreateRequestbody=EventCreateRequest(title="Example-Event very very very looooooooong looooooooooooong loooooooooooooooooooooong looooooooooooooooooooooooooong title with 100+ characters",text="A text message.",tags=["test:ExampleEvent",],)configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=EventsApi(api_client)response=api_instance.create_event(body=body)print(response)
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 itdog=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.
# Post an event returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V1::EventsAPI.newbody=DatadogAPIClient::V1::EventCreateRequest.new({title:"Example-Event",text:"A text message.",tags:["test:ExampleEvent",],})papi_instance.create_event(body)
# Post an event with a long title returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V1::EventsAPI.newbody=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",],})papi_instance.create_event(body)
// Post an event returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV1::api_events::EventsAPI;usedatadog_api_client::datadogV1::model::EventCreateRequest;#[tokio::main]asyncfnmain(){letbody=EventCreateRequest::new("A text message.".to_string(),"Example-Event".to_string()).tags(vec!["test:ExampleEvent".to_string()]);letconfiguration=datadog::Configuration::new();letapi=EventsAPI::with_config(configuration);letresp=api.create_event(body).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
// Post an event with a long title returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV1::api_events::EventsAPI;usedatadog_api_client::datadogV1::model::EventCreateRequest;#[tokio::main]asyncfnmain(){letbody=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()]);letconfiguration=datadog::Configuration::new();letapi=EventsAPI::with_config(configuration);letresp=api.create_event(body).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"cargo run
/**
* Post an event returns "OK" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.EventsApi(configuration);constparams: 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
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.EventsApi(configuration);constparams: 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));
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).
✅ Only events with the change or alert category are in General Availability. For change events, see Change Tracking for more details.
❌ For use cases involving other event categories, use the V1 endpoint or reach out to support.
A 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]
<oneOf>
JSON object for category-specific attributes. Schema is different per event category.
Option 1
object
Change event attributes.
author
object
The entity that made the change. Optional, if provided it must include type and name.
name [required]
string
The name of the user or system that made the change. Limited to 128 characters.
Free 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]
object
A uniquely identified resource.
name [required]
string
The name of the resource that was changed. Limited to 128 characters. Must contain at least one non-whitespace character.
type [required]
enum
The type of the resource that was changed.
Allowed enum values: feature_flag,configuration
impacted_resources
[object]
A 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]
string
The name of the impacted resource. Limited to 128 characters.
type [required]
enum
The type of the impacted resource.
Allowed enum values: service
new_value
object
Free form JSON object representing the new state of the changed resource.
prev_value
object
Free form JSON object representing the previous state of the changed resource.
Option 2
object
Alert event attributes.
custom
object
Free form JSON object for arbitrary data. Supports up to 100 properties per object and a maximum nesting depth of 10 levels.
links
[object]
The links related to the event. Maximum of 20 links allowed.
category [required]
enum
The category of the link.
Allowed enum values: runbook,documentation,dashboard,resource
title
string
The display text of the link. Limited to 300 characters.
url [required]
string
The URL of the link. Limited to 2048 characters.
priority
enum
The priority of the alert.
Allowed enum values: 1,2,3,4,5
default: 5
status [required]
enum
The status of the alert.
Allowed enum values: warn,error,ok
category [required]
enum
Event category identifying the type of event.
Allowed enum values: change,alert
host
string
Host name to associate with the event. Any tags associated with the host are also applied to this event. Limited to 255 characters.
integration_id
enum
Integration ID sourced from integration manifests.
Allowed enum values: custom-events
message
string
Free formed text associated with the event. It's suggested to use data.attributes.attributes.custom for well-structured attributes. Limited to 4000 characters.
tags
[string]
A list of tags associated with the event. Maximum of 100 tags allowed.
Refer to Tags docs.
timestamp
string
Timestamp 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]
string
The title of the event. Limited to 500 characters.
type [required]
enum
Entity type.
Allowed enum values: 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","integration_id":"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"}}
// Post an event returns "OK" responsepackagemainimport("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")funcmain(){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)iferr!=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 returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.EventsApi;importcom.datadog.api.client.v2.model.ChangeEventCustomAttributes;importcom.datadog.api.client.v2.model.ChangeEventCustomAttributesAuthor;importcom.datadog.api.client.v2.model.ChangeEventCustomAttributesAuthorType;importcom.datadog.api.client.v2.model.ChangeEventCustomAttributesChangedResource;importcom.datadog.api.client.v2.model.ChangeEventCustomAttributesChangedResourceType;importcom.datadog.api.client.v2.model.ChangeEventCustomAttributesImpactedResourcesItems;importcom.datadog.api.client.v2.model.ChangeEventCustomAttributesImpactedResourcesItemsType;importcom.datadog.api.client.v2.model.EventCategory;importcom.datadog.api.client.v2.model.EventCreateRequest;importcom.datadog.api.client.v2.model.EventCreateRequestPayload;importcom.datadog.api.client.v2.model.EventCreateRequestType;importcom.datadog.api.client.v2.model.EventCreateResponsePayload;importcom.datadog.api.client.v2.model.EventPayload;importcom.datadog.api.client.v2.model.EventPayloadAttributes;importcom.datadog.api.client.v2.model.EventPayloadIntegrationId;importjava.util.Collections;importjava.util.Map;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();EventsApiapiInstance=newEventsApi(defaultClient);EventCreateRequestPayloadbody=newEventCreateRequestPayload().data(newEventCreateRequest().attributes(newEventPayload().aggregationKey("aggregation_key_123").attributes(newEventPayloadAttributes(newChangeEventCustomAttributes().author(newChangeEventCustomAttributesAuthor().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(newChangeEventCustomAttributesChangedResource().name("fallback_payments_test").type(ChangeEventCustomAttributesChangedResourceType.FEATURE_FLAG)).impactedResources(Collections.singletonList(newChangeEventCustomAttributesImpactedResourcesItems().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{EventCreateResponsePayloadresult=apiInstance.createEvent(body);System.out.println(result);}catch(ApiExceptione){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 returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.events_apiimportEventsApifromdatadog_api_client.v2.model.change_event_custom_attributesimportChangeEventCustomAttributesfromdatadog_api_client.v2.model.change_event_custom_attributes_authorimportChangeEventCustomAttributesAuthorfromdatadog_api_client.v2.model.change_event_custom_attributes_author_typeimportChangeEventCustomAttributesAuthorTypefromdatadog_api_client.v2.model.change_event_custom_attributes_changed_resourceimport(ChangeEventCustomAttributesChangedResource,)fromdatadog_api_client.v2.model.change_event_custom_attributes_changed_resource_typeimport(ChangeEventCustomAttributesChangedResourceType,)fromdatadog_api_client.v2.model.change_event_custom_attributes_impacted_resources_itemsimport(ChangeEventCustomAttributesImpactedResourcesItems,)fromdatadog_api_client.v2.model.change_event_custom_attributes_impacted_resources_items_typeimport(ChangeEventCustomAttributesImpactedResourcesItemsType,)fromdatadog_api_client.v2.model.event_categoryimportEventCategoryfromdatadog_api_client.v2.model.event_create_requestimportEventCreateRequestfromdatadog_api_client.v2.model.event_create_request_payloadimportEventCreateRequestPayloadfromdatadog_api_client.v2.model.event_create_request_typeimportEventCreateRequestTypefromdatadog_api_client.v2.model.event_payloadimportEventPayloadfromdatadog_api_client.v2.model.event_payload_integration_idimportEventPayloadIntegrationIdbody=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()withApiClient(configuration)asapi_client:api_instance=EventsApi(api_client)response=api_instance.create_event(body=body)print(response)
# Post an event returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::EventsAPI.newbody=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,}),})papi_instance.create_event(body)
// Post an event returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_events::EventsAPI;usedatadog_api_client::datadogV2::model::ChangeEventCustomAttributes;usedatadog_api_client::datadogV2::model::ChangeEventCustomAttributesAuthor;usedatadog_api_client::datadogV2::model::ChangeEventCustomAttributesAuthorType;usedatadog_api_client::datadogV2::model::ChangeEventCustomAttributesChangedResource;usedatadog_api_client::datadogV2::model::ChangeEventCustomAttributesChangedResourceType;usedatadog_api_client::datadogV2::model::ChangeEventCustomAttributesImpactedResourcesItems;usedatadog_api_client::datadogV2::model::ChangeEventCustomAttributesImpactedResourcesItemsType;usedatadog_api_client::datadogV2::model::EventCategory;usedatadog_api_client::datadogV2::model::EventCreateRequest;usedatadog_api_client::datadogV2::model::EventCreateRequestPayload;usedatadog_api_client::datadogV2::model::EventCreateRequestType;usedatadog_api_client::datadogV2::model::EventPayload;usedatadog_api_client::datadogV2::model::EventPayloadAttributes;usedatadog_api_client::datadogV2::model::EventPayloadIntegrationId;useserde_json::Value;usestd::collections::BTreeMap;#[tokio::main]asyncfnmain(){letbody=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,));letconfiguration=datadog::Configuration::new();letapi=EventsAPI::with_config(configuration);letresp=api.create_event(body).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.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";constconfiguration=client.createConfiguration();constapiInstance=newv2.EventsApi(configuration);constparams: 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));