Create a Salesforce incident template

POST https://api.ap1.datadoghq.com/api/v2/integration/salesforce-incidents/incident-templateshttps://api.ap2.datadoghq.com/api/v2/integration/salesforce-incidents/incident-templateshttps://api.datadoghq.eu/api/v2/integration/salesforce-incidents/incident-templateshttps://api.ddog-gov.com/api/v2/integration/salesforce-incidents/incident-templateshttps://api.us2.ddog-gov.com/api/v2/integration/salesforce-incidents/incident-templateshttps://api.uk1.datadoghq.com/api/v2/integration/salesforce-incidents/incident-templateshttps://api.datadoghq.com/api/v2/integration/salesforce-incidents/incident-templateshttps://api.us3.datadoghq.com/api/v2/integration/salesforce-incidents/incident-templateshttps://api.us5.datadoghq.com/api/v2/integration/salesforce-incidents/incident-templates

概要

Create a new Salesforce incident template for your organization. Template names must be unique within an organization. This endpoint requires the manage_integrations permission.

リクエスト

Body Data (required)

Salesforce incident template payload.

Expand All

フィールド

タイプ

説明

data [required]

object

Salesforce incident template data for a create request.

attributes [required]

object

Salesforce incident template attributes for a create request.

description [required]

string

Long-form description body for Salesforce incidents created from this template.

name [required]

string

Human-readable name for this incident template. Must be unique within your organization.

owner_id [required]

string

The Salesforce user ID that owns incidents created from this template.

priority [required]

enum

Priority of the Salesforce incident created from this template. Allowed enum values: Critical,High,Moderate,Low

salesforce_org_id [required]

uuid

The Datadog-assigned ID of the Salesforce organization this template belongs to.

subject [required]

string

Subject line for Salesforce incidents created from this template.

type [required]

enum

Salesforce incident template resource type. Allowed enum values: salesforce-incidents-incident-template

default: salesforce-incidents-incident-template

{
  "data": {
    "attributes": {
      "description": "An incident was detected by Datadog monitors.",
      "name": "production-outage",
      "owner_id": "005000000000000",
      "priority": "High",
      "salesforce_org_id": "596da4af-0563-4097-90ff-07230c3f9db3",
      "subject": "Datadog Incident: Production Outage"
    },
    "type": "salesforce-incidents-incident-template"
  }
}

応答

CREATED

Response containing a Salesforce incident template.

Expand All

フィールド

タイプ

説明

data [required]

object

Salesforce incident template data from a response.

attributes [required]

object

Salesforce incident template attributes returned by the API.

description

string

Long-form description body for Salesforce incidents created from this template.

name

string

Human-readable name for this incident template.

owner_id

string

The Salesforce user ID that owns incidents created from this template.

priority

enum

Priority of the Salesforce incident created from this template. Allowed enum values: Critical,High,Moderate,Low

salesforce_org_id

uuid

The Datadog-assigned ID of the Salesforce organization this template belongs to.

subject

string

Subject line for Salesforce incidents created from this template.

id [required]

string

The ID of the Salesforce incident template.

type [required]

enum

Salesforce incident template resource type. Allowed enum values: salesforce-incidents-incident-template

default: salesforce-incidents-incident-template

{
  "data": {
    "attributes": {
      "description": "An incident was detected by Datadog monitors.",
      "name": "production-outage",
      "owner_id": "005000000000000",
      "priority": "High",
      "salesforce_org_id": "596da4af-0563-4097-90ff-07230c3f9db3",
      "subject": "Datadog Incident: Production Outage"
    },
    "id": "596da4af-0563-4097-90ff-07230c3f9db3",
    "type": "salesforce-incidents-incident-template"
  }
}

Bad Request

API error response.

Expand All

フィールド

タイプ

説明

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

API error response.

Expand All

フィールド

タイプ

説明

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Not Found

API error response.

Expand All

フィールド

タイプ

説明

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Conflict

API error response.

Expand All

フィールド

タイプ

説明

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

API error response.

Expand All

フィールド

タイプ

説明

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

コード例

                  ## default
# 

# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

# Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.uk1.datadoghq.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/integration/salesforce-incidents/incident-templates" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${DD_BEARER_TOKEN}" \ -d @- << EOF { "data": { "attributes": { "description": "An incident was detected by Datadog monitors.", "name": "production-outage", "owner_id": "005000000000000", "priority": "High", "salesforce_org_id": "596da4af-0563-4097-90ff-07230c3f9db3", "subject": "Datadog Incident: Production Outage" }, "type": "salesforce-incidents-incident-template" } } EOF
"""
Create a Salesforce incident template returns "CREATED" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.salesforce_integration_api import SalesforceIntegrationApi
from datadog_api_client.v2.model.salesforce_incidents_template_create_attributes import (
    SalesforceIncidentsTemplateCreateAttributes,
)
from datadog_api_client.v2.model.salesforce_incidents_template_create_data import SalesforceIncidentsTemplateCreateData
from datadog_api_client.v2.model.salesforce_incidents_template_create_request import (
    SalesforceIncidentsTemplateCreateRequest,
)
from datadog_api_client.v2.model.salesforce_incidents_template_priority import SalesforceIncidentsTemplatePriority
from datadog_api_client.v2.model.salesforce_incidents_template_type import SalesforceIncidentsTemplateType
from uuid import UUID

body = SalesforceIncidentsTemplateCreateRequest(
    data=SalesforceIncidentsTemplateCreateData(
        attributes=SalesforceIncidentsTemplateCreateAttributes(
            description="An incident was detected by Datadog monitors.",
            name="production-outage",
            owner_id="005000000000000",
            priority=SalesforceIncidentsTemplatePriority.HIGH,
            salesforce_org_id=UUID("596da4af-0563-4097-90ff-07230c3f9db3"),
            subject="Datadog Incident: Production Outage",
        ),
        type=SalesforceIncidentsTemplateType.SALESFORCE_INCIDENTS_INCIDENT_TEMPLATE,
    ),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
    api_instance = SalesforceIntegrationApi(api_client)
    response = api_instance.create_incident_template(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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"
# Create a Salesforce incident template returns "CREATED" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::SalesforceIntegrationAPI.new

body = DatadogAPIClient::V2::SalesforceIncidentsTemplateCreateRequest.new({
  data: DatadogAPIClient::V2::SalesforceIncidentsTemplateCreateData.new({
    attributes: DatadogAPIClient::V2::SalesforceIncidentsTemplateCreateAttributes.new({
      description: "An incident was detected by Datadog monitors.",
      name: "production-outage",
      owner_id: "005000000000000",
      priority: DatadogAPIClient::V2::SalesforceIncidentsTemplatePriority::HIGH,
      salesforce_org_id: "596da4af-0563-4097-90ff-07230c3f9db3",
      subject: "Datadog Incident: Production Outage",
    }),
    type: DatadogAPIClient::V2::SalesforceIncidentsTemplateType::SALESFORCE_INCIDENTS_INCIDENT_TEMPLATE,
  }),
})
p api_instance.create_incident_template(body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"
// Create a Salesforce incident template returns "CREATED" 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"
	"github.com/google/uuid"
)

func main() {
	body := datadogV2.SalesforceIncidentsTemplateCreateRequest{
		Data: datadogV2.SalesforceIncidentsTemplateCreateData{
			Attributes: datadogV2.SalesforceIncidentsTemplateCreateAttributes{
				Description:     "An incident was detected by Datadog monitors.",
				Name:            "production-outage",
				OwnerId:         "005000000000000",
				Priority:        datadogV2.SALESFORCEINCIDENTSTEMPLATEPRIORITY_HIGH,
				SalesforceOrgId: uuid.MustParse("596da4af-0563-4097-90ff-07230c3f9db3"),
				Subject:         "Datadog Incident: Production Outage",
			},
			Type: datadogV2.SALESFORCEINCIDENTSTEMPLATETYPE_SALESFORCE_INCIDENTS_INCIDENT_TEMPLATE,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewSalesforceIntegrationApi(apiClient)
	resp, r, err := api.CreateIncidentTemplate(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `SalesforceIntegrationApi.CreateIncidentTemplate`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `SalesforceIntegrationApi.CreateIncidentTemplate`:\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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"
// Create a Salesforce incident template returns "CREATED" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.SalesforceIntegrationApi;
import com.datadog.api.client.v2.model.SalesforceIncidentsTemplateCreateAttributes;
import com.datadog.api.client.v2.model.SalesforceIncidentsTemplateCreateData;
import com.datadog.api.client.v2.model.SalesforceIncidentsTemplateCreateRequest;
import com.datadog.api.client.v2.model.SalesforceIncidentsTemplatePriority;
import com.datadog.api.client.v2.model.SalesforceIncidentsTemplateResponse;
import com.datadog.api.client.v2.model.SalesforceIncidentsTemplateType;
import java.util.UUID;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
    SalesforceIntegrationApi apiInstance = new SalesforceIntegrationApi(defaultClient);

    SalesforceIncidentsTemplateCreateRequest body =
        new SalesforceIncidentsTemplateCreateRequest()
            .data(
                new SalesforceIncidentsTemplateCreateData()
                    .attributes(
                        new SalesforceIncidentsTemplateCreateAttributes()
                            .description("An incident was detected by Datadog monitors.")
                            .name("production-outage")
                            .ownerId("005000000000000")
                            .priority(SalesforceIncidentsTemplatePriority.HIGH)
                            .salesforceOrgId(
                                UUID.fromString("596da4af-0563-4097-90ff-07230c3f9db3"))
                            .subject("Datadog Incident: Production Outage"))
                    .type(SalesforceIncidentsTemplateType.SALESFORCE_INCIDENTS_INCIDENT_TEMPLATE));

    try {
      SalesforceIncidentsTemplateResponse result = apiInstance.createIncidentTemplate(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling SalesforceIntegrationApi#createIncidentTemplate");
      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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"
// Create a Salesforce incident template returns "CREATED" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_salesforce_integration::SalesforceIntegrationAPI;
use datadog_api_client::datadogV2::model::SalesforceIncidentsTemplateCreateAttributes;
use datadog_api_client::datadogV2::model::SalesforceIncidentsTemplateCreateData;
use datadog_api_client::datadogV2::model::SalesforceIncidentsTemplateCreateRequest;
use datadog_api_client::datadogV2::model::SalesforceIncidentsTemplatePriority;
use datadog_api_client::datadogV2::model::SalesforceIncidentsTemplateType;
use uuid::Uuid;

#[tokio::main]
async fn main() {
    let body =
        SalesforceIncidentsTemplateCreateRequest::new(SalesforceIncidentsTemplateCreateData::new(
            SalesforceIncidentsTemplateCreateAttributes::new(
                "An incident was detected by Datadog monitors.".to_string(),
                "production-outage".to_string(),
                "005000000000000".to_string(),
                SalesforceIncidentsTemplatePriority::HIGH,
                Uuid::parse_str("596da4af-0563-4097-90ff-07230c3f9db3").expect("invalid UUID"),
                "Datadog Incident: Production Outage".to_string(),
            ),
            SalesforceIncidentsTemplateType::SALESFORCE_INCIDENTS_INCIDENT_TEMPLATE,
        ));
    let configuration = datadog::Configuration::new();
    let api = SalesforceIntegrationAPI::with_config(configuration);
    let resp = api.create_incident_template(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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
/**
 * Create a Salesforce incident template returns "CREATED" 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.SalesforceIntegrationApi(configuration);

const params: v2.SalesforceIntegrationApiCreateIncidentTemplateRequest = {
  body: {
    data: {
      attributes: {
        description: "An incident was detected by Datadog monitors.",
        name: "production-outage",
        ownerId: "005000000000000",
        priority: "High",
        salesforceOrgId: "596da4af-0563-4097-90ff-07230c3f9db3",
        subject: "Datadog Incident: Production Outage",
      },
      type: "salesforce-incidents-incident-template",
    },
  },
};

apiInstance
  .createIncidentTemplate(params)
  .then((data: v2.SalesforceIncidentsTemplateResponse) => {
    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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"