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)
Contacts.ReadWrite
Delegated (personal Microsoft account)
Contacts.ReadWrite
Application
Contacts.ReadWrite
HTTP request
POST /me/contacts
POST /users/{id | userPrincipalName}/contacts
POST /me/contactFolders/{contactFolderId}/contacts
POST /users/{id | userPrincipalName}/contactFolders/{contactFolderId}/contacts
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new Contact
{
GivenName = "Pavel",
Surname = "Bansky",
EmailAddresses = new List<EmailAddress>
{
new EmailAddress
{
Address = "[email protected]",
Name = "Pavel Bansky",
},
},
BusinessPhones = new List<string>
{
"+1 732 555 0102",
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Contacts.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Contact contact = new Contact();
contact.setGivenName("Pavel");
contact.setSurname("Bansky");
LinkedList<EmailAddress> emailAddresses = new LinkedList<EmailAddress>();
EmailAddress emailAddress = new EmailAddress();
emailAddress.setAddress("[email protected]");
emailAddress.setName("Pavel Bansky");
emailAddresses.add(emailAddress);
contact.setEmailAddresses(emailAddresses);
LinkedList<String> businessPhones = new LinkedList<String>();
businessPhones.add("+1 732 555 0102");
contact.setBusinessPhones(businessPhones);
Contact result = graphClient.me().contacts().post(contact);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.contact import Contact
from msgraph.generated.models.email_address import EmailAddress
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Contact(
given_name = "Pavel",
surname = "Bansky",
email_addresses = [
EmailAddress(
address = "[email protected]",
name = "Pavel Bansky",
),
],
business_phones = [
"+1 732 555 0102",
],
)
result = await graph_client.me.contacts.post(request_body)