Language

ApiClient Class

Definition

Top-level API client that provides access to all Teams Bot API sub-clients.

public class ApiClient
type ApiClient = class
Public Class ApiClient
Inheritance
ApiClient

Remarks

This client can be constructed in two ways:

  • DI-friendly (no serviceUrl) — Use Microsoft.Teams.Apps.Clients.ApiClient.#ctor(System.Net.Http.HttpClient,Microsoft.Teams.Core.ConversationClient,Microsoft.Teams.Core.UserTokenClient,Microsoft.Extensions.Logging.ILogger) and call ForServiceUrl(Uri) per-request to create a scoped instance.
  • Fully initialized — Use the internal service-URL constructor when the service URL is known upfront.

Properties

Name Description
AgenticIdentity

The agentic identity used by this client for all operations, or null. Set once at the client level (like ServiceUrl) via ForAgenticIdentity(AgenticIdentity) rather than per method call.

Conversations

Client for conversation operations (activities, members, reactions).

Meetings

Client for meeting operations.

ServiceUrl

The service URL used by this client. Null when constructed without a service URL (DI-friendly constructor). Call ForServiceUrl(Uri) to create a scoped instance with a service URL.

Teams

Client for team operations.

UserToken

Client for user token operations (OAuth SSO, sign-in resources). Lazily created over the underlying Microsoft.Teams.Apps.Clients.ApiClient.UserTokenClient; serviceUrl-independent.

Methods

Name Description
ForActivity(CoreActivity)

Creates a new ApiClient scoped to an inbound activity, binding both the service URL and the agentic identity (from the activity's Recipient) in one call.

ForAgenticIdentity(AgenticIdentity)

Creates a new ApiClient scoped to the specified agentic identity, used for all operations on the returned client (like ServiceUrl).

ForServiceUrl(Uri)

Creates a new ApiClient scoped to the specified service URL, sharing the underlying HTTP client, authentication, and agentic identity.

Applies to