All users api

Mansi Gusain 270 Reputation points
2025-02-19T17:10:12.6666667+00:00

Hi , I am using the /users api to get the domains and ids of my colleague now what is happening is that I do use the api- /me/events and try getting my events so in the response i am able to view other users events how can i customize it? please help .

I have the User.ReadBasic.All also.

openapi: 3.1.0

info:

title: Microsoft Graph API Integration

version: 1.0.0

servers:

components:

securitySchemes:

OAuth2:

  type: oauth2

  flows:

    clientCredentials:

      tokenUrl: https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token

      scopes:

        https://graph.microsoft.com/User.Read: Access current user profile

        https://graph.microsoft.com/Mail.Read: Read user mail

        https://graph.microsoft.com/Mail.Send: Send mail

        https://graph.microsoft.com/Calendars.ReadWrite: Read and write user calendars

schemas:

UserProfile:

  type: object

  properties:

    id:

      type: string

    displayName:

      type: string

    mail:

      type: string

UserMessage:

  type: object

  properties:

    id:

      type: string

    subject:

      type: string

    bodyPreview:

      type: string

CalendarEvent:

  type: object

  properties:

    id:

      type: string

    subject:

      type: string

    start:

      type: object

      properties:

        dateTime:

          type: string

        timeZone:

          type: string

    end:

      type: object

      properties:

        dateTime:

          type: string

        timeZone:

          type: string

NewEvent:

  type: object

  properties:

    subject:

      type: string

    start:

      type: object

      properties:

        dateTime:

          type: string

        timeZone:

          type: string

    end:

      type: object

      properties:

        dateTime:

          type: string

        timeZone:

          type: string

    attendees:

      type: array

      items:

        type: object

        properties:

          emailAddress:

            type: object

            properties:

              address:

                type: string

              name:

                type: string

SendMailRequest:

  type: object

  properties:

    message:

      type: object

      properties:

        subject:

          type: string

        body:

          type: object

          properties:

            contentType:

              type: string

            content:

              type: string

        toRecipients:

          type: array

          items:

            type: object

            properties:

              emailAddress:

                type: object

                properties:

                  address:

                    type: string

security:

  • OAuth2: []

paths:

/me:

get:

  operationId: getUserProfile

  summary: Get the authenticated user's profile

  security:

    - OAuth2: []

  responses:

    '200':

      description: A user profile

      content:

        application/json:

          schema:

            $ref: '#/components/schemas/UserProfile'

/me/messages:

get:

  operationId: getUserMessages

  summary: Get the authenticated user's messages

  security:

    - OAuth2: []

  parameters:

    - name: $top

      in: query

      required: false

      schema:

        type: integer

        default: 10

        description: Number of messages to return

    - name: $filter

      in: query

      required: false

      schema:

        type: string

        description: OData filter query to narrow results

    - name: $orderby

      in: query

      required: false

      schema:

        type: string

        description: OData order by query to sort results

  responses:

    '200':

      description: A list of user messages

      content:

        application/json:

          schema:

            type: array

            items:

              $ref: '#/components/schemas/UserMessage'

/me/sendMail:

post:

  operationId: sendUserMail

  summary: Send an email as the authenticated user

  security:

    - OAuth2: []

  requestBody:

    required: true

    content:

      application/json:

        schema:

          $ref: '#/components/schemas/SendMailRequest'

  responses:

    '202':

      description: Accepted

/me/events:

get:

  operationId: getUserCalendarEvents

  summary: Get the authenticated user's calendar events

  security:

    - OAuth2: []

  responses:

    '200':

      description: A list of calendar events

      content:

        application/json:

          schema:

            type: array

            items:

              $ref: '#/components/schemas/CalendarEvent'

post:

  operationId: createUserCalendarEvent

  summary: Create a new calendar event for the authenticated user

  security:

    - OAuth2: []

  requestBody:

    required: true

    content:

      application/json:

        schema:

          $ref: '#/components/schemas/NewEvent'

  responses:

    '201':

      description: Created

      content:

        application/json:

          schema:

            $ref: '#/components/schemas/CalendarEvent'

/me/outlook/supportedTimeZones:

get:

  operationId: getSupportedTimeZones

  summary: Get supported time zones for the authenticated user

  security:

    - OAuth2: []

  responses:

    '200':

      description: A list of supported time zones

      content:

        application/json:

          schema:

            type: array

            items:

              type: object

              properties:

                alias:

                  type: string

                displayName:

                  type: string

/users:

get:

  operationId: listUsers

  summary: List users

  security:

    - OAuth2: []

  parameters:

    - name: $filter

      in: query

      required: true

      schema:

        type: string

        description: OData filter query to narrow results

        example: startsWith(displayName,'[NAME]')

  responses:

    '200':

      description: A list of users

      content:

        application/json:

          schema:

            type: array

            items:

              $ref: '#/components/schemas/UserProfile'
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,112 questions
{count} votes

Accepted answer
  1. Yakun Huang-MSFT 10,400 Reputation points Microsoft Vendor
    2025-02-20T06:20:28.2033333+00:00

    Hello Mansi Gusain,

    Thank you for reaching out to Microsoft Support!

    When you need to view other users' events, you first need the other users to grant your account permission to respond, as follows:

    User's image

    Then the event of other users can be obtained by GET /users/{id | userPrincipalName}/events request.

    If you don't want other users to see your email, then again, other users can only get your email if you share your email:

    User's image

    With the exception of Application permissions, application permissions can obtain information such as emails and events for all users, but it is important to note that application permissions require administrator authorization.

    Reference document:

    https://learn.microsoft.com/en-us/graph/api/user-list-events?view=graph-rest-1.0&tabs=http

    https://learn.microsoft.com/en-us/graph/api/user-list-messages?view=graph-rest-1.0&tabs=http

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.