Microsoft.Agents.M365Copilot.Core
1.0.0-preview.2
Prefix Reserved
See the version list below for details.
dotnet add package Microsoft.Agents.M365Copilot.Core --version 1.0.0-preview.2
NuGet\Install-Package Microsoft.Agents.M365Copilot.Core -Version 1.0.0-preview.2
<PackageReference Include="Microsoft.Agents.M365Copilot.Core" Version="1.0.0-preview.2" />
<PackageVersion Include="Microsoft.Agents.M365Copilot.Core" Version="1.0.0-preview.2" />
<PackageReference Include="Microsoft.Agents.M365Copilot.Core" />
paket add Microsoft.Agents.M365Copilot.Core --version 1.0.0-preview.2
#r "nuget: Microsoft.Agents.M365Copilot.Core, 1.0.0-preview.2"
#:package Microsoft.Agents.M365Copilot.Core@1.0.0-preview.2
#addin nuget:?package=Microsoft.Agents.M365Copilot.Core&version=1.0.0-preview.2&prerelease
#tool nuget:?package=Microsoft.Agents.M365Copilot.Core&version=1.0.0-preview.2&prerelease
Microsoft Agents M365 Copilot APIs .NET Core Client Library
The Microsoft M365 Copilot APIs .NET Core Client Library contains core classes and interfaces used by the Microsoft M365 Copilot APIs Library to send native HTTP requests to the Microsoft M365 Copilot APIs. The latest core client library targets .NetStandard 2.0.
Getting started
1. Register your application
Register your application to use Microsoft Agents M365 Copilot API by following the steps at Register your application with the Microsoft identity platform.
2. Authenticate for the Microsoft Agents M365 Copilot service
The Microsoft Agents M365 Copilot .NET Client Library supports the use of TokenCredential classes in the Azure.Identity library.
You can read more about available Credential classes here and examples on how to quickly setup TokenCredential instances can be found here.
The recommended library for authenticating against Microsoft Identity (Azure AD) is MSAL.
For an example of authenticating a UWP app using the V2 Authentication Endpoint, see the Microsoft Graph UWP Connect Library.
Create a Copilot APIs client and make an API call
The following code example shows how to create an instance of a Microsoft 365 Copilot APIs client with an authentication provider in the supported languages. The authentication provider handles acquiring access tokens for the application. Many different authentication providers are available for each language and platform. The different authentication providers support different client scenarios. For details about which provider and options are appropriate for your scenario, see Choose an Authentication Provider.
The example also shows how to make a call to the Microsoft 365 Copilot Retrieval API. To call this API, you first need to create a request object and then run the POST method on the request.
The client ID is the app registration ID that is generated when you register your app in the Azure portal.
NOTE:
Your tenant must have a Microsoft 365 Copilot license.
using Azure.Identity;
using Microsoft.Agents.M365Copilot.Beta;
using Microsoft.Agents.M365Copilot.Beta.Models;
using Microsoft.Agents.M365Copilot.Beta.Copilot.Retrieval;
var scopes = new[] {"Files.Read.All", "Sites.Read.All"};
// Multi-tenant apps can use "common",
// single-tenant apps must use the tenant ID from the Azure portal
var tenantId = "YOUR_TENANT_ID";
// Value from app registration
var clientId = "YOUR_CLIENT_ID";
// using Azure.Identity;
var deviceCodeCredentialOptions = new DeviceCodeCredentialOptions
{
ClientId = clientId,
TenantId = tenantId,
// Callback function that receives the user prompt
// Prompt contains the generated device code that user must
// enter during the auth process in the browser
DeviceCodeCallback = (deviceCodeInfo, cancellationToken) =>
{
Console.WriteLine(deviceCodeInfo.Message);
return Task.CompletedTask;
},
};
// https://learn.microsoft.com/dotnet/api/azure.identity.devicecodecredential
var deviceCodeCredential = new DeviceCodeCredential(deviceCodeCredentialOptions);
//Create the client with explicit base URL
var baseURL = “https://graph.microsoft.com/beta”;
AgentsM365CopilotBetaServiceClient client = new AgentsM365CopilotBetaServiceClient (deviceCodeCredential, scopes, baseURL);
try
{
var requestBody = new RetrievalPostRequestBody
{
DataSource = RetrievalDataSource.SharePoint,
QueryString = "What is the latest in my organization?",
MaximumNumberOfResults = 10
};
var result = await client.Copilot.Retrieval.PostAsync(requestBody);
Console.WriteLine($"Retrieval post: {result}");
if (result != null)
{
Console.WriteLine("Retrieval response received successfully");
Console.WriteLine("\nResults:");
Console.WriteLine(result.RetrievalHits.Count.ToString());
if (result.RetrievalHits != null)
{
foreach (var hit in result.RetrievalHits)
{
Console.WriteLine("\n---");
Console.WriteLine($"Web URL: {hit.WebUrl}");
Console.WriteLine($"Resource Type: {hit.ResourceType}");
if (hit.Extracts != null && hit.Extracts.Any())
{
Console.WriteLine("\nExtracts:");
foreach (var extract in hit.Extracts)
{
Console.WriteLine($" {extract.Text}");
}
}
if (hit.SensitivityLabel != null)
{
Console.WriteLine("\nSensitivity Label:");
Console.WriteLine($" Display Name: {hit.SensitivityLabel.DisplayName}");
Console.WriteLine($" Tooltip: {hit.SensitivityLabel.Tooltip}");
Console.WriteLine($" Priority: {hit.SensitivityLabel.Priority}");
Console.WriteLine($" Color: {hit.SensitivityLabel.Color}");
if (hit.SensitivityLabel.IsEncrypted.HasValue)
{
Console.WriteLine($" Is Encrypted: {hit.SensitivityLabel.IsEncrypted.Value}");
}
}
}
}
else
{
Console.WriteLine("No retrieval hits found in the response");
}
}
}
catch (Exception ex)
{
Console.WriteLine($"Error making retrieval request: {ex.Message}");
Console.Error.WriteLine(ex);
}
Documentation and resources
Issues
To view or log issues, see issues.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Other resources
Building library locally
If you are looking to build the library locally for the purposes of contributing code or running tests, you will need to:
- Have the .NET Core SDK (> 1.0) installed
- Run
dotnet restore
from the command line in your package directory - Run
nuget restore
andmsbuild
from CLI or run Build from Visual Studio to restore Nuget packages and build the project
Run
dotnet build -p:IncludeMauiTargets=true
if you wish to build the MAUI targets for the projects as well.
License
Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT license.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-browser1.0 is compatible. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.6.1)
- Microsoft.IdentityModel.Validators (>= 8.6.1)
- Microsoft.Kiota.Abstractions (>= 1.17.1)
- Microsoft.Kiota.Authentication.Azure (>= 1.17.1)
- Microsoft.Kiota.Http.HttpClientLibrary (>= 1.17.1)
- Microsoft.Kiota.Serialization.Form (>= 1.17.1)
- Microsoft.Kiota.Serialization.Json (>= 1.17.1)
- Microsoft.Kiota.Serialization.Multipart (>= 1.17.1)
- Microsoft.Kiota.Serialization.Text (>= 1.17.1)
- System.Net.Http.WinHttpHandler (>= 6.0.0)
-
.NETStandard 2.0
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.6.1)
- Microsoft.IdentityModel.Validators (>= 8.6.1)
- Microsoft.Kiota.Abstractions (>= 1.17.1)
- Microsoft.Kiota.Authentication.Azure (>= 1.17.1)
- Microsoft.Kiota.Http.HttpClientLibrary (>= 1.17.1)
- Microsoft.Kiota.Serialization.Form (>= 1.17.1)
- Microsoft.Kiota.Serialization.Json (>= 1.17.1)
- Microsoft.Kiota.Serialization.Multipart (>= 1.17.1)
- Microsoft.Kiota.Serialization.Text (>= 1.17.1)
-
.NETStandard 2.1
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.6.1)
- Microsoft.IdentityModel.Validators (>= 8.6.1)
- Microsoft.Kiota.Abstractions (>= 1.17.1)
- Microsoft.Kiota.Authentication.Azure (>= 1.17.1)
- Microsoft.Kiota.Http.HttpClientLibrary (>= 1.17.1)
- Microsoft.Kiota.Serialization.Form (>= 1.17.1)
- Microsoft.Kiota.Serialization.Json (>= 1.17.1)
- Microsoft.Kiota.Serialization.Multipart (>= 1.17.1)
- Microsoft.Kiota.Serialization.Text (>= 1.17.1)
-
net6.0
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.6.1)
- Microsoft.IdentityModel.Validators (>= 8.6.1)
- Microsoft.Kiota.Abstractions (>= 1.17.1)
- Microsoft.Kiota.Authentication.Azure (>= 1.17.1)
- Microsoft.Kiota.Http.HttpClientLibrary (>= 1.17.1)
- Microsoft.Kiota.Serialization.Form (>= 1.17.1)
- Microsoft.Kiota.Serialization.Json (>= 1.17.1)
- Microsoft.Kiota.Serialization.Multipart (>= 1.17.1)
- Microsoft.Kiota.Serialization.Text (>= 1.17.1)
-
net8.0
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.6.1)
- Microsoft.IdentityModel.Validators (>= 8.6.1)
- Microsoft.Kiota.Abstractions (>= 1.17.1)
- Microsoft.Kiota.Authentication.Azure (>= 1.17.1)
- Microsoft.Kiota.Http.HttpClientLibrary (>= 1.17.1)
- Microsoft.Kiota.Serialization.Form (>= 1.17.1)
- Microsoft.Kiota.Serialization.Json (>= 1.17.1)
- Microsoft.Kiota.Serialization.Multipart (>= 1.17.1)
- Microsoft.Kiota.Serialization.Text (>= 1.17.1)
-
net8.0-browser1.0
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.6.1)
- Microsoft.IdentityModel.Validators (>= 8.6.1)
- Microsoft.Kiota.Abstractions (>= 1.17.1)
- Microsoft.Kiota.Authentication.Azure (>= 1.17.1)
- Microsoft.Kiota.Http.HttpClientLibrary (>= 1.17.1)
- Microsoft.Kiota.Serialization.Form (>= 1.17.1)
- Microsoft.Kiota.Serialization.Json (>= 1.17.1)
- Microsoft.Kiota.Serialization.Multipart (>= 1.17.1)
- Microsoft.Kiota.Serialization.Text (>= 1.17.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Microsoft.Agents.M365Copilot.Core:
Package | Downloads |
---|---|
Microsoft.Agents.M365Copilot.Beta
Microsoft 365 Copilot APIs Beta client library enables you to call the Microsoft 365 Copilot APIs in your applications and custom engine agents. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.0-preview.3 | 238 | 7/16/2025 |
1.0.0-preview.2 | 16,804 | 6/12/2025 |