API plugins enable declarative agents in Microsoft 365 Copilot to interact with REST APIs that have an OpenAPI description. With an API plugin, users can ask a declarative agent to not only query a REST API for information, but to create, update, and delete data and objects. Anything the REST API can do is accessible via natural language prompts.
Important
API plugins are only supported as actions within declarative agents. They are not enabled in Microsoft 365 Copilot.
An API plugin provides an OpenAPI description document and a plugin manifest that Copilot uses to learn the capabilities of the API. Copilot can then decide when an installed and enabled plugin's API is suited to answer any given prompt. To learn more about the manifest file that an API plugin requires, see API plugin manifest schema for Microsoft 365 Copilot.
For example, consider a budgets API that allows for querying and creating budgets, charging expenses, or adding funds to existing budgets. The prompt "How much is left in the Contoso travel budget" could trigger a budget plugin, making the following API call.
HTTP
GET /budgets?name=contoso%20travel
Copilot uses the response from the API call to generate its response: "The Contoso travel budget currently has $5,000 in available funds. If you need to allocate funds to specific categories or track expenses, I can assist you with that as well. Just let me know how I can help!"
The prompt "Charge $500 to the Contoso travel budget for Megan's airline ticket" could be translated to the following API call.
Copilot responds to the user, using the information returned: "The charge of $500 for Megan's airline ticket has been successfully processed. The Contoso travel budget now has $4,500 remaining in available funds. If you need to make any more transactions or require further assistance with your budget, please let me know!"
How API plugins work
The user asks the agent "How much is left in the Fourth Coffee lobby renovation budget?"
The agent identifies a budget-related plugin from its available plugins that has a function GetBudget to get budget details. It maps parts of the user's question to the parameters of the function: budgetName="".
The agent asks the user to allow it to send Fourth Coffee lobby renovation to the plugin.
The user chooses to allow data to be shared with the plugin once, or chooses to always allow data to be shared for this function.
If the plugin's API requires authentication, the plugin requests a token or API key from the token store.
The token store returns a token or key. If needed, the token store causes the agent to prompt the user to sign in.
The agent sends a request to the plugin's API, which is hosted outside of Microsoft 365.
HTTP
GET /budgets?budgetName=Fourth+Coffee+lobby+renovation
The API returns an API response in the format specified in it's OpenAPI specification.
Copilot generates conversational responses using data from API responses. Plugins can customize these responses by providing Adaptive Card templates to display data in a structured way.
Optimize your plugin for Copilot orchestrator
Microsoft 365 Copilot can uniquely choose the right skill from the many skills in its repertoire. But how can you make sure Copilot will choose your plugin to provide the right skill?
The answer lies in how you describe your plugin, its skills, and the parameters for initiation of skills. Specify concise and accurate descriptions in your plugin manifest to best ensure that the Copilot orchestrator knows when and how to invoke your plugin.
The way you describe your plugin to the orchestrator depends on the type of plugin you build, as described in the following table.
There are two tools developers can use to generate API plugin packages.
The Teams Toolkit in Visual Studio or Visual Studio Code can create plugin packages based on an existing OpenAPI description. If you don't have an existing API, Teams Toolkit also has starter projects with an example API and corresponding plugin package.
Kiota is a command line tool and a Visual Studio Code extension that can generate plugin packages based on an existing OpenAPI description.
Limitations
URLs in API responses are redacted
To protect the user's privacy, Copilot redacts any URLs contained in API responses. The sole exception to this behavior is any URL in a property specified by the url property in the Response semantics properties object.
Extend declarative agents for Microsoft 365 Copilot with API plugins is a multi-part series that teaches you basic concepts of extending declarative agents with actions using API plugins. You learn what API plugins are, how they work, and when you should consider building them. You also learn how to use Adaptive Cards to show data in a rich way and how to connect to secured APIs.