Updates an existing annotation.
Valid color values: gray, blue, purple, green, yellow, red.
Valid type values: pointInTime (marks a single moment) or timeRegion (spans a range and requires end_time).
Attributes for creating or updating an annotation.
color [required]
enum
Color used to render the annotation in the UI.
Allowed enum values: gray,blue,purple,green,yellow,red
description [required]
string
User-defined text attached to the annotation.
end_time
int64
End time of the annotation in milliseconds since the Unix epoch. Required for timeRegion annotations; omit or set to null for pointInTime annotations.
page_id [required]
string
ID of the page the annotation belongs to, prefixed with the page type and joined by a colon
(for example, dashboard:abc-def-xyz or notebook:1234567890).
start_time [required]
int64
Start time of the annotation in milliseconds since the Unix epoch.
type [required]
enum
Kind of annotation. pointInTime annotations mark a single moment in time,
while timeRegion annotations span a window of time and require an end_time.
Allowed enum values: pointInTime,timeRegion
widget_ids
[string]
IDs of widgets the annotation is associated with. When empty or omitted, the annotation applies to the whole page.
Attributes of an annotation returned in a response.
author_id [required]
string
Identifier of the user who created the annotation.
color [required]
enum
Color used to render the annotation in the UI.
Allowed enum values: gray,blue,purple,green,yellow,red
created_at [required]
int64
Creation time of the annotation in milliseconds since the Unix epoch.
description [required]
string
User-defined text attached to the annotation.
end_time [required]
int64
End time of the annotation in milliseconds since the Unix epoch. Null for pointInTime annotations.
modified_at [required]
int64
Last modification time of the annotation in milliseconds since the Unix epoch.
page_id [required]
string
ID of the page the annotation belongs to, prefixed with the page type and joined by a colon
(for example, dashboard:abc-def-xyz or notebook:1234567890).
start_time [required]
int64
Start time of the annotation in milliseconds since the Unix epoch.
type [required]
enum
Kind of annotation. pointInTime annotations mark a single moment in time,
while timeRegion annotations span a window of time and require an end_time.
Allowed enum values: pointInTime,timeRegion
widget_ids
[string]
IDs of widgets the annotation is associated with. When empty or omitted, the annotation applies to the whole page.
{"data":{"attributes":{"author_id":"00000000-0000-0000-0000-000000000000","color":"blue","created_at":1704067200000,"description":"Deployed v2.3.1 to production.","end_time":1704070800000,"modified_at":1704067200000,"page_id":"dashboard:abc-def-xyz","start_time":1704067200000,"type":"pointInTime","widget_ids":["1234567890"]},"id":"00000000-0000-0000-0000-000000000000","type":"annotation"}}
// Update an annotation 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""github.com/google/uuid")funcmain(){// there is a valid "annotation" in the systemAnnotationDataID:=uuid.MustParse(os.Getenv("ANNOTATION_DATA_ID"))body:=datadogV2.AnnotationUpdateRequest{Data:datadogV2.AnnotationRequestData{Attributes:datadogV2.AnnotationCreateAttributes{Color:datadogV2.ANNOTATIONCOLOR_GREEN,Description:"Updated annotation.",PageId:"dashboard:abc-def-xyz",StartTime:1704067200000,Type:datadogV2.ANNOTATIONKIND_POINT_IN_TIME,},Type:datadogV2.ANNOTATIONTYPE_ANNOTATION,},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()configuration.SetUnstableOperationEnabled("v2.UpdateAnnotation",true)apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewAnnotationsApi(apiClient)resp,r,err:=api.UpdateAnnotation(ctx,AnnotationDataID,body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `AnnotationsApi.UpdateAnnotation`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `AnnotationsApi.UpdateAnnotation`:\n%s\n",responseContent)}
// Update an annotation returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.AnnotationsApi;importcom.datadog.api.client.v2.model.AnnotationColor;importcom.datadog.api.client.v2.model.AnnotationCreateAttributes;importcom.datadog.api.client.v2.model.AnnotationKind;importcom.datadog.api.client.v2.model.AnnotationRequestData;importcom.datadog.api.client.v2.model.AnnotationResponse;importcom.datadog.api.client.v2.model.AnnotationType;importcom.datadog.api.client.v2.model.AnnotationUpdateRequest;importjava.util.UUID;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();defaultClient.setUnstableOperationEnabled("v2.updateAnnotation",true);AnnotationsApiapiInstance=newAnnotationsApi(defaultClient);// there is a valid "annotation" in the systemUUIDANNOTATION_DATA_ID=null;try{ANNOTATION_DATA_ID=UUID.fromString(System.getenv("ANNOTATION_DATA_ID"));}catch(IllegalArgumentExceptione){System.err.println("Error parsing UUID: "+e.getMessage());}AnnotationUpdateRequestbody=newAnnotationUpdateRequest().data(newAnnotationRequestData().attributes(newAnnotationCreateAttributes().color(AnnotationColor.GREEN).description("Updated annotation.").pageId("dashboard:abc-def-xyz").startTime(1704067200000L).type(AnnotationKind.POINT_IN_TIME)).type(AnnotationType.ANNOTATION));try{AnnotationResponseresult=apiInstance.updateAnnotation(ANNOTATION_DATA_ID,body);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling AnnotationsApi#updateAnnotation");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
"""
Update an annotation returns "OK" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.annotations_apiimportAnnotationsApifromdatadog_api_client.v2.model.annotation_colorimportAnnotationColorfromdatadog_api_client.v2.model.annotation_create_attributesimportAnnotationCreateAttributesfromdatadog_api_client.v2.model.annotation_kindimportAnnotationKindfromdatadog_api_client.v2.model.annotation_request_dataimportAnnotationRequestDatafromdatadog_api_client.v2.model.annotation_typeimportAnnotationTypefromdatadog_api_client.v2.model.annotation_update_requestimportAnnotationUpdateRequest# there is a valid "annotation" in the systemANNOTATION_DATA_ID=environ["ANNOTATION_DATA_ID"]body=AnnotationUpdateRequest(data=AnnotationRequestData(attributes=AnnotationCreateAttributes(color=AnnotationColor.GREEN,description="Updated annotation.",page_id="dashboard:abc-def-xyz",start_time=1704067200000,type=AnnotationKind.POINT_IN_TIME,),type=AnnotationType.ANNOTATION,),)configuration=Configuration()configuration.unstable_operations["update_annotation"]=TruewithApiClient(configuration)asapi_client:api_instance=AnnotationsApi(api_client)response=api_instance.update_annotation(annotation_id=ANNOTATION_DATA_ID,body=body)print(response)
# Update an annotation returns "OK" responserequire"datadog_api_client"DatadogAPIClient.configuredo|config|config.unstable_operations["v2.update_annotation".to_sym]=trueendapi_instance=DatadogAPIClient::V2::AnnotationsAPI.new# there is a valid "annotation" in the systemANNOTATION_DATA_ID=ENV["ANNOTATION_DATA_ID"]body=DatadogAPIClient::V2::AnnotationUpdateRequest.new({data:DatadogAPIClient::V2::AnnotationRequestData.new({attributes:DatadogAPIClient::V2::AnnotationCreateAttributes.new({color:DatadogAPIClient::V2::AnnotationColor::GREEN,description:"Updated annotation.",page_id:"dashboard:abc-def-xyz",start_time:1704067200000,type:DatadogAPIClient::V2::AnnotationKind::POINT_IN_TIME,}),type:DatadogAPIClient::V2::AnnotationType::ANNOTATION,}),})papi_instance.update_annotation(ANNOTATION_DATA_ID,body)
// Update an annotation returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_annotations::AnnotationsAPI;usedatadog_api_client::datadogV2::model::AnnotationColor;usedatadog_api_client::datadogV2::model::AnnotationCreateAttributes;usedatadog_api_client::datadogV2::model::AnnotationKind;usedatadog_api_client::datadogV2::model::AnnotationRequestData;usedatadog_api_client::datadogV2::model::AnnotationType;usedatadog_api_client::datadogV2::model::AnnotationUpdateRequest;#[tokio::main]asyncfnmain(){// there is a valid "annotation" in the system
letannotation_data_id=uuid::Uuid::parse_str(&std::env::var("ANNOTATION_DATA_ID").unwrap()).expect("Invalid UUID");letbody=AnnotationUpdateRequest::new(AnnotationRequestData::new(AnnotationCreateAttributes::new(AnnotationColor::GREEN,"Updated annotation.".to_string(),"dashboard:abc-def-xyz".to_string(),1704067200000,AnnotationKind::POINT_IN_TIME,),AnnotationType::ANNOTATION,));letmutconfiguration=datadog::Configuration::new();configuration.set_unstable_operation_enabled("v2.UpdateAnnotation",true);letapi=AnnotationsAPI::with_config(configuration);letresp=api.update_annotation(annotation_data_id.clone(),body).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Update an annotation returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();configuration.unstableOperations["v2.updateAnnotation"]=true;constapiInstance=newv2.AnnotationsApi(configuration);// there is a valid "annotation" in the system
constANNOTATION_DATA_ID=process.env.ANNOTATION_DATA_IDasstring;constparams: v2.AnnotationsApiUpdateAnnotationRequest={body:{data:{attributes:{color:"green",description:"Updated annotation.",pageId:"dashboard:abc-def-xyz",startTime: 1704067200000,type:"pointInTime",},type:"annotation",},},annotationId: ANNOTATION_DATA_ID,};apiInstance.updateAnnotation(params).then((data: v2.AnnotationResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));