Get a notification channel for a user. The authenticated user must be the target user or have the on_call_admin permission
This endpoint requires the on_call_read permission.
# Path parameters exportuser_id="00000000-0000-0000-0000-000000000000" exportchannel_id="00000000-0000-0000-0000-000000000000" # Use a Personal Access Token or Service Access Token exportDD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
"""
Get an On-Call notification channel for a user returns "OK" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.on_call_apiimportOnCallApi# there is a valid "user" in the systemUSER_DATA_ID=environ["USER_DATA_ID"]# there is a valid "oncall_email_notification_channel" in the systemONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID=environ["ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID"]configuration=Configuration()configuration.access_token=environ["DD_BEARER_TOKEN"]withApiClient(configuration)asapi_client:api_instance=OnCallApi(api_client)response=api_instance.get_user_notification_channel(user_id=USER_DATA_ID,channel_id=ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID,)print(response)
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"
# Get an On-Call notification channel for a user returns "OK" responserequire"datadog_api_client"DatadogAPIClient.configuredo|config|config.access_token=ENV["DD_BEARER_TOKEN"]endapi_instance=DatadogAPIClient::V2::OnCallAPI.new# there is a valid "user" in the systemUSER_DATA_ID=ENV["USER_DATA_ID"]# there is a valid "oncall_email_notification_channel" in the systemONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID=ENV["ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID"]papi_instance.get_user_notification_channel(USER_DATA_ID,ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID)
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"
// Get an On-Call notification channel for a user returns "OK" responsepackagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){// there is a valid "user" in the systemUserDataID:=os.Getenv("USER_DATA_ID")// there is a valid "oncall_email_notification_channel" in the systemOncallEmailNotificationChannelDataID:=os.Getenv("ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID")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.NewOnCallApi(apiClient)resp,r,err:=api.GetUserNotificationChannel(ctx,UserDataID,OncallEmailNotificationChannelDataID)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `OnCallApi.GetUserNotificationChannel`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `OnCallApi.GetUserNotificationChannel`:\n%s\n",responseContent)}
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"
// Get an On-Call notification channel for a user returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.OnCallApi;importcom.datadog.api.client.v2.model.NotificationChannel;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));OnCallApiapiInstance=newOnCallApi(defaultClient);// there is a valid "user" in the systemStringUSER_DATA_ID=System.getenv("USER_DATA_ID");// there is a valid "oncall_email_notification_channel" in the systemStringONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID=System.getenv("ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID");try{NotificationChannelresult=apiInstance.getUserNotificationChannel(USER_DATA_ID,ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling OnCallApi#getUserNotificationChannel");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
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"
// Get an On-Call notification channel for a user returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_on_call::OnCallAPI;#[tokio::main]asyncfnmain(){// there is a valid "user" in the system
letuser_data_id=std::env::var("USER_DATA_ID").unwrap();// there is a valid "oncall_email_notification_channel" in the system
letoncall_email_notification_channel_data_id=std::env::var("ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID").unwrap();letconfiguration=datadog::Configuration::new();letapi=OnCallAPI::with_config(configuration);letresp=api.get_user_notification_channel(user_data_id.clone(),oncall_email_notification_channel_data_id.clone(),).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
/**
* Get an On-Call notification channel for a user returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration({authMethods:{AuthZ:{accessToken: process.env.DD_BEARER_TOKENasstring,},},});constapiInstance=newv2.OnCallApi(configuration);// there is a valid "user" in the system
constUSER_DATA_ID=process.env.USER_DATA_IDasstring;// there is a valid "oncall_email_notification_channel" in the system
constONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID=process.env.ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_IDasstring;constparams: v2.OnCallApiGetUserNotificationChannelRequest={userId: USER_DATA_ID,channelId: ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID,};apiInstance.getUserNotificationChannel(params).then((data: v2.NotificationChannel)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
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"
Request a personalized demo
Get Started with Datadog
Ask AI
AI-generated responses may be inaccurate. Verify important info.