Namespace: microsoft.graph
Get the specified profilePhoto or its metadata (profilePhoto properties).
The supported sizes of HD photos on Microsoft 365 are as follows: 48x48, 64x64, 96x96, 120x120, 240x240,
360x360, 432x432, 504x504, and 648x648. Photos can be any dimension if they're stored in Microsoft Entra ID.
You can get the metadata of the largest available photo or specify a size to get the metadata for that photo size.
If the size you request is unavailable, you can still get a smaller size that the user has uploaded and made available.
For example, if the user uploads a photo that is 504x504 pixels, all but the 648x648 size of the photo is available for download.
This API is available in the following national cloud deployments.
Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
✅ |
✅ |
✅ |
✅ |
Permissions
The following tables show the least privileged permission or permissions required to call this API on each supported resource type. Follow best practices to request the least privileged permissions. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
Permission type |
Least privileged permissions |
Higher privileged permissions |
Delegated (work or school account) |
Contacts.Read |
Contacts.ReadWrite |
Delegated (personal Microsoft account) |
Contacts.Read |
Contacts.ReadWrite |
Application |
Contacts.Read |
Contacts.ReadWrite |
To retrieve the profile photo of a group
Permission type |
Least privileged permissions |
Higher privileged permissions |
Delegated (work or school account) |
ProfilePhoto.Read.All |
ProfilePhoto.ReadWrite.All, Group.Read.All, Group.ReadWrite.All |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
ProfilePhoto.Read.All |
ProfilePhoto.ReadWrite.All, Group.Read.All, Group.ReadWrite.All |
To retrieve the profile photo of a team
Permission type |
Least privileged permissions |
Higher privileged permissions |
Delegated (work or school account) |
Team.ReadBasic.All |
TeamSettings.Read.All, TeamSettings.ReadWrite.All |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
Team.ReadBasic.All |
TeamSettings.Read.All, TeamSettings.ReadWrite.All |
To retrieve the profile photo of a user
Permission type |
Least privileged permissions |
Higher privileged permissions |
Delegated (work or school account) |
ProfilePhoto.Read.All |
ProfilePhoto.ReadWrite.All, User.Read, User.ReadBasic.All, User.Read.All, User.ReadWrite, User.ReadWrite.All |
Delegated (personal Microsoft account) |
User.Read |
User.ReadWrite |
Application |
ProfilePhoto.Read.All |
ProfilePhoto.ReadWrite.All, User.Read.All, User.ReadWrite.All |
Note
- Retrieving a user's photo using the Microsoft Graph API is currently not supported in Azure AD B2C tenants.
- Guest users can view profile photos of users, even when the Guest user access settings are configured to the most restrictive option in Azure Active Directory External Identities settings.
HTTP request
Get the photo
GET /me/photo/$value
GET /users/{id | userPrincipalName}/photo/$value
GET /groups/{id}/photo/$value
GET /me/contacts/{id}/photo/$value
GET /users/{id | userPrincipalName}/contacts/{id}/photo/$value
GET /me/contactfolders/{contactFolderId}/contacts/{id}/photo/$value
GET /users/{id | userPrincipalName}/contactfolders/{contactFolderId}/contacts/{id}/photo/$value
GET /team/{id}/photo/$value
GET /me/photo
GET /me/photos
GET /users/{id | userPrincipalName}/photo
GET /groups/{id}/photo
GET /me/contacts/{id}/photo
GET /users/{id | userPrincipalName}/contacts/{id}/photo
GET /me/contactfolders/{contactFolderId}/contacts/{id}/photo
GET /users/{id | userPrincipalName}/contactfolders/{contactFolderId}/contacts/{id}/photo
GET /team/{id}/photo
GET /me/photos/{size}
GET /users/{id | userPrincipalName}/photos/{size}
GET /groups/{id}/photos/{size}
Path parameters
Parameter |
Type |
Description |
size |
String |
A photo size. The supported sizes of HD photos on Microsoft 365 are as follows: 48x48, 64x64, 96x96, 120x120, 240x240, 360x360, 432x432, 504x504, and 648x648. Photos can be any dimension if they're stored in Microsoft Entra ID. |
Optional query parameters
This method supports the OData query parameters to help customize the response.
Request body
Don't supply a request body for this method.
Response
Response for getting the photo
If successful, this method returns a 200 OK
response code and binary data of the requested photo. If no photo exists, the operation returns 404 Not Found
.
If successful, this method returns a 200 OK
response code and profilePhoto object in the response body.
Examples
Example 1: Get the photo for the signed-in user in the largest available size
Request
GET https://graph.microsoft.com/v1.0/me/photo/$value
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Me.Photo.Content.GetAsync();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Me().Photo().Value().Get(context.Background(), nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.me().photo().content().get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$graphServiceClient->me()->photo()->content()->get()->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
await graph_client.me.photo.content.get()
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
Contains the binary data of the requested photo. The HTTP response code is 200.
HTTP/1.1 200 OK
Example 2: Get the 48x48 photo for the signed-in user
Request
GET https://graph.microsoft.com/v1.0/me/photos/48x48/$value
Content-Type: image/jpg
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Me.Photos["{profilePhoto-id}"].Content.GetAsync();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Me().Photos().ByProfilePhotoId("profilePhoto-id").Value().Get(context.Background(), nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.me().photos().byProfilePhotoId("{profilePhoto-id}").content().get();
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);
let stream = await client.api('/me/photos/48x48/$value')
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$graphServiceClient->me()->photos()->byProfilePhotoId('profilePhoto-id')->content()->get()->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
await graph_client.me.photos.by_profile_photo_id('profilePhoto-id').content.get()
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Note
To ensure a fixed size for the output photo, use the dedicated endpoint for photos (/photos) with fixed sizes instead of relying on the default photo endpoint (/photo), which provides the largest available photo.
Response
Contains the binary data of the requested 48x48 photo. The HTTP response code is 200.
HTTP/1.1 200 OK
Request
GET https://graph.microsoft.com/v1.0/me/photo
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Photo.GetAsync();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
photo, err := graphClient.Me().Photo().Get(context.Background(), nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
ProfilePhoto result = graphClient.me().photo().get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->me()->photo()->get()->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
result = await graph_client.me.photo.get()
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
The following response data shows the photo metadata.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Me/photo/$entity",
"@odata.id": "https://graph.microsoft.com/v1.0/users('ddfcd489-628b-7d04-b48b-20075df800e5@1717622f-1d94-c0d4-9d74-f907ad6677b4')/photo",
"@odata.mediaContentType": "image/jpeg",
"@odata.mediaEtag": "\"BA09D118\"",
"id": "240x240",
"width": 240,
"height": 240
}
The following response data shows the contents of a response when a photo hasn't already been uploaded for the user.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Me/photo/$entity",
"@odata.id": "https://graph.microsoft.com/v1.0/users('ddfcd489-628b-7d04-b48b-20075df800e5@1717622f-1d94-c0d4-9d74-f907ad6677b4')/photo",
"@odata.mediaContentType": "image/gif",
"@odata.mediaEtag": "",
"id": "1x1",
"width": 1,
"height": 1
}
Request
The following example shows a request to get the metadata of the team photo.
GET https://graph.microsoft.com/v1.0/teams/172b0cce-e65d-44ce-9a49-91d9f2e8491e/photo
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Teams["{team-id}"].Photo.GetAsync();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
photo, err := graphClient.Teams().ByTeamId("team-id").Photo().Get(context.Background(), nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
ProfilePhoto result = graphClient.teams().byTeamId("{team-id}").photo().get();
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);
let profilePhoto = await client.api('/teams/172b0cce-e65d-44ce-9a49-91d9f2e8491e/photo')
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->teams()->byTeamId('team-id')->photo()->get()->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
result = await graph_client.teams.by_team_id('team-id').photo.get()
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#teams('172b0cce-e65d-44ce-9a49-91d9f2e8491e')/photo/$entity",
"@odata.id": "https://graph.microsoft.com/v1.0/teams('172b0cce-e65d-44ce-9a49-91d9f2e8491e')/photo",
"@odata.mediaContentType": "image/jpeg",
"@odata.mediaEtag": "\"BA09D118\"",
"id": "240X240",
"width": 240,
"height": 240
}
Example 5: Get the team photo's binary data
The following example shows a request to get the team photo's binary data.
Request
GET https://graph.microsoft.com/v1.0/teams/172b0cce-e65d-44ce-9a49-91d9f2e8491e/photo/$value
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Teams["{team-id}"].Photo.Content.GetAsync();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Teams().ByTeamId("team-id").Photo().Value().Get(context.Background(), nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.teams().byTeamId("{team-id}").photo().content().get();
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);
let stream = await client.api('/teams/172b0cce-e65d-44ce-9a49-91d9f2e8491e/photo/$value')
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$graphServiceClient->teams()->byTeamId('team-id')->photo()->content()->get()->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
await graph_client.teams.by_team_id('team-id').photo.content.get()
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
Contains the binary data of the requested photo. The HTTP response code is 200.
HTTP/1.1 200 OK
Using the binary data of the requested photo
When you use the /photo/$value
endpoint to get the binary data for a profile photo, you need to convert the data into a base-64 string to add it as an email attachment. The following JavaScript example shows how to create an array that you can pass as the value of the Attachments
parameter of an Outlook message.
const attachments = [{
'@odata.type': '#microsoft.graph.fileAttachment',
ContentBytes: file.toString('base64'),
Name: 'mypic.jpg'
}];
For implementation details, see the Microsoft Graph Connect Sample for Node.js.
If you want to display the image on a web page, create an in-memory object from the image and make that object the source of an image element. The following JavaScript example shows this operation.
const url = window.URL || window.webkitURL;
const blobUrl = url.createObjectURL(image.data);
document.getElementById(imageElement).setAttribute("src", blobUrl);