Skip to main content

spo agent add

Adds a new SharePoint agent

Usage

m365 spo agent add [options]

Options

-u, --webUrl <webUrl>

URL of the site where the agent should be added.

-n, --name <name>

The name of the agent.

-a, --agentInstructions <agentInstructions>

The definition of the agent's role, tone, and limitations.

-w, --welcomeMessage <welcomeMessage>

The welcome message.

-s, --sourceUrls <sourceUrls>

Comma-separated list of URLs of the SharePoint sites, libraries, or files that are the sources of information.

-d, --description <description>

The brief description of the agent's objective.

-i, --icon [icon]

The URL of the icon.

-c, --conversationStarters [conversationStarters]

Starter prompts. Please provide each prompt separated by a comma.

-h, --help [help]

Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are options, examples, remarks, permissions, response, full. Default is options.

--query [query]

JMESPath query string. See http://jmespath.org/ for more information and examples.

-o, --output [output]

Output type. json, text, csv, md, none. Default json.

--verbose

Runs command with verbose logging.

--debug

Runs command with debug logging.

Permissions

ResourcePermissions
SharePointAllSites.FullControl

Examples

Add a SharePoint agent with site and library sources.

m365 spo agent add --webUrl https://contoso.sharepoint.com/sites/projectSite --name "Project Assistant" --agentInstructions "You are a helpful assistant for project management tasks. Be professional and concise." --welcomeMessage "Hello! I'm here to help you with project management tasks." --sourceUrls "https://contoso.sharepoint.com/sites/projectSite,https://contoso.sharepoint.com/sites/projectSite/Shared Documents/Forms/AllItems.aspx" --description "A helpful agent for project management assistance"

Add a SharePoint agent with icon and conversation starters.

m365 spo agent add --webUrl https://contoso.sharepoint.com/sites/projectSite --name "HR Assistant" --agentInstructions "You are an HR assistant. Help with HR policies and procedures." --welcomeMessage "Welcome! I can help you with HR-related questions." --sourceUrls "https://contoso.sharepoint.com/sites/hr" --icon "https://contoso.sharepoint.com/sites/projectSite/SiteAssets/hr-icon.png" --conversationStarters "What are the vacation policies?,How do I submit a timesheet?,Where can I find the employee handbook?" --description "A helpful agent for project management assistance"

Add a basic SharePoint agent with minimal configuration.

m365 spo agent add --webUrl https://contoso.sharepoint.com/sites/marketing --name "Marketing Bot" --agentInstructions "Assist with marketing campaign information and resources." --welcomeMessage "Hi! I can help you find marketing resources." --sourceUrls "https://contoso.sharepoint.com/sites/marketing/Campaigns" --description "A helpful agent for project management assistance"

Response

{
"CheckInComment": "",
"CheckOutType": 2,
"ContentTag": "{95784749-23D7-410D-BAEF-E694328F89AB},1,1",
"CustomizedPageStatus": 0,
"ETag": "\"{95784749-23D7-410D-BAEF-E694328F89AB},1\"",
"Exists": true,
"ExistsAllowThrowForPolicyFailures": true,
"ExistsWithException": true,
"IrmEnabled": false,
"Length": "4543",
"Level": 1,
"LinkingUri": null,
"LinkingUrl": "",
"MajorVersion": 1,
"MinorVersion": 0,
"Name": "Test Agent.agent",
"ServerRelativeUrl": "/sites/TestSite/SiteAssets/Copilots/Test Agent.agent",
"TimeCreated": "2025-08-19T06:49:03Z",
"TimeLastModified": "2025-08-19T06:49:03Z",
"Title": null,
"UIVersion": 512,
"UIVersionLabel": "1.0",
"UniqueId": "95784749-23d7-410d-baef-e694328f89ab"
}