Share via


Delete agents programmatically by using the Power Platform API

Copilot Studio provides administrators with robust tools to manage agent security and compliance, including the ability to delete agents through the Power Platform API.

Deleting agents is part of Copilot Studio's broader security framework and works in tandem with your overall security approach in Copilot Studio.

For example, audits, runtime protection, and other admin reports or notifications can flag agents that violate organizational requirements for security and authentication. Admins can use the delete operation to remove noncompliant agents while investigating and remediating security and compliance issues.

When you delete agents, you remove them from your environment. Makers and previous users can no longer see them.

When you delete an agent that has a Microsoft Entra Agent ID, the associated Agent ID (or app registration for legacy agents) is also removed from Microsoft Entra ID. For more information, see Automatically create Microsoft Entra agent identities.

Important

The powervirtualgents namespace is deprecated. Use the copilotstudio namespace in your API calls.

Prerequisites

  • You have the Bot ID and Environment ID for the target agent.
  • You must obtain a user access token issued by Microsoft Entra ID OAuth2. To obtain a token, see Authentication.
    • The user associated with the token must have one of the following admin roles:
      • Global tenant administrator
      • AI administrator
      • Power Platform administrator
    • You must acquire the access token by using the client ID of an app registration that has the CopilotStudio.AdminActions.Invoke scope granted under the Power Platform API.

API operations for agent deletion

Copilot Studio, as part of Power Platform API, supports the REST API delete operation for removing agents.

For more information about how and when to use the Power Platform API, see:

Delete agent

  • Endpoint: DELETE https://api.powerplatform.com/copilotstudio/environments/{EnvironmentId}/bots/{BotId}/api/botAdminOperations?api-version=1
  • Purpose: Permanently delete an agent
  • Response: Returns 204 OK if the agent was deleted successfully

Learn more in Delete Copilot Agent API reference documentation.