Skip to content

Copilot Studio runtime protection

Preloop can act as the external threat detection provider for Microsoft Copilot Studio. With it connected, Copilot Studio asks Preloop before every tool call of a generative agent, and Preloop answers allow or block using the same tool rules, approvals and audit trail as your other agents.

This is an Enterprise feature. Microsoft's interface is in preview, and only agents with generative orchestration call the provider; classic agents do not.

What happens on a tool call

  1. Copilot Studio sends the tool name, its input values and the conversation metadata to Preloop, signed in with an Entra ID token.
  2. Preloop checks the token, records the agent once (it appears in Agents with kind copilot_studio) and evaluates your rules for that tool.
  3. Preloop answers within one second:
Outcome Answer Reason code
Allowed allow
A deny rule matched block, with the rule's description 1001
A rule requires approval, request created now block 1002
The same call is already waiting for approval block 1003
The tool is unknown and your account defaults deny unknown tools block 1004
Preloop could not decide in time (700 ms) block, or allow if configured 1005
The agent's tenant or environment is not covered by the integration block 1006
A new agent would exceed your plan's agent limit block 1007

Approvals

Copilot Studio cannot wait for a person, so an approval works as block, then retry:

  1. The first call is blocked and one approval request is sent to your approvers, with the tool name and arguments.
  2. Until someone decides, the same call is blocked as pending. No second request is created.
  3. After approval, the next identical call (same agent, tool and arguments) is allowed once. The call after that asks again.
  4. A declined, cancelled or expired request never allows a call. A call with different arguments never uses another call's approval. An approval older than grant_max_age_seconds (default one hour) is not used.

Rules

Write rules for the tool name Copilot Studio reports (for example Send-an-email). Conditions can use the tool's input values as args, and two planner values:

  • planner.user_message: the user's message that led to the call.
  • planner.thought: the agent's stated reason for the call.

Example: deny any email with a Bcc recipient: has(args.bcc).

The planner values are used only while the rule runs. Preloop never stores or logs the user message, the chat history or earlier tool outputs. The audit row written for every allow or block answer records the tool, verdict, reason code, deciding rule, Microsoft's plan step id, a one-way digest of the conversation id and the latency.

Set up

You need: a Preloop administrator with the Manage policies permission, a Microsoft Entra administrator, and a Power Platform administrator.

1. Register an Entra application

Copilot Studio authenticates to the provider with a token issued to an application in your tenant, obtained through a federated identity credential.

  1. In the Microsoft Entra admin center, create an app registration (single tenant). Copy the Application (client) ID and the Directory (tenant) ID.
  2. Under Expose an API, set the Application ID URI to your Preloop base URL (for example https://preloop.example.com). Microsoft requests a token for a scope equal to the provider's base URL.
  3. Under Certificates & secrets > Federated credentials, add the credential Microsoft's guide for external threat detection describes, with the issuer and subject it gives for your Power Platform environment.

2. Create the integration in Preloop

The server operator enables the feature with PRELOOP_COPILOT_STUDIO_RUNTIME_ENABLED=true. Then:

curl -X POST https://preloop.example.com/api/v1/copilot-studio/runtime \
  -H "Authorization: Bearer $PRELOOP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "expected_tenant_id": "<directory tenant id>",
    "expected_client_app_id": "<application client id>",
    "audience": "https://preloop.example.com",
    "environment_ids": [],
    "enabled": true,
    "on_internal_error": "block",
    "grant_max_age_seconds": 3600
  }'

The answer contains endpoint_path, for example /api/v1/copilot-studio/runtime/callback/<integration id>. The endpoint link for Power Platform is your Preloop base URL followed by that path.

Setting Meaning
expected_tenant_id Only tokens from this Entra tenant are accepted.
expected_client_app_id Only tokens issued to this application (azp or appid) are accepted.
audience The token audience Preloop requires.
environment_ids When not empty, only these Power Platform environments are covered; others are blocked with 1006.
enabled New integrations are disabled until you enable them.
on_internal_error block (default) or allow when Preloop cannot decide within 700 ms.
grant_max_age_seconds How long an approval can be used by the retry (60 to 86400).

Other routes: GET (list), GET /{id}, PUT /{id}, POST /{id}/disable, GET /{id}/health. Device-scoped API keys cannot use them.

3. Connect in the Power Platform admin center

In the Power Platform admin center, open the threat detection settings for the environment (Microsoft's guide names the exact place for your tenant), choose an external provider, and enter:

  • the Entra application (client) ID from step 1;
  • the endpoint link from step 2.

Power Platform calls validate on the endpoint when you save; it succeeds when the token is valid and the integration is enabled.

Errors

HTTP errorCode Cause
401 2003 Missing, unsigned, expired or foreign token (wrong audience, tenant or application).
400 4001 A required field is missing (the message names it).
400 4000 The body is not a JSON object.
404 4040 The integration does not exist or is disabled.
429 4290 analyze-tool-execution only: too many calls in flight on this Preloop process; retry.
503 5030 Entra ID signing keys could not be fetched or checked in time; retry. The call is never allowed in this case, whatever on_internal_error says.

Unknown api-version values and unknown fields are accepted.

Turning it off

  • Disable the integration (POST /{id}/disable); calls then get 404.
  • Or unset PRELOOP_COPILOT_STUDIO_RUNTIME_ENABLED; the routes disappear.
  • In the Power Platform admin center, disconnect the provider.

What Copilot Studio does when the provider answers with an error or not at all is decided by Microsoft, not Preloop.

Limits

  • Preview interface from Microsoft; fields and behaviour may change.
  • Only tool calls are checked. Copilot Studio sends no call after a tool runs, so tool outputs and model responses are not inspected.
  • Agents appear in Preloop after their first tool call.
  • The first call after a server start may take longer while Entra signing keys are fetched; if that exceeds 700 ms, the call is answered 503 (5030). on_internal_error applies only after the token is verified.
  • Not yet confirmed on a live tenant: which token version Microsoft sends (azp or appid, both accepted), the exact audience value, and whether the endpoint link may contain a path.