Skip to content

Update events intake specs for v2 Events post endpoint #2355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
273 changes: 230 additions & 43 deletions .generator/schemas/v2/openapi.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"2025-06-10T15:38:58.529Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"log": {
"_recordingName": "Events/Post an event returns \"Bad request\" response",
"creator": {
"comment": "persister:fs",
"name": "Polly.JS",
"version": "6.0.5"
},
"entries": [
{
"_id": "b35f8f8450dc70b83d7661b05817ff7e",
"_order": 0,
"cache": {},
"request": {
"bodySize": 867,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
},
{
"_fromType": "array",
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 592,
"httpVersion": "HTTP/1.1",
"method": "POST",
"postData": {
"mimeType": "application/json",
"params": [],
"text": "{\"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\":\"invalid\",\"integration_id\":\"custom-events\",\"message\":\"payment_processed feature flag has been enabled\",\"tags\":[\"env:api_client_test\"],\"title\":\"payment_processed feature flag updated\"},\"type\":\"event\"}}"
},
"queryString": [],
"url": "https://event-management-intake.datadoghq.com/api/v2/events"
},
"response": {
"bodySize": 163,
"content": {
"mimeType": "application/json",
"size": 163,
"text": "{\"errors\":[{\"status\":\"400\",\"title\":\"Bad Request\",\"detail\":\"JSON validation failed at $.data.attributes.category: value must be one of: [\\\"alert\\\", \\\"change\\\"].\"}]}"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 323,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 400,
"statusText": "Bad Request"
},
"startedDateTime": "2025-06-10T15:38:58.757Z",
"time": 189
}
],
"pages": [],
"version": "1.2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"2025-06-10T15:38:58.954Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"log": {
"_recordingName": "Events/Post an event returns \"OK\" response",
"creator": {
"comment": "persister:fs",
"name": "Polly.JS",
"version": "6.0.5"
},
"entries": [
{
"_id": "12f2ce8ce9b919c06a471c2b7d261fb3",
"_order": 0,
"cache": {},
"request": {
"bodySize": 866,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
},
{
"_fromType": "array",
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 592,
"httpVersion": "HTTP/1.1",
"method": "POST",
"postData": {
"mimeType": "application/json",
"params": [],
"text": "{\"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\",\"message\":\"payment_processed feature flag has been enabled\",\"tags\":[\"env:api_client_test\"],\"title\":\"payment_processed feature flag updated\"},\"type\":\"event\"}}"
},
"queryString": [],
"url": "https://event-management-intake.datadoghq.com/api/v2/events"
},
"response": {
"bodySize": 191,
"content": {
"mimeType": "application/json",
"size": 191,
"text": "{\"data\":{\"attributes\":{\"attributes\":{\"evt\":{\"uid\":\"AZdafqaTAACKG_iMQ82pmAAA\"}}},\"id\":\"_\",\"type\":\"event\"},\"links\":{\"self\":\"https://app.datadoghq.com/event/event?uid=AZdafqaTAACKG_iMQ82pmAAA\"}}"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 323,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 202,
"statusText": "Accepted"
},
"startedDateTime": "2025-06-10T15:38:58.956Z",
"time": 212
}
],
"pages": [],
"version": "1.2"
}
}
12 changes: 7 additions & 5 deletions features/v2/events.feature
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,21 @@ Feature: Events
Then the response status is 200 OK
And the response "data" has length 0

@generated @skip @team:DataDog/event-management
@team:DataDog/event-management
Scenario: Post an event returns "Bad request" response
Given new "CreateEvent" request
And body with value {"data": {"attributes": {"attributes": {"author": {"name": "datadog@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", "message": "payment_processed feature flag has been enabled", "tags": ["env:test"], "title": "payment_processed feature flag updated"}, "type": "event"}}
And body with value {"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": "invalid", "integration_id": "custom-events", "message": "payment_processed feature flag has been enabled", "tags": ["env:api_client_test"], "title": "payment_processed feature flag updated"}, "type": "event"}}
When the request is sent
Then the response status is 400 Bad request

@generated @skip @team:DataDog/event-management
@skip-validation @team:DataDog/event-management
Scenario: Post an event returns "OK" response
Given new "CreateEvent" request
And body with value {"data": {"attributes": {"attributes": {"author": {"name": "datadog@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", "message": "payment_processed feature flag has been enabled", "tags": ["env:test"], "title": "payment_processed feature flag updated"}, "type": "event"}}
And body with value {"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", "message": "payment_processed feature flag has been enabled", "tags": ["env:api_client_test"], "title": "payment_processed feature flag updated"}, "type": "event"}}
When the request is sent
Then the response status is 200 OK
Then the response status is 202 OK
And the response "data.type" is equal to "event"
And the response "data.attributes.attributes.evt" has field "uid"

@team:DataDog/event-management
Scenario: Search events returns "Bad Request" response
Expand Down
2 changes: 1 addition & 1 deletion features/v2/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@
"CreateEvent": {
"tag": "Events",
"undo": {
"type": "unsafe"
"type": "safe"
}
},
"SearchEvents": {
Expand Down
44 changes: 39 additions & 5 deletions services/events/src/v2/EventsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export class EventsApiResponseProcessor {
response: ResponseContext,
): Promise<EventCreateResponsePayload> {
const contentType = normalizeMediaType(response.headers["content-type"]);
if (response.httpStatusCode === 200) {
if (response.httpStatusCode === 202) {
const body: EventCreateResponsePayload = deserialize(
parse(await response.body.text(), contentType),
TypingInfo,
Expand Down Expand Up @@ -476,7 +476,37 @@ export class EventsApi {
private responseProcessor: EventsApiResponseProcessor;
private configuration: Configuration;

static operationServers: { [key: string]: BaseServerConfiguration[] } = {};
static operationServers: { [key: string]: BaseServerConfiguration[] } = {
"EventsApi.v2.createEvent": [
new ServerConfiguration<{
site:
| "datadoghq.com"
| "us3.datadoghq.com"
| "us5.datadoghq.com"
| "ap1.datadoghq.com"
| "datadoghq.eu"
| "ddog-gov.com";
subdomain: string;
}>("https://{subdomain}.{site}", {
site: "datadoghq.com",
subdomain: "event-management-intake",
}),
new ServerConfiguration<{
name: string;
protocol: string;
}>("{protocol}://{name}", {
name: "event-management-intake.datadoghq.com",
protocol: "https",
}),
new ServerConfiguration<{
site: string;
subdomain: string;
}>("https://{subdomain}.{site}", {
site: "datadoghq.com",
subdomain: "event-management-intake",
}),
],
};

public constructor(
configuration?: Configuration,
Expand All @@ -491,11 +521,15 @@ export class EventsApi {
}

/**
* This endpoint allows you to post events.
* This endpoint allows you to publish events.
*
* ✅ **Only events with the `change` or `alert` category** are in General Availability. For change events, see [Change Tracking](https://docs.datadoghq.com/change_tracking) for more details.
*
* ❌ For use cases involving other event categories, use the V1 endpoint or reach out to [support](https://www.datadoghq.com/support/).
*
* ✅ **Only events with the `change` category** are in General Availability. See [Change Tracking](https://docs.datadoghq.com/change_tracking) for more details.
* ❌ Notifications are not yet supported for events sent to this endpoint. Use the V1 endpoint for notification functionality.
*
* ❌ For use cases involving other event categories, please use the V1 endpoint.
* ❌ This endpoint is not available for the Government (US1-FED) site. Contact your account representative for more information.
* @param param The request object
*/
public createEvent(
Expand Down
7 changes: 7 additions & 0 deletions services/events/src/v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ export {
EventsApi,
} from "./EventsApi";

export { AlertEventCustomAttributes } from "./models/AlertEventCustomAttributes";
export { AlertEventCustomAttributesLinksItems } from "./models/AlertEventCustomAttributesLinksItems";
export { AlertEventCustomAttributesLinksItemsCategory } from "./models/AlertEventCustomAttributesLinksItemsCategory";
export { AlertEventCustomAttributesPriority } from "./models/AlertEventCustomAttributesPriority";
export { AlertEventCustomAttributesStatus } from "./models/AlertEventCustomAttributesStatus";
export { APIErrorResponse } from "./models/APIErrorResponse";
export { ChangeEventCustomAttributes } from "./models/ChangeEventCustomAttributes";
export { ChangeEventCustomAttributesAuthor } from "./models/ChangeEventCustomAttributesAuthor";
Expand All @@ -24,8 +29,10 @@ export { EventCreateResponseAttributes } from "./models/EventCreateResponseAttri
export { EventCreateResponseAttributesAttributes } from "./models/EventCreateResponseAttributesAttributes";
export { EventCreateResponseAttributesAttributesEvt } from "./models/EventCreateResponseAttributesAttributesEvt";
export { EventCreateResponsePayload } from "./models/EventCreateResponsePayload";
export { EventCreateResponsePayloadLinks } from "./models/EventCreateResponsePayloadLinks";
export { EventPayload } from "./models/EventPayload";
export { EventPayloadAttributes } from "./models/EventPayloadAttributes";
export { EventPayloadIntegrationId } from "./models/EventPayloadIntegrationId";
export { EventPriority } from "./models/EventPriority";
export { EventResponse } from "./models/EventResponse";
export { EventResponseAttributes } from "./models/EventResponseAttributes";
Expand Down
63 changes: 63 additions & 0 deletions services/events/src/v2/models/AlertEventCustomAttributes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { AttributeTypeMap } from "@datadog/datadog-api-client";

import { AlertEventCustomAttributesLinksItems } from "./AlertEventCustomAttributesLinksItems";
import { AlertEventCustomAttributesPriority } from "./AlertEventCustomAttributesPriority";
import { AlertEventCustomAttributesStatus } from "./AlertEventCustomAttributesStatus";

/**
* Alert event attributes.
*/
export class AlertEventCustomAttributes {
/**
* Free form JSON object for arbitrary data. Supports up to 100 properties per object and a maximum nesting depth of 10 levels.
*/
"custom"?: { [key: string]: any };
/**
* The links related to the event. Maximum of 20 links allowed.
*/
"links"?: Array<AlertEventCustomAttributesLinksItems>;
/**
* The priority of the alert.
*/
"priority"?: AlertEventCustomAttributesPriority;
/**
* The status of the alert.
*/
"status": AlertEventCustomAttributesStatus;
/**
* @ignore
*/
"_unparsed"?: boolean;

/**
* @ignore
*/
static readonly attributeTypeMap: AttributeTypeMap = {
custom: {
baseName: "custom",
type: "{ [key: string]: any; }",
},
links: {
baseName: "links",
type: "Array<AlertEventCustomAttributesLinksItems>",
},
priority: {
baseName: "priority",
type: "AlertEventCustomAttributesPriority",
},
status: {
baseName: "status",
type: "AlertEventCustomAttributesStatus",
required: true,
},
};

/**
* @ignore
*/
static getAttributeTypeMap(): AttributeTypeMap {
return AlertEventCustomAttributes.attributeTypeMap;
}

public constructor() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { AttributeTypeMap } from "@datadog/datadog-api-client";

import { AlertEventCustomAttributesLinksItemsCategory } from "./AlertEventCustomAttributesLinksItemsCategory";

/**
* A link.
*/
export class AlertEventCustomAttributesLinksItems {
/**
* The category of the link.
*/
"category": AlertEventCustomAttributesLinksItemsCategory;
/**
* The display text of the link. Limited to 300 characters.
*/
"title"?: string;
/**
* The URL of the link. Limited to 2048 characters.
*/
"url": string;
/**
* @ignore
*/
"_unparsed"?: boolean;

/**
* @ignore
*/
static readonly attributeTypeMap: AttributeTypeMap = {
category: {
baseName: "category",
type: "AlertEventCustomAttributesLinksItemsCategory",
required: true,
},
title: {
baseName: "title",
type: "string",
},
url: {
baseName: "url",
type: "string",
required: true,
},
};

/**
* @ignore
*/
static getAttributeTypeMap(): AttributeTypeMap {
return AlertEventCustomAttributesLinksItems.attributeTypeMap;
}

public constructor() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { UnparsedObject } from "@datadog/datadog-api-client";

/**
* The category of the link.
*/
export type AlertEventCustomAttributesLinksItemsCategory =
| typeof RUNBOOK
| typeof DOCUMENTATION
| typeof DASHBOARD
| UnparsedObject;
export const RUNBOOK = "runbook";
export const DOCUMENTATION = "documentation";
export const DASHBOARD = "dashboard";
Loading