participant: startHoldMusic
Article
02/18/2023
4 contributors
Feedback
In this article
Namespace: microsoft.graph
Put a participant on hold and play music in the background.
Note: Only one participant can be placed on hold at any given time.
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions .
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
Not Supported.
Delegated (personal Microsoft account)
Not Supported.
Application
Calls.JoinGroupCallsasGuest.All or Calls.JoinGroupCalls.All
HTTP request
POST /communications/calls/{id}/participants/{id}/startHoldMusic
Name
Description
Authorization
Bearer {token}. Required.
Content-type
application/json. Required.
Request body
In the request body, provide a JSON object with the following parameters.
Parameter
Type
Description
customPrompt
microsoft.graph.mediaPrompt
Optional. Audio prompt the participant will hear when placed on hold.
clientContext
String
Optional. Unique client context string. Can have a maximum of 256 characters.
Response
If successful, this method returns a 202 Accepted
response code and a startHoldMusicOperation object in the response body.
Example
The following example shows how to call this API.
Request
The following is an example of a request.
POST https://graph.microsoft.com/v1.0/communications/calls/e141b67c-90fd-455d-858b-b48a40b9cc8d/participants/fa1e9582-7145-4ca3-bcd8-577f561fcb6e/startHoldMusic
Content-type: application/json
{
"customPrompt": {
"@odata.type": "#microsoft.graph.mediaPrompt",
"mediaInfo": {
"@odata.type": "#microsoft.graph.mediaInfo",
"uri": "https://bot.contoso.com/onHold.wav",
},
},
"clientContext": "d45324c1-fcb5-430a-902c-f20af696537c",
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Microsoft.Graph.Communications.Calls.Item.Participants.Item.StartHoldMusic.StartHoldMusicPostRequestBody
{
CustomPrompt = new Prompt
{
OdataType = "#microsoft.graph.mediaPrompt",
AdditionalData = new Dictionary<string, object>
{
{
"mediaInfo" , new
{
OdataType = "#microsoft.graph.mediaInfo",
Uri = "https://bot.contoso.com/onHold.wav",
}
},
},
},
ClientContext = "d45324c1-fcb5-430a-902c-f20af696537c",
};
var result = await graphClient.Communications.Calls["{call-id}"].Participants["{participant-id}"].StartHoldMusic.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/Communications/Calls/Item/Participants/Item/StartHoldMusic"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestBody := graphmodels.NewStartHoldMusicPostRequestBody()
customPrompt := graphmodels.NewPrompt()
additionalData := map[string]interface{}{
mediaInfo := graphmodels.New()
uri := "https://bot.contoso.com/onHold.wav"
mediaInfo.SetUri(&uri)
customPrompt.SetMediaInfo(mediaInfo)
}
customPrompt.SetAdditionalData(additionalData)
requestBody.SetCustomPrompt(customPrompt)
clientContext := "d45324c1-fcb5-430a-902c-f20af696537c"
requestBody.SetClientContext(&clientContext)
result, err := graphClient.Communications().Calls().ByCallId("call-id").Participants().ByParticipantId("participant-id").StartHoldMusic().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
MediaPrompt customMediaPrompt = new MediaPrompt();
MediaInfo mediaInfo = new MediaInfo();
mediaInfo.uri = "https://bot.contoso.com/onHold.wav";
customPrompt.mediaInfo = mediaInfo;
String clientContext = "d45324c1-fcb5-430a-902c-f20af696537c";
graphClient.communications().calls("e141b67c-90fd-455d-858b-b48a40b9cc8d").participants("fa1e9582-7145-4ca3-bcd8-577f561fcb6e")
.startHoldMusic(ParticipantStartHoldMusicParameterSet
.newBuilder()
.withCustomPrompt(customPrompt)
.withClientContext(clientContext)
.build())
.buildRequest()
.post();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
const options = {
authProvider,
};
const client = Client.init(options);
const startHoldMusicOperation = {
customPrompt: {
'@odata.type': '#microsoft.graph.mediaPrompt',
mediaInfo: {
'@odata.type': '#microsoft.graph.mediaInfo',
uri: 'https://bot.contoso.com/onHold.wav',
},
},
clientContext: 'd45324c1-fcb5-430a-902c-f20af696537c',
};
await client.api('/communications/calls/e141b67c-90fd-455d-858b-b48a40b9cc8d/participants/fa1e9582-7145-4ca3-bcd8-577f561fcb6e/startHoldMusic')
.post(startHoldMusicOperation);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestBody = new StartHoldMusicPostRequestBody();
$customPrompt = new Prompt();
$customPrompt->set@odatatype('#microsoft.graph.mediaPrompt');
$additionalData = [
'mediaInfo' => $customPrompt = new MediaInfo();
$ customPrompt->set@odatatype('#microsoft.graph.mediaInfo');
$ customPrompt->setUri('https://bot.contoso.com/onHold.wav');
$customPrompt->setMediaInfo($mediaInfo);
];
$customPrompt->setAdditionalData($additionalData);
$requestBody->setCustomPrompt($customPrompt);
$requestBody->setClientContext('d45324c1-fcb5-430a-902c-f20af696537c');
$result = $graphServiceClient->communications()->calls()->byCallId('call-id')->participants()->byParticipantId('participant-id')->startHoldMusic()->post($requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Import-Module Microsoft.Graph.CloudCommunications
$params = @{
customPrompt = @{
"@odata.type" = "#microsoft.graph.mediaPrompt"
mediaInfo = @{
"@odata.type" = "#microsoft.graph.mediaInfo"
uri = "https://bot.contoso.com/onHold.wav"
}
}
clientContext = "d45324c1-fcb5-430a-902c-f20af696537c"
}
Start-MgCommunicationCallParticipantHoldMusic -CallId $callId -ParticipantId $participantId -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response
Note: The response object shown here might be shortened for readability.
HTTP/1.1 202 Accepted
Location: https://graph.microsoft.com/v1.0/communications/calls/e141b67c-90fd-455d-858b-b48a40b9cc8d/operations/0fe0623f-d628-42ed-b4bd-8ac290072cc5
{
"@odata.type": "#microsoft.graph.startHoldMusicOperation",
"id": "0fe0623f-d628-42ed-b4bd-8ac290072cc5",
"status": "running",
"clientContext": "d45324c1-fcb5-430a-902c-f20af696537c"
}
Notification sent to the application after the startHoldMusicOperation finishes
POST https://bot.contoso.com/api/calls
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.commsNotifications",
"value": [
{
"@odata.type": "#microsoft.graph.commsNotification",
"changeType": "deleted",
"resourceUrl": "communications/calls/e141b67c-90fd-455d-858b-b48a40b9cc8d/operations/0fe0623f-d628-42ed-b4bd-8ac290072cc5",
"resourceData": {
"@odata.type": "#microsoft.graph.startHoldMusicOperation",
"@odata.id": "communications/calls/e141b67c-90fd-455d-858b-b48a40b9cc8d/operations/0fe0623f-d628-42ed-b4bd-8ac290072cc5",
"@odata.etag": "W/\"54451\"",
"clientContext": "d45324c1-fcb5-430a-902c-f20af696537c",
"status": "completed"
}
}
]
}