Skip to content
Download

Graph API Calls

The graph-call command executes HTTP requests against the Microsoft Graph API.

Terminal window
msgraph graph-call <METHOD> <URL> [flags]

The URL can be a full URL or a relative path starting with /.

GET requests work by default without any special flags:

Terminal window
# Current user profile
msgraph graph-call GET /me
# List users
msgraph graph-call GET /users --select "displayName,mail" --top 10
# Get user's unread messages
msgraph graph-call GET /me/messages --filter "isRead eq false" --top 5
# List groups
msgraph graph-call GET /groups --select "displayName,description"
# Get team channels
msgraph graph-call GET /teams/{team-id}/channels

POST, PUT, and PATCH requests require the --allow-writes flag:

Terminal window
# Send mail
msgraph graph-call POST /me/sendMail \
--body '{"message":{"subject":"Hello","body":{"content":"Hi"},"toRecipients":[{"emailAddress":{"address":"user@example.com"}}]}}' \
--allow-writes
# Update user
msgraph graph-call PATCH /me \
--body '{"jobTitle":"Engineer"}' \
--allow-writes

DELETE requests are always blocked for safety.

FlagOData ParameterExample
--select$select--select "displayName,mail"
--filter$filter--filter "isRead eq false"
--top$top--top 10
--expand$expand--expand "members"
--orderby$orderby--orderby "displayName desc"
FlagDescription
--api-versionUse v1.0 or beta (default: beta)
--bodyJSON request body for POST/PUT/PATCH
--headersCustom headers as key:value
--scopesAdditional permission scopes to request
--outputOutput format: json (default) or raw

Responses are returned as JSON:

{
"statusCode": 200,
"body": {
"@odata.context": "https://graph.microsoft.com/beta/$metadata#users/$entity",
"displayName": "John Doe",
"mail": "john@contoso.com"
}
}

Some queries require the ConsistencyLevel header:

Terminal window
# Count users
msgraph graph-call GET /users/\$count \
--headers "ConsistencyLevel:eventual"
# Search users
msgraph graph-call GET '/users?$search="displayName:John"' \
--headers "ConsistencyLevel:eventual"

The tool handles common errors:

  • 401: Token expired — run auth signin again
  • 403: Insufficient permissions — automatic incremental consent is attempted
  • 404: Resource not found — check the URL
  • 429: Rate limited — wait and retry