---
title: Update an incident user-defined role
description: Update an existing user-defined role for incidents.
breadcrumbs: Docs > API > Update an incident user-defined role
---

> For the complete documentation index, see [llms.txt](https://dnd37xeb23o8n.cloudfront.net/stefon.simmons/docs-astro-web-10435/llms.txt).

# Update an incident user-defined role

## v2 (latest)

{% alert level="warning" %}
**Note**: This endpoint is in preview and is subject to change.
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help.md).
{% /alert %}

| Datadog site      | API endpoint                                                                             |
| ----------------- | ---------------------------------------------------------------------------------------- |
| app.datadoghq.com | PATCH https://api.datadoghq.com/api/v2/incidents/config/user-defined-roles/{role_id}     |
| us3.datadoghq.com | PATCH https://api.us3.datadoghq.com/api/v2/incidents/config/user-defined-roles/{role_id} |
| us5.datadoghq.com | PATCH https://api.us5.datadoghq.com/api/v2/incidents/config/user-defined-roles/{role_id} |
| app.datadoghq.eu  | PATCH https://api.datadoghq.eu/api/v2/incidents/config/user-defined-roles/{role_id}      |
| ap1.datadoghq.com | PATCH https://api.ap1.datadoghq.com/api/v2/incidents/config/user-defined-roles/{role_id} |
| ap2.datadoghq.com | PATCH https://api.ap2.datadoghq.com/api/v2/incidents/config/user-defined-roles/{role_id} |
| uk1.datadoghq.com | PATCH https://api.uk1.datadoghq.com/api/v2/incidents/config/user-defined-roles/{role_id} |
| app.ddog-gov.com  | PATCH https://api.ddog-gov.com/api/v2/incidents/config/user-defined-roles/{role_id}      |
| us2.ddog-gov.com  | PATCH https://api.us2.ddog-gov.com/api/v2/incidents/config/user-defined-roles/{role_id}  |

### Overview

Update an existing user-defined role for incidents.

OAuth apps require the `incident_settings_write` authorization [scope](https://dnd37xeb23o8n.cloudfront.net/stefon.simmons/docs-astro-web-10435/api/latest/scopes.md#incidents) to access this endpoint.

### Arguments

#### Path Parameters

| Field                | Type   | Description                                 |
| -------------------- | ------ | ------------------------------------------- |
| role_id [*required*] | string | The UUID of the incident user-defined role. |

#### Query Strings

| Field   | Type   | Description                                                           |
| ------- | ------ | --------------------------------------------------------------------- |
| include | string | Comma-separated list of related resources to include in the response. |

### Request

#### Body Data (required)

{% tabs %}
{% tab label="Model" %}
| Parent field | Field                  | Type    | Description                                                                                   |
| ------------ | ---------------------- | ------- | --------------------------------------------------------------------------------------------- |
|              | data [*required*]      | object  | Data for updating an incident user-defined role.                                              |
| data         | attributes             | object  | Attributes for updating an incident user-defined role.                                        |
| attributes   | description            | string  | A description of the user-defined role.                                                       |
| attributes   | name                   | string  | The name of the user-defined role.                                                            |
| attributes   | policy                 | object  | Policy configuration for a user-defined role.                                                 |
| policy       | is_single [*required*] | boolean | Whether this role can only be assigned to one responder at a time.                            |
| data         | id [*required*]        | uuid    | The ID of the user-defined role to update.                                                    |
| data         | type [*required*]      | enum    | Incident user-defined role resource type. Allowed enum values: `incident_user_defined_roles`. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "attributes": {
      "description": "The technical lead for the incident.",
      "name": "Tech Lead",
      "policy": {
        "is_single": true
      }
    },
    "id": "00000000-0000-0000-0000-000000000002",
    "type": "incident_user_defined_roles"
  }
}
```
{% /tab %}
{% /tabs %}

### Response

{% tabs %}
{% tab label="200" %}
OK

{% tabs %}
{% tab label="Model" %}
Response with a single incident user-defined role.

| Parent field                  | Field                         | Type      | Description                                                                                                                                                                                                                                                           |
| ----------------------------- | ----------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|                               | data [*required*]             | object    | Data for an incident user-defined role response.                                                                                                                                                                                                                      |
| data                          | attributes [*required*]       | object    | Attributes of an incident user-defined role.                                                                                                                                                                                                                          |
| attributes                    | created [*required*]          | date-time | Timestamp when the role was created.                                                                                                                                                                                                                                  |
| attributes                    | description                   | string    | A description of the user-defined role.                                                                                                                                                                                                                               |
| attributes                    | modified [*required*]         | date-time | Timestamp when the role was last modified.                                                                                                                                                                                                                            |
| attributes                    | name [*required*]             | string    | The name of the user-defined role.                                                                                                                                                                                                                                    |
| attributes                    | policy [*required*]           | object    | Policy configuration for a user-defined role.                                                                                                                                                                                                                         |
| policy                        | is_single [*required*]        | boolean   | Whether this role can only be assigned to one responder at a time.                                                                                                                                                                                                    |
| data                          | id [*required*]               | uuid      | The ID of the user-defined role.                                                                                                                                                                                                                                      |
| data                          | relationships                 | object    | Relationships of a user-defined role response.                                                                                                                                                                                                                        |
| relationships                 | created_by_user               | object    | Relationship to user.                                                                                                                                                                                                                                                 |
| created_by_user               | data [*required*]             | object    | Relationship to user object.                                                                                                                                                                                                                                          |
| data                          | id [*required*]               | string    | A unique identifier that represents the user.                                                                                                                                                                                                                         |
| data                          | type [*required*]             | enum      | Users resource type. Allowed enum values: `users`. Default: `users`.                                                                                                                                                                                                  |
| relationships                 | incident_type                 | object    | Relationship to an incident type for a user-defined role.                                                                                                                                                                                                             |
| incident_type                 | data [*required*]             | object    | Data for the incident type relationship of a user-defined role.                                                                                                                                                                                                       |
| data                          | id [*required*]               | uuid      | The ID of the incident type.                                                                                                                                                                                                                                          |
| data                          | type [*required*]             | string    | The type of the resource.                                                                                                                                                                                                                                             |
| relationships                 | last_modified_by_user         | object    | Relationship to user.                                                                                                                                                                                                                                                 |
| last_modified_by_user         | data [*required*]             | object    | Relationship to user object.                                                                                                                                                                                                                                          |
| data                          | id [*required*]               | string    | A unique identifier that represents the user.                                                                                                                                                                                                                         |
| data                          | type [*required*]             | enum      | Users resource type. Allowed enum values: `users`. Default: `users`.                                                                                                                                                                                                  |
| data                          | type [*required*]             | enum      | Incident user-defined role resource type. Allowed enum values: `incident_user_defined_roles`.                                                                                                                                                                         |
|                               | included                      | [<oneOf>] | Included resources for an incident user-defined role response.                                                                                                                                                                                                        |
| included                      | <type=users>                  | object    | User object returned by the API.                                                                                                                                                                                                                                      |
| <type=users>                  | attributes                    | object    | Attributes of user object returned by the API.                                                                                                                                                                                                                        |
| attributes                    | email                         | string    | Email of the user.                                                                                                                                                                                                                                                    |
| attributes                    | handle                        | string    | Handle of the user.                                                                                                                                                                                                                                                   |
| attributes                    | icon                          | string    | URL of the user's icon.                                                                                                                                                                                                                                               |
| attributes                    | name                          | string    | Name of the user.                                                                                                                                                                                                                                                     |
| attributes                    | uuid                          | string    | UUID of the user.                                                                                                                                                                                                                                                     |
| <type=users>                  | id                            | string    | ID of the user.                                                                                                                                                                                                                                                       |
| <type=users>                  | type                          | enum      | Users resource type. Allowed enum values: `users`. Default: `users`.                                                                                                                                                                                                  |
| included                      | <type=incident_types>         | object    | Incident type response data.                                                                                                                                                                                                                                          |
| <type=incident_types>         | attributes                    | object    | Incident type's attributes.                                                                                                                                                                                                                                           |
| attributes                    | configuration                 | object    | The incident-type-scoped behavior settings. All fields are optional on update. Any field omitted from a PATCH request keeps its current value. This object is read-only on the incident type resource itself and is only mutated through the update (PATCH) endpoint. |
| configuration                 | allow_incident_deletion       | boolean   | Whether incidents of this type can be deleted. Default: `false`.                                                                                                                                                                                                      |
| configuration                 | allow_workflows               | boolean   | Whether automation workflows can be triggered for incidents of this type. Default: `true`.                                                                                                                                                                            |
| configuration                 | create_message                | string    | An optional message shown to users when they declare an incident of this type.                                                                                                                                                                                        |
| configuration                 | editable_timestamps           | boolean   | Whether responders can edit incident timestamps for incidents of this type. Default: `false`.                                                                                                                                                                         |
| configuration                 | private_incidents             | boolean   | Whether responders can create private incidents of this type. This is an opt-in setting, distinct from `private_incidents_by_default`, which controls whether incidents are created private automatically. Default: `false`.                                          |
| configuration                 | private_incidents_by_default  | boolean   | Whether incidents of this type are created as private by default. Default: `false`.                                                                                                                                                                                   |
| configuration                 | slug_source                   | enum      | When set to `servicenow`, incidents will display the ServiceNow record ID instead of the public ID. If no ServiceNow integration exists, the public ID will be displayed. Allowed enum values: `default`, `servicenow`. Default: `default`.                           |
| configuration                 | test_incidents                | boolean   | Whether incidents of this type are treated as test incidents. Default: `true`.                                                                                                                                                                                        |
| attributes                    | createdAt                     | date-time | Timestamp when the incident type was created. Read-only.                                                                                                                                                                                                              |
| attributes                    | createdBy                     | string    | A unique identifier that represents the user that created the incident type. Read-only.                                                                                                                                                                               |
| attributes                    | description                   | string    | Text that describes the incident type.                                                                                                                                                                                                                                |
| attributes                    | is_default                    | boolean   | If true, this incident type will be used as the default incident type if a type is not specified during the creation of incident resources. Default: `false`.                                                                                                         |
| attributes                    | lastModifiedBy                | string    | A unique identifier that represents the user that last modified the incident type. Read-only.                                                                                                                                                                         |
| attributes                    | modifiedAt                    | date-time | Timestamp when the incident type was last modified. Read-only.                                                                                                                                                                                                        |
| attributes                    | name [*required*]             | string    | The name of the incident type.                                                                                                                                                                                                                                        |
| attributes                    | prefix                        | string    | The string that will be prepended to the incident title across the Datadog app. Read-only.                                                                                                                                                                            |
| <type=incident_types>         | id [*required*]               | string    | The incident type's ID.                                                                                                                                                                                                                                               |
| <type=incident_types>         | relationships                 | object    | The incident type's resource relationships.                                                                                                                                                                                                                           |
| relationships                 | created_by_user               | object    | Relationship to user.                                                                                                                                                                                                                                                 |
| created_by_user               | data [*required*]             | object    | Relationship to user object.                                                                                                                                                                                                                                          |
| data                          | id [*required*]               | string    | A unique identifier that represents the user.                                                                                                                                                                                                                         |
| data                          | type [*required*]             | enum      | Users resource type. Allowed enum values: `users`. Default: `users`.                                                                                                                                                                                                  |
| relationships                 | google_meet_configuration     | object    | A reference to a Google Meet Configuration resource.                                                                                                                                                                                                                  |
| google_meet_configuration     | data [*required*]             | object    | The Google Meet configuration relationship data object.                                                                                                                                                                                                               |
| data                          | id [*required*]               | string    | The unique identifier of the Google Meet configuration.                                                                                                                                                                                                               |
| data                          | type [*required*]             | string    | The type of the Google Meet configuration.                                                                                                                                                                                                                            |
| relationships                 | last_modified_by_user         | object    | Relationship to user.                                                                                                                                                                                                                                                 |
| last_modified_by_user         | data [*required*]             | object    | Relationship to user object.                                                                                                                                                                                                                                          |
| data                          | id [*required*]               | string    | A unique identifier that represents the user.                                                                                                                                                                                                                         |
| data                          | type [*required*]             | enum      | Users resource type. Allowed enum values: `users`. Default: `users`.                                                                                                                                                                                                  |
| relationships                 | microsoft_teams_configuration | object    | A reference to a Microsoft Teams Configuration resource.                                                                                                                                                                                                              |
| microsoft_teams_configuration | data [*required*]             | object    | The Microsoft Teams configuration relationship data object.                                                                                                                                                                                                           |
| data                          | id [*required*]               | string    | The unique identifier of the Microsoft Teams configuration.                                                                                                                                                                                                           |
| data                          | type [*required*]             | string    | The type of the Microsoft Teams configuration.                                                                                                                                                                                                                        |
| relationships                 | zoom_configuration            | object    | A reference to a Zoom configuration resource.                                                                                                                                                                                                                         |
| zoom_configuration            | data [*required*]             | object    | The Zoom configuration relationship data object.                                                                                                                                                                                                                      |
| data                          | id [*required*]               | string    | The unique identifier of the Zoom configuration.                                                                                                                                                                                                                      |
| data                          | type [*required*]             | string    | The type of the Zoom configuration.                                                                                                                                                                                                                                   |
| <type=incident_types>         | type [*required*]             | enum      | Incident type resource type. Allowed enum values: `incident_types`. Default: `incident_types`.                                                                                                                                                                        |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "attributes": {
      "created": "2024-01-01T00:00:00.000Z",
      "description": "The technical lead for the incident.",
      "modified": "2024-01-01T00:00:00.000Z",
      "name": "Tech Lead",
      "policy": {
        "is_single": true
      }
    },
    "id": "00000000-0000-0000-0000-000000000002",
    "relationships": {
      "created_by_user": {
        "data": {
          "id": "00000000-0000-0000-2345-000000000000",
          "type": "users"
        }
      },
      "incident_type": {
        "data": {
          "id": "00000000-0000-0000-0000-000000000001",
          "type": "incident_types"
        }
      },
      "last_modified_by_user": {
        "data": {
          "id": "00000000-0000-0000-2345-000000000000",
          "type": "users"
        }
      }
    },
    "type": "incident_user_defined_roles"
  },
  "included": [
    {
      "attributes": {
        "email": "string",
        "handle": "string",
        "icon": "string",
        "name": "string",
        "uuid": "string"
      },
      "id": "string",
      "type": "users"
    }
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="400" %}
Bad Request

{% tabs %}
{% tab label="Model" %}
API error response.

| Parent field | Field               | Type     | Description                                                                     |
| ------------ | ------------------- | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail              | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                | object   | Non-standard meta-information about the error                                   |
| errors       | source              | object   | References to the source of the error.                                          |
| source       | header              | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter           | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer             | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status              | string   | Status code of the response.                                                    |
| errors       | title               | string   | Short human-readable summary of the error.                                      |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="404" %}
Not Found

{% tabs %}
{% tab label="Model" %}
API error response.

| Parent field | Field               | Type     | Description                                                                     |
| ------------ | ------------------- | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail              | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                | object   | Non-standard meta-information about the error                                   |
| errors       | source              | object   | References to the source of the error.                                          |
| source       | header              | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter           | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer             | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status              | string   | Status code of the response.                                                    |
| errors       | title               | string   | Short human-readable summary of the error.                                      |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="429" %}
Too many requests

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}
{% /tabs %}

### Code Example

{% tabs %}
{% tab label="Curl" %}
```bash
# Path parameters
export role_id="00000000-0000-0000-0000-000000000002"

# Set your Datadog site and credentials
export DD_SITE="datadoghq.com" # Or us3.datadoghq.com, us5.datadoghq.com, datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com, ddog-gov.com, us2.ddog-gov.com
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X PATCH "https://api.${DD_SITE}/api/v2/incidents/config/user-defined-roles/${role_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Updated Tech Lead"
    },
    "id": "00000000-0000-0000-0000-000000000002",
    "type": "incident_user_defined_roles"
  }
}
EOF
```
{% /tab %}

{% tab label="Go" %}
```go
// Update an incident user-defined role 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"
	"github.com/google/uuid"
)

func main() {
	body := datadogV2.IncidentUserDefinedRolePatchRequest{
		Data: datadogV2.IncidentUserDefinedRolePatchDataRequest{
			Attributes: &datadogV2.IncidentUserDefinedRolePatchDataAttributesRequest{
				Description: *datadog.NewNullableString(datadog.PtrString("The technical lead for the incident.")),
				Name:        datadog.PtrString("Tech Lead"),
				Policy: &datadogV2.IncidentUserDefinedRolePolicy{
					IsSingle: true,
				},
			},
			Id:   uuid.MustParse("00000000-0000-0000-0000-000000000002"),
			Type: datadogV2.INCIDENTUSERDEFINEDROLETYPE_INCIDENT_USER_DEFINED_ROLES,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.UpdateIncidentUserDefinedRole", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewIncidentsApi(apiClient)
	resp, r, err := api.UpdateIncidentUserDefinedRole(ctx, uuid.MustParse("00000000-0000-0000-0000-000000000002"), body, *datadogV2.NewUpdateIncidentUserDefinedRoleOptionalParameters())

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.UpdateIncidentUserDefinedRole`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"
```
{% /tab %}

{% tab label="Java" %}
```java
// Update an incident user-defined role returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.IncidentsApi;
import com.datadog.api.client.v2.model.IncidentUserDefinedRolePatchDataAttributesRequest;
import com.datadog.api.client.v2.model.IncidentUserDefinedRolePatchDataRequest;
import com.datadog.api.client.v2.model.IncidentUserDefinedRolePatchRequest;
import com.datadog.api.client.v2.model.IncidentUserDefinedRolePolicy;
import com.datadog.api.client.v2.model.IncidentUserDefinedRoleResponse;
import com.datadog.api.client.v2.model.IncidentUserDefinedRoleType;
import java.util.UUID;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
    defaultClient.setUnstableOperationEnabled("v2.updateIncidentUserDefinedRole", true);
    IncidentsApi apiInstance = new IncidentsApi(defaultClient);

    IncidentUserDefinedRolePatchRequest body =
        new IncidentUserDefinedRolePatchRequest()
            .data(
                new IncidentUserDefinedRolePatchDataRequest()
                    .attributes(
                        new IncidentUserDefinedRolePatchDataAttributesRequest()
                            .description("The technical lead for the incident.")
                            .name("Tech Lead")
                            .policy(new IncidentUserDefinedRolePolicy().isSingle(true)))
                    .id(UUID.fromString("00000000-0000-0000-0000-000000000002"))
                    .type(IncidentUserDefinedRoleType.INCIDENT_USER_DEFINED_ROLES));

    try {
      IncidentUserDefinedRoleResponse result =
          apiInstance.updateIncidentUserDefinedRole(
              UUID.fromString("00000000-0000-0000-0000-000000000002"), body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling IncidentsApi#updateIncidentUserDefinedRole");
      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](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"
```
{% /tab %}

{% tab label="Python" %}
```python
"""
Update an incident user-defined role returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.incidents_api import IncidentsApi
from datadog_api_client.v2.model.incident_user_defined_role_patch_data_attributes_request import (
    IncidentUserDefinedRolePatchDataAttributesRequest,
)
from datadog_api_client.v2.model.incident_user_defined_role_patch_data_request import (
    IncidentUserDefinedRolePatchDataRequest,
)
from datadog_api_client.v2.model.incident_user_defined_role_patch_request import IncidentUserDefinedRolePatchRequest
from datadog_api_client.v2.model.incident_user_defined_role_policy import IncidentUserDefinedRolePolicy
from datadog_api_client.v2.model.incident_user_defined_role_type import IncidentUserDefinedRoleType
from uuid import UUID

body = IncidentUserDefinedRolePatchRequest(
    data=IncidentUserDefinedRolePatchDataRequest(
        attributes=IncidentUserDefinedRolePatchDataAttributesRequest(
            description="The technical lead for the incident.",
            name="Tech Lead",
            policy=IncidentUserDefinedRolePolicy(
                is_single=True,
            ),
        ),
        id=UUID("00000000-0000-0000-0000-000000000002"),
        type=IncidentUserDefinedRoleType.INCIDENT_USER_DEFINED_ROLES,
    ),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["update_incident_user_defined_role"] = True
with ApiClient(configuration) as api_client:
    api_instance = IncidentsApi(api_client)
    response = api_instance.update_incident_user_defined_role(
        role_id=UUID("00000000-0000-0000-0000-000000000002"), body=body
    )

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"
```
{% /tab %}

{% tab label="Ruby" %}
```ruby
# Update an incident user-defined role returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.access_token = ENV["DD_BEARER_TOKEN"]
  config.unstable_operations["v2.update_incident_user_defined_role".to_sym] = true
end
api_instance = DatadogAPIClient::V2::IncidentsAPI.new

body = DatadogAPIClient::V2::IncidentUserDefinedRolePatchRequest.new({
  data: DatadogAPIClient::V2::IncidentUserDefinedRolePatchDataRequest.new({
    attributes: DatadogAPIClient::V2::IncidentUserDefinedRolePatchDataAttributesRequest.new({
      description: "The technical lead for the incident.",
      name: "Tech Lead",
      policy: DatadogAPIClient::V2::IncidentUserDefinedRolePolicy.new({
        is_single: true,
      }),
    }),
    id: "00000000-0000-0000-0000-000000000002",
    type: DatadogAPIClient::V2::IncidentUserDefinedRoleType::INCIDENT_USER_DEFINED_ROLES,
  }),
})
p api_instance.update_incident_user_defined_role("00000000-0000-0000-0000-000000000002", body)
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"
```
{% /tab %}

{% tab label="Rust" %}
```rust
// Update an incident user-defined role returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_incidents::IncidentsAPI;
use datadog_api_client::datadogV2::api_incidents::UpdateIncidentUserDefinedRoleOptionalParams;
use datadog_api_client::datadogV2::model::IncidentUserDefinedRolePatchDataAttributesRequest;
use datadog_api_client::datadogV2::model::IncidentUserDefinedRolePatchDataRequest;
use datadog_api_client::datadogV2::model::IncidentUserDefinedRolePatchRequest;
use datadog_api_client::datadogV2::model::IncidentUserDefinedRolePolicy;
use datadog_api_client::datadogV2::model::IncidentUserDefinedRoleType;
use uuid::Uuid;

#[tokio::main]
async fn main() {
    let body = IncidentUserDefinedRolePatchRequest::new(
        IncidentUserDefinedRolePatchDataRequest::new(
            Uuid::parse_str("00000000-0000-0000-0000-000000000002").expect("invalid UUID"),
            IncidentUserDefinedRoleType::INCIDENT_USER_DEFINED_ROLES,
        )
        .attributes(
            IncidentUserDefinedRolePatchDataAttributesRequest::new()
                .description(Some("The technical lead for the incident.".to_string()))
                .name("Tech Lead".to_string())
                .policy(IncidentUserDefinedRolePolicy::new(true)),
        ),
    );
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.update_incident_user_defined_role", true);
    let api = IncidentsAPI::with_config(configuration);
    let resp = api
        .update_incident_user_defined_role(
            Uuid::parse_str("00000000-0000-0000-0000-000000000002").expect("invalid UUID"),
            body,
            UpdateIncidentUserDefinedRoleOptionalParams::default(),
        )
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
```
{% /tab %}

{% tab label="TypeScript" %}
```typescript
/**
 * Update an incident user-defined role 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,
    },
  },
});
configuration.unstableOperations["v2.updateIncidentUserDefinedRole"] = true;
const apiInstance = new v2.IncidentsApi(configuration);

const params: v2.IncidentsApiUpdateIncidentUserDefinedRoleRequest = {
  body: {
    data: {
      attributes: {
        description: "The technical lead for the incident.",
        name: "Tech Lead",
        policy: {
          isSingle: true,
        },
      },
      id: "00000000-0000-0000-0000-000000000002",
      type: "incident_user_defined_roles",
    },
  },
  roleId: "00000000-0000-0000-0000-000000000002",
};

apiInstance
  .updateIncidentUserDefinedRole(params)
  .then((data: v2.IncidentUserDefinedRoleResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"
```
{% /tab %}
{% /tabs %}
