Skip to main content

Graph CLI command reference

Run commands from Architecture/GraphSyncExperimenter/cli-graph. First complete CLI setup and Graph application authorization. Every write targets a real mailbox.

Commands​

CommandAction
user lookupResolve a directory user by address
email listList messages
email getRead one message
email attachmentsInspect message attachments
email sendSend a new message
email reply, email reply-all, email forwardCreate and send the corresponding response
email waitWait for the matching recipient copy
email readMark a message read
email moveMove a message
email label add, email label removeAdd or remove an Outlook category
email deleteMove a message to Deleted Items
email permanent-deletePermanently delete a message
folder list, folder getList the tree or read a folder
folder create, folder update, folder move, folder deleteCreate, rename, move, or delete a folder
label list, label getList or read Outlook master categories
label create, label update, label deleteCreate, change color, or delete a category

Identifiers and inputs​

--user-id selects the Graph object ID or user principal name (UPN) of the target mailbox. It identifies the sender for sending. There is no independent spoofable --from option.

Message operations need that mailbox's immutable message ID. internetMessageId correlates copies across mailboxes. The sender's emailId cannot address the recipient's copy.

Folder references accept an exact ID or unique full display name. Names match without case sensitivity, not by substring. Ambiguous matches require an explicit ID. Well-known values such as inbox work in ID inputs.

Send requires at least one --to, nonempty --subject and --body, and --priority low|normal|high. Repeat --to, --cc, and --bcc for several recipients. --body-type accepts html or text and defaults to html. Supported send/response commands accept repeated --attachment file inputs.

email wait defaults to 60000 ms timeout and 2000 ms polling. Positive --timeout-ms and --poll-interval-ms override them. Without a folder filter, it searches the target mailbox.

email permanent-delete, folder delete, and label delete require --confirm. This authorizes a real destructive operation. Permanent message deletion supports messages in Deleted Items. After a send timeout, inspect Sent Items before another send.

Examples​

Replace sample addresses, IDs, and content with your authorized targets. Write examples change real mailbox state. The exact current command grammar is available through bun run cli -- --help.

bun run cli -- <resource> <action> \
--user-id <graph-user-id-or-upn> \
[command-specific-options]
bun run cli -- --help
bun run cli -- email list \
--user-id tatar.bela@t42.hu
bun run cli -- email list \
--user-id tatar.bela@t42.hu \
--folder-id AAMkAG...
bun run cli -- email list \
--user-id tatar.bela@t42.hu \
--folder-id inbox
bun run cli -- email list \
--user-id tatar.bela@t42.hu \
--folder-name "Customer Follow-up"
bun run cli -- email send \
--user-id tatar.bela@t42.hu \
--to recipient@example.com \
--cc copy@example.com \
--bcc hidden@example.com \
--subject "Graph synchronization test" \
--body "<p>Test message</p>" \
--body-type html \
--priority normal
bun run cli -- email wait \
--user-id tatar.bela@t42.hu \
--internet-message-id "<message-id@example.com>" \
--timeout-ms 120000 \
--poll-interval-ms 2000
bun run cli -- email wait \
--user-id tatar.bela@t42.hu \
--internet-message-id "<message-id@example.com>" \
--folder-name "Incoming Tests"
bun run cli -- email read \
--user-id tatar.bela@t42.hu \
--immutable-email-id IMMUTABLE_ID
bun run cli -- email move \
--user-id tatar.bela@t42.hu \
--immutable-email-id IMMUTABLE_ID \
--target archive
bun run cli -- email move \
--user-id tatar.bela@t42.hu \
--immutable-email-id IMMUTABLE_ID \
--target AAMkAG...
bun run cli -- email move \
--user-id tatar.bela@t42.hu \
--immutable-email-id IMMUTABLE_ID \
--target "Customer Follow-up"
bun run cli -- email label add \
--user-id tatar.bela@t42.hu \
--immutable-email-id IMMUTABLE_ID \
--label-id LABEL_ID
bun run cli -- email label add \
--user-id tatar.bela@t42.hu \
--immutable-email-id IMMUTABLE_ID \
--label-name "Important"
bun run cli -- email label remove \
--user-id tatar.bela@t42.hu \
--immutable-email-id IMMUTABLE_ID \
--label-name "Important"
bun run cli -- email delete \
--user-id tatar.bela@t42.hu \
--immutable-email-id IMMUTABLE_ID
bun run cli -- email permanent-delete \
--user-id tatar.bela@t42.hu \
--immutable-email-id IMMUTABLE_ID \
--confirm
bun run cli -- folder list \
--user-id tatar.bela@t42.hu
bun run cli -- folder get \
--user-id tatar.bela@t42.hu \
--folder-id FOLDER_ID
bun run cli -- folder create \
--user-id tatar.bela@t42.hu \
--name "Graph Tests"
bun run cli -- folder create \
--user-id tatar.bela@t42.hu \
--name "Completed" \
--parent-folder-id PARENT_FOLDER_ID
bun run cli -- folder update \
--user-id tatar.bela@t42.hu \
--folder-id FOLDER_ID \
--name "New folder name"
bun run cli -- folder move \
--user-id tatar.bela@t42.hu \
--folder-id FOLDER_ID \
--target-folder-id TARGET_PARENT_FOLDER_ID
bun run cli -- folder delete \
--user-id tatar.bela@t42.hu \
--folder-id FOLDER_ID \
--confirm
bun run cli -- label list \
--user-id tatar.bela@t42.hu
bun run cli -- label get \
--user-id tatar.bela@t42.hu \
--label-id LABEL_ID
bun run cli -- label create \
--user-id tatar.bela@t42.hu \
--name "Graph Tested" \
--color preset4
bun run cli -- label update \
--user-id tatar.bela@t42.hu \
--label-id LABEL_ID \
--color preset8
bun run cli -- label delete \
--user-id tatar.bela@t42.hu \
--label-id LABEL_ID \
--confirm
bun run cli -- user lookup --address person@example.com
bun run cli -- email get --user-id person@example.com --immutable-email-id MESSAGE_ID
bun run cli -- email reply --user-id person@example.com --immutable-email-id MESSAGE_ID --to sender@example.com --body 'Reply text'
bun run cli -- email reply-all --user-id person@example.com --immutable-email-id MESSAGE_ID --to sender@example.com --cc colleague@example.com --body 'Reply to everyone'
bun run cli -- email forward --user-id person@example.com --immutable-email-id MESSAGE_ID --to colleague@example.com --body 'Forwarding for review'

See outputs and troubleshooting for exit codes and provider failures.