Create bookingAppointment
8/15/2019
7 minutes to read
In this article
Important
APIs under the /beta
version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported.
Create a new bookingAppointment for the specified bookingbusiness .
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)
BookingsAppointment.ReadWrite.All, Bookings.ReadWrite.All, Bookings.Manage.All
Delegated (personal Microsoft account)
Not supported.
Application
Not supported.
HTTP request
POST /bookingBusinesses/{id}/appointments
Name
Description
Authorization
Bearer {code}
Request body
In the request body, supply a JSON representation of bookingAppointment object.
Response
If successful, this method returns 201, Created
response code and bookingAppointment object in the response body.
Example
Request
The following is an example of the request. This appointment does not involve booking specific staff members.
POST https://graph.microsoft.com/beta/bookingBusinesses/Contosolunchdelivery@M365B489948.onmicrosoft.com/appointments
Content-type: application/json
{
"@odata.type":"#microsoft.graph.bookingAppointment",
"customerEmailAddress":"jordanm@contoso.com",
"customerLocation":{
"@odata.type":"#microsoft.graph.location",
"address":{
"@odata.type":"#microsoft.graph.physicalAddress",
"city":"Buffalo",
"countryOrRegion":"USA",
"postalCode":"98052",
"postOfficeBox":null,
"state":"NY",
"street":"123 First Avenue",
"type@odata.type":"#microsoft.graph.physicalAddressType",
"type":null
},
"coordinates":null,
"displayName":"Customer",
"locationEmailAddress":null,
"locationType@odata.type":"#microsoft.graph.locationType",
"locationType":null,
"locationUri":null,
"uniqueId":null,
"uniqueIdType@odata.type":"#microsoft.graph.locationUniqueIdType",
"uniqueIdType":null
},
"customerName":"Jordan Miller",
"customerNotes":"Please be on time.",
"customerPhone":"213-555-0199",
"end":{
"@odata.type":"#microsoft.graph.dateTimeTimeZone",
"dateTime":"2018-05-01T12:30:00.0000000+00:00",
"timeZone":"UTC"
},
"invoiceAmount":10.0,
"invoiceDate":{
"@odata.type":"#microsoft.graph.dateTimeTimeZone",
"dateTime":"2018-05-01T12:30:00.0000000+00:00",
"timeZone":"UTC"
},
"invoiceId":"1001",
"invoiceStatus@odata.type":"#microsoft.graph.bookingInvoiceStatus",
"invoiceStatus":"open",
"invoiceUrl":"theInvoiceUrl",
"optOutOfCustomerEmail":false,
"postBuffer":"PT10M",
"preBuffer":"PT5M",
"price":10.0,
"priceType@odata.type":"#microsoft.graph.bookingPriceType",
"priceType":"fixedPrice",
"reminders@odata.type":"#Collection(microsoft.graph.bookingReminder)",
"reminders":[
{
"@odata.type":"#microsoft.graph.bookingReminder",
"message":"This service is tomorrow",
"offset":"P1D",
"recipients@odata.type":"#microsoft.graph.bookingReminderRecipients",
"recipients":"allAttendees"
},
{
"@odata.type":"#microsoft.graph.bookingReminder",
"message":"Please be available to enjoy your lunch service.",
"offset":"PT1H",
"recipients@odata.type":"#microsoft.graph.bookingReminderRecipients",
"recipients":"customer"
},
{
"@odata.type":"#microsoft.graph.bookingReminder",
"message":"Please check traffic for next cater.",
"offset":"PT2H",
"recipients@odata.type":"#microsoft.graph.bookingReminderRecipients",
"recipients":"staff"
}
],
"serviceId":"57da6774-a087-4d69-b0e6-6fb82c339976",
"serviceLocation":{
"@odata.type":"#microsoft.graph.location",
"address":{
"@odata.type":"#microsoft.graph.physicalAddress",
"city":"Buffalo",
"countryOrRegion":"USA",
"postalCode":"98052",
"postOfficeBox":null,
"state":"NY",
"street":"123 First Avenue",
"type@odata.type":"#microsoft.graph.physicalAddressType",
"type":null
},
"coordinates":null,
"displayName":"Customer location",
"locationEmailAddress":null,
"locationType@odata.type":"#microsoft.graph.locationType",
"locationType":null,
"locationUri":null,
"uniqueId":null,
"uniqueIdType@odata.type":"#microsoft.graph.locationUniqueIdType",
"uniqueIdType":null
},
"serviceName":"Catered bento",
"serviceNotes":"Customer requires punctual service.",
"start":{
"@odata.type":"#microsoft.graph.dateTimeTimeZone",
"dateTime":"2018-05-01T12:00:00.0000000+00:00",
"timeZone":"UTC"
}
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var bookingAppointment = new BookingAppointment
{
CustomerEmailAddress = "jordanm@contoso.com",
CustomerLocation = new Location
{
Address = new PhysicalAddress
{
City = "Buffalo",
CountryOrRegion = "USA",
PostalCode = "98052",
PostOfficeBox = null,
State = "NY",
Street = "123 First Avenue",
AdditionalData = new Dictionary<string, object>()
{
{"type@odata.type","#microsoft.graph.physicalAddressType"}
},
Type = null
},
Coordinates = null,
DisplayName = "Customer",
LocationEmailAddress = null,
AdditionalData = new Dictionary<string, object>()
{
{"uniqueIdType@odata.type","#microsoft.graph.locationUniqueIdType"},
{"locationType@odata.type","#microsoft.graph.locationType"}
},
LocationType = null,
LocationUri = null,
UniqueId = null,
UniqueIdType = null
},
CustomerName = "Jordan Miller",
CustomerNotes = "Please be on time.",
CustomerPhone = "213-555-0199",
End = new DateTimeTimeZone
{
DateTime = "2018-05-01T12:30:00+00:00",
TimeZone = "UTC"
},
InvoiceAmount = 10,
InvoiceDate = new DateTimeTimeZone
{
DateTime = "2018-05-01T12:30:00+00:00",
TimeZone = "UTC"
},
InvoiceId = "1001",
AdditionalData = new Dictionary<string, object>()
{
{"reminders@odata.type","#Collection(microsoft.graph.bookingReminder)"},
{"priceType@odata.type","#microsoft.graph.bookingPriceType"},
{"invoiceStatus@odata.type","#microsoft.graph.bookingInvoiceStatus"}
},
InvoiceStatus = BookingInvoiceStatus.Open,
InvoiceUrl = "theInvoiceUrl",
OptOutOfCustomerEmail = false,
PostBuffer = "PT10M",
PreBuffer = "PT5M",
Price = 10,
PriceType = BookingPriceType.FixedPrice,
Reminders = new List<BookingReminder>()
{
new BookingReminder
{
Message = "This service is tomorrow",
Offset = "P1D",
AdditionalData = new Dictionary<string, object>()
{
{"recipients@odata.type","#microsoft.graph.bookingReminderRecipients"}
},
Recipients = BookingReminderRecipients.AllAttendees
},
new BookingReminder
{
Message = "Please be available to enjoy your lunch service.",
Offset = "PT1H",
AdditionalData = new Dictionary<string, object>()
{
{"recipients@odata.type","#microsoft.graph.bookingReminderRecipients"}
},
Recipients = BookingReminderRecipients.Customer
},
new BookingReminder
{
Message = "Please check traffic for next cater.",
Offset = "PT2H",
AdditionalData = new Dictionary<string, object>()
{
{"recipients@odata.type","#microsoft.graph.bookingReminderRecipients"}
},
Recipients = BookingReminderRecipients.Staff
}
},
ServiceId = "57da6774-a087-4d69-b0e6-6fb82c339976",
ServiceLocation = new Location
{
Address = new PhysicalAddress
{
City = "Buffalo",
CountryOrRegion = "USA",
PostalCode = "98052",
PostOfficeBox = null,
State = "NY",
Street = "123 First Avenue",
AdditionalData = new Dictionary<string, object>()
{
{"type@odata.type","#microsoft.graph.physicalAddressType"}
},
Type = null
},
Coordinates = null,
DisplayName = "Customer location",
LocationEmailAddress = null,
AdditionalData = new Dictionary<string, object>()
{
{"uniqueIdType@odata.type","#microsoft.graph.locationUniqueIdType"},
{"locationType@odata.type","#microsoft.graph.locationType"}
},
LocationType = null,
LocationUri = null,
UniqueId = null,
UniqueIdType = null
},
ServiceName = "Catered bento",
ServiceNotes = "Customer requires punctual service.",
Start = new DateTimeTimeZone
{
DateTime = "2018-05-01T12:00:00+00:00",
TimeZone = "UTC"
}
};
await graphClient.BookingBusinesses["Contosolunchdelivery@M365B489948.onmicrosoft.com"].Appointments
.Request()
.AddAsync(bookingAppointment);
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
const options = {
authProvider,
};
const client = Client.init(options);
const bookingAppointment = {
@odata.type:"#microsoft.graph.bookingAppointment",
customerEmailAddress:"jordanm@contoso.com",
customerLocation:{
@odata.type:"#microsoft.graph.location",
address:{
@odata.type:"#microsoft.graph.physicalAddress",
city:"Buffalo",
countryOrRegion:"USA",
postalCode:"98052",
postOfficeBox:null,
state:"NY",
street:"123 First Avenue",
type@odata.type:"#microsoft.graph.physicalAddressType",
type:null
},
coordinates:null,
displayName:"Customer",
locationEmailAddress:null,
locationType@odata.type:"#microsoft.graph.locationType",
locationType:null,
locationUri:null,
uniqueId:null,
uniqueIdType@odata.type:"#microsoft.graph.locationUniqueIdType",
uniqueIdType:null
},
customerName:"Jordan Miller",
customerNotes:"Please be on time.",
customerPhone:"213-555-0199",
end:{
@odata.type:"#microsoft.graph.dateTimeTimeZone",
dateTime:"2018-05-01T12:30:00.0000000+00:00",
timeZone:"UTC"
},
invoiceAmount:10.0,
invoiceDate:{
@odata.type:"#microsoft.graph.dateTimeTimeZone",
dateTime:"2018-05-01T12:30:00.0000000+00:00",
timeZone:"UTC"
},
invoiceId:"1001",
invoiceStatus@odata.type:"#microsoft.graph.bookingInvoiceStatus",
invoiceStatus:"open",
invoiceUrl:"theInvoiceUrl",
optOutOfCustomerEmail:false,
postBuffer:"PT10M",
preBuffer:"PT5M",
price:10.0,
priceType@odata.type:"#microsoft.graph.bookingPriceType",
priceType:"fixedPrice",
reminders@odata.type:"#Collection(microsoft.graph.bookingReminder)",
reminders:[
{
@odata.type:"#microsoft.graph.bookingReminder",
message:"This service is tomorrow",
offset:"P1D",
recipients@odata.type:"#microsoft.graph.bookingReminderRecipients",
recipients:"allAttendees"
},
{
@odata.type:"#microsoft.graph.bookingReminder",
message:"Please be available to enjoy your lunch service.",
offset:"PT1H",
recipients@odata.type:"#microsoft.graph.bookingReminderRecipients",
recipients:"customer"
},
{
@odata.type:"#microsoft.graph.bookingReminder",
message:"Please check traffic for next cater.",
offset:"PT2H",
recipients@odata.type:"#microsoft.graph.bookingReminderRecipients",
recipients:"staff"
}
],
serviceId:"57da6774-a087-4d69-b0e6-6fb82c339976",
serviceLocation:{
@odata.type:"#microsoft.graph.location",
address:{
@odata.type:"#microsoft.graph.physicalAddress",
city:"Buffalo",
countryOrRegion:"USA",
postalCode:"98052",
postOfficeBox:null,
state:"NY",
street:"123 First Avenue",
type@odata.type:"#microsoft.graph.physicalAddressType",
type:null
},
coordinates:null,
displayName:"Customer location",
locationEmailAddress:null,
locationType@odata.type:"#microsoft.graph.locationType",
locationType:null,
locationUri:null,
uniqueId:null,
uniqueIdType@odata.type:"#microsoft.graph.locationUniqueIdType",
uniqueIdType:null
},
serviceName:"Catered bento",
serviceNotes:"Customer requires punctual service.",
start:{
@odata.type:"#microsoft.graph.dateTimeTimeZone",
dateTime:"2018-05-01T12:00:00.0000000+00:00",
timeZone:"UTC"
}
};
let res = await client.api('/bookingBusinesses/Contosolunchdelivery@M365B489948.onmicrosoft.com/appointments')
.version('beta')
.post(bookingAppointment);
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/bookingBusinesses/Contosolunchdelivery@M365B489948.onmicrosoft.com/appointments"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphBookingAppointment *bookingAppointment = [[MSGraphBookingAppointment alloc] init];
[bookingAppointment setCustomerEmailAddress:@"jordanm@contoso.com"];
MSGraphLocation *customerLocation = [[MSGraphLocation alloc] init];
MSGraphPhysicalAddress *address = [[MSGraphPhysicalAddress alloc] init];
[address setCity:@"Buffalo"];
[address setCountryOrRegion:@"USA"];
[address setPostalCode:@"98052"];
[address setPostOfficeBox: null];
[address setState:@"NY"];
[address setStreet:@"123 First Avenue"];
[address setType: null];
[customerLocation setAddress:address];
[customerLocation setCoordinates: null];
[customerLocation setDisplayName:@"Customer"];
[customerLocation setLocationEmailAddress: null];
[customerLocation setLocationType: null];
[customerLocation setLocationUri: null];
[customerLocation setUniqueId: null];
[customerLocation setUniqueIdType: null];
[bookingAppointment setCustomerLocation:customerLocation];
[bookingAppointment setCustomerName:@"Jordan Miller"];
[bookingAppointment setCustomerNotes:@"Please be on time."];
[bookingAppointment setCustomerPhone:@"213-555-0199"];
MSGraphDateTimeTimeZone *end = [[MSGraphDateTimeTimeZone alloc] init];
[end setDateTime: "2018-05-01T12:30:00+00:00"];
[end setTimeZone:@"UTC"];
[bookingAppointment setEnd:end];
[bookingAppointment setInvoiceAmount: 10.0];
MSGraphDateTimeTimeZone *invoiceDate = [[MSGraphDateTimeTimeZone alloc] init];
[invoiceDate setDateTime: "2018-05-01T12:30:00+00:00"];
[invoiceDate setTimeZone:@"UTC"];
[bookingAppointment setInvoiceDate:invoiceDate];
[bookingAppointment setInvoiceId:@"1001"];
[bookingAppointment setInvoiceStatus: [MSGraphBookingInvoiceStatus open]];
[bookingAppointment setInvoiceUrl:@"theInvoiceUrl"];
[bookingAppointment setOptOutOfCustomerEmail: false];
[bookingAppointment setPostBuffer:@"PT10M"];
[bookingAppointment setPreBuffer:@"PT5M"];
[bookingAppointment setPrice: 10.0];
[bookingAppointment setPriceType: [MSGraphBookingPriceType fixedPrice]];
NSMutableArray *remindersList = [[NSMutableArray alloc] init];
MSGraphBookingReminder *reminders = [[MSGraphBookingReminder alloc] init];
[reminders setMessage:@"This service is tomorrow"];
[reminders setOffset:@"P1D"];
[reminders setRecipients: [MSGraphBookingReminderRecipients allAttendees]];
[remindersList addObject: reminders];
MSGraphBookingReminder *reminders = [[MSGraphBookingReminder alloc] init];
[reminders setMessage:@"Please be available to enjoy your lunch service."];
[reminders setOffset:@"PT1H"];
[reminders setRecipients: [MSGraphBookingReminderRecipients customer]];
[remindersList addObject: reminders];
MSGraphBookingReminder *reminders = [[MSGraphBookingReminder alloc] init];
[reminders setMessage:@"Please check traffic for next cater."];
[reminders setOffset:@"PT2H"];
[reminders setRecipients: [MSGraphBookingReminderRecipients staff]];
[remindersList addObject: reminders];
[bookingAppointment setReminders:remindersList];
[bookingAppointment setServiceId:@"57da6774-a087-4d69-b0e6-6fb82c339976"];
MSGraphLocation *serviceLocation = [[MSGraphLocation alloc] init];
MSGraphPhysicalAddress *address = [[MSGraphPhysicalAddress alloc] init];
[address setCity:@"Buffalo"];
[address setCountryOrRegion:@"USA"];
[address setPostalCode:@"98052"];
[address setPostOfficeBox: null];
[address setState:@"NY"];
[address setStreet:@"123 First Avenue"];
[address setType: null];
[serviceLocation setAddress:address];
[serviceLocation setCoordinates: null];
[serviceLocation setDisplayName:@"Customer location"];
[serviceLocation setLocationEmailAddress: null];
[serviceLocation setLocationType: null];
[serviceLocation setLocationUri: null];
[serviceLocation setUniqueId: null];
[serviceLocation setUniqueIdType: null];
[bookingAppointment setServiceLocation:serviceLocation];
[bookingAppointment setServiceName:@"Catered bento"];
[bookingAppointment setServiceNotes:@"Customer requires punctual service."];
MSGraphDateTimeTimeZone *start = [[MSGraphDateTimeTimeZone alloc] init];
[start setDateTime: "2018-05-01T12:00:00+00:00"];
[start setTimeZone:@"UTC"];
[bookingAppointment setStart:start];
NSError *error;
NSData *bookingAppointmentData = [bookingAppointment getSerializedDataWithError:&error];
[urlRequest setHTTPBody:bookingAppointmentData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
In the request body, supply a JSON representation of bookingAppointment object.
Response
The following is an example of the response. Note: The response object shown here may be truncated for brevity. All of the properties will be returned from an actual call.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#bookingBusinesses('Contosolunchdelivery%40M365B489948.onmicrosoft.com')/appointments/$entity",
"id": "AAMkADc7zF4J0AAA8v_KnAAA=",
"selfServiceAppointmentId": "00000000-0000-0000-0000-000000000000",
"customerId": "7ed53fa5-9ef2-4f2f-975b-27447440bc09",
"customerName": "Jordan Miller",
"customerEmailAddress": "jordanm@contoso.com",
"customerPhone": "213-555-0199",
"customerNotes": null,
"serviceId": "57da6774-a087-4d69-b0e6-6fb82c339976",
"serviceName": "Catered bento",
"duration": "PT30M",
"preBuffer": "PT5M",
"postBuffer": "PT10M",
"priceType": "fixedPrice",
"price": 10,
"serviceNotes": "Customer requires punctual service.",
"optOutOfCustomerEmail": false,
"staffMemberIds": [],
"invoiceAmount": 10,
"invoiceId": "1001",
"invoiceStatus": "open",
"invoiceUrl": "theInvoiceUrl",
"customerLocation": {
"displayName": "Customer",
"locationEmailAddress": null,
"locationUri": "",
"locationType": null,
"uniqueId": null,
"uniqueIdType": null,
"address": {
"type": "home",
"postOfficeBox": "",
"street": "",
"city": "",
"state": "",
"countryOrRegion": "",
"postalCode": ""
},
"coordinates": {
"altitude": null,
"latitude": null,
"longitude": null,
"accuracy": null,
"altitudeAccuracy": null
}
},
"start": {
"dateTime": "2018-05-01T12:00:00.0000000Z",
"timeZone": "UTC"
},
"end": {
"dateTime": "2018-05-01T12:30:00.0000000Z",
"timeZone": "UTC"
},
"serviceLocation": {
"displayName": "Customer location (123 First Avenue, Buffalo, NY 98052, USA)",
"locationEmailAddress": null,
"locationUri": "",
"locationType": null,
"uniqueId": null,
"uniqueIdType": null,
"address": {
"type": "home",
"postOfficeBox": "",
"street": "",
"city": "",
"state": "",
"countryOrRegion": "",
"postalCode": ""
},
"coordinates": {
"altitude": null,
"latitude": null,
"longitude": null,
"accuracy": null,
"altitudeAccuracy": null
}
},
"reminders": [
{
"offset": "P1D",
"recipients": "allAttendees",
"message": "This service is tomorrow"
},
{
"offset": "PT1H",
"recipients": "customer",
"message": "Please be available to enjoy your lunch service."
},
{
"offset": "PT2H",
"recipients": "staff",
"message": "Please check traffic for next cater."
}
],
"invoiceDate": {
"dateTime": "2018-05-01T12:30:00.0000000Z",
"timeZone": "UTC"
}
}