Automation · IT and security
How to build endpoint alert containment
The laptop was isolated at 2am, the on-call engineer's production access went with it, and nobody told them why. The design behind containment that is fast where it is safe and careful where it isn't, the prompts that build it, and what running it takes.
Built with Tray Headless
- Step EDR alert
- Step Attach device and user
- Step Rule or approver
- System Microsoft Intune
- System Jira
A clear rule decides most detections. Servers, executives and anyone on call go to a person, with the evidence attached, before the device is cut off.
The short answer
What is endpoint alert containment automation?
Endpoint alert containment has four parts: attaching the device's owner, role and recent activity to every serious detection, a written rule that says which detections isolate a device straight away and which wait for a person, containment that covers the account as well as the device, and a release that brings the device and the user back cleanly once the case is closed. The part teams get wrong is the rule. Isolating everything is how a production server or the on-call engineer goes dark at 2am, and isolating nothing is how ransomware gets an hour.
Stage 5 of 7: Endpoint alert containment. Part of Security operations, end to end : every stage, the systems it runs on and the guide that builds it.
What matters here
- Write the rule down: which detections isolate on their own, and which devices always wait for a person.
- Attach the device and the user before deciding. Who owns it and what it runs changes the answer.
- Contain the account too. A cut-off laptop with a working session elsewhere has only moved the problem.
- Tell the user straight away, on a channel that still works. An isolated laptop with no explanation becomes a service desk call.
- Release on purpose, with a check. A device let back on the network without one is a second incident waiting.
Who this is for
You run security operations. Your endpoint tool raises serious detections at all hours, and the team has argued for a year about which ones should isolate on their own.
How it works in practice
From a serious detection on a device to that device being back in use.
- 1
A serious detection arrives from the endpoint tool
Through its connector or its API, with the device, the process and the detection detail.
- 2
The device and the user are attached
Owner, role, whether they are on call, what the device runs, its compliance state in Intune, and recent sign-ins.
- 3
The rule decides, or a person does
Clear detections on ordinary laptops isolate straight away. Servers, executives and on-call engineers go to an approver.
- 4
The device is isolated and the account contained
Network isolation through the endpoint tool, and the user's sessions revoked if the detection points at credentials.
- 5
The user is told, and a case is opened
What happened, what to do next, and how to get a loan device, on their phone or a manager's message.
- 6
Release is a decision with a check
The device is cleaned or rebuilt, checked compliant, and released, with the approver recorded.
What containment is made of
Four parts, and the second is the one the security team and the business have to agree on before anything is built.
Device and user context
Who owns it, what it runs, whether they are on call, its compliance state and recent sign-ins. The rule needs all of it.
A written containment rule
Detections that isolate on their own, devices that always need a person, and who is asked next when the first approver does not answer.
Device and account together
Network isolation for the device, and session revocation for the account when the detection involves credentials.
A clean release
Rebuilt or cleaned, checked compliant, released by a named person, and the user told.
The Tray Headless prompts
Paste these into Claude Code or Codex with the Tray Headless plugin installed. Each stage runs on its own. The systems named in them are the worked example rather than a requirement, and every prompt says so.
Once per project, run
/tray-workflows:set-workspace
to pick the workspace these build in. Point it at a sandbox first.
- 1
Set up, then attach the device and the user
The right action depends on whose device it is and what it runs.
Headless skills
build-workflowUse build-workflow. The systems in play are our endpoint detection tool, Microsoft Intune, Azure Active Directory or Okta, ServiceNow, Slack, Jira and Snowflake, or whatever we run in those seats. Before you plan anything, tell me which of them are already authenticated in the workspace, because I do not want a connector stubbed that I have not authenticated. If the endpoint tool has no connector, reach it through its API with a credential held in the workspace. On every high or critical detection, attach: the device's owner, their role and manager, whether they are on call right now, what the device runs (laptop, server, kiosk), its compliance state in Intune, and the owner's sign-ins in the last 24 hours.
- 2
Write the containment rule as data
Which detections isolate on their own is a decision, not a default.
Headless skills
build-workflowUse build-workflow. Build the rule as a table the security team can edit, not as logic in the workflow: Detections that isolate straight away on an ordinary laptop: for example ransomware behaviour, credential theft tools, known malware Devices that always need a person: servers, executives' devices, anyone on call, shared kiosks How long an approver has before the request goes to the next person on call, per detection For anything that needs a person, post to the on-call analyst in Slack with the detection, the device and the user, and buttons to isolate or hold. Record who decided and when.
Agree the table with IT and the business before you build it. Most arguments about containment are about this table, and they are easier to have before 2am.
- 3
Isolate the device, and contain the account
A cut-off laptop with a working session elsewhere has only moved the problem.
Headless skills
tray-gotchasUse tray-gotchas, then on a decision to contain: Isolate the device from the network through the endpoint tool, keeping its connection to the endpoint tool itself open If the detection involves credentials, revoke the owner's sessions in the identity provider and reset their sign-in methods Mark the device in Intune so it can't reach company apps until released Then open a Jira case with the detection, the context, the decision and every action, and a ServiceNow request for a loan device if the user will be without one for more than a few hours.
- 4
Tell the user on a channel that still works
An isolated laptop with no explanation becomes a service desk call.
The user's laptop is offline, so message them on Slack or Teams on their phone, and copy their manager. Say what happened in plain words, that it is not their fault, what they should not do (sign in somewhere else with the same password), and how to get a loan device. Keep the message short. The case has the detail.
- 5
Release on purpose, with a check
A device let back on without a check is a second incident.
Release only when an analyst marks the case resolved. Before release confirm: the device was cleaned or rebuilt, the endpoint tool shows no active detections, and Intune shows it compliant. Then lift the isolation, clear the Intune mark, tell the user, and close the ServiceNow loan request. Record who released it. Report: detections, share contained on the rule, time from detection to isolation, time an approver took, and devices held more than two days.
- 6
Validate it, then hand the rule to security ops
Because the rule will need changing the first week it runs.
Run the per-step schema checks and the whole-workflow audit before this touches production. Run it for a fortnight with every isolation going to an approver, and compare what the rule would have done with what the analyst chose. Then open the same workflow in Tray Build so security operations can change the containment table, the approver timeouts and the user message in the visual canvas.
What it connects to
The detection comes from the endpoint tool. The device, the account and the user each live somewhere else.
Microsoft Intune
Read the device's owner and compliance state, and mark it so it can't reach company apps until released.
Reads and writes
Azure Active Directory
Revoke the owner's sessions and reset sign-in methods where the detection involves credentials.
Writes
Okta
Resolve the owner, their role and whether they are on call, and revoke sessions where Okta runs sign-in.
Reads and writes
ServiceNow
Raise a loan device request so the user can keep working while their laptop is held.
Writes
Slack
Ask the on-call analyst to approve, and tell the user what happened on a device that still works.
Reads and writes
Jira
Keep one case per device with the detection, the decision, every action and the release.
Writes
Same build, other stacks
The design does not change if you run something else in one of these seats. The same prompts build it against Google BigQuery, Microsoft Teams, Jira Service Desk, Databricks, Google Chat or Zendesk.
Connections in this build
Field mapping, templates and common problems for each pairing: Microsoft Intune + Azure Active Directory, Azure Active Directory + ServiceNow, Okta + ServiceNow and Azure Active Directory + Slack.
Named systems are the ones most teams run, not the only ones that work. Each is an authentication in your Tray workspace, referenced by name, so the workflow never holds a credential. Where we have a connector page, the name links to it.
Running it in production
This takes devices off the network. Fast and wrong is an outage, and slow and right is a breach.
It runs where production runs, not on a laptop
Detections are handled the minute they arrive, at any hour, with every decision and action recorded.
The rule is a table, and it has an owner
Which detections isolate and which devices wait for a person is written down, versioned and owned by security operations.
Managed credentials, not secrets in a config file
A credential that can isolate any device in the company is among the most powerful you hold. It lives in your workspace, scoped and separately rotated.
Servers and on-call engineers always get a person
Cutting them off on a rule can cause the outage you were trying to prevent. They wait for an analyst's yes, and an unanswered request moves to the next person on call.
Approve everything first
Two weeks with every isolation going to an approver, compared against the rule. That record decides what moves to the rule.
Questions people ask
Which detections should isolate a device on their own?
Clear, high-confidence detections on ordinary laptops, such as ransomware behaviour or known credential theft tools. Servers, executives' devices and anyone on call should wait for a person.
Why contain the account as well as the device?
Because a detection involving credentials means the attacker may already have them. Isolating the laptop while the account's sessions keep working elsewhere only moves the problem.
What if our endpoint tool has no Tray connector?
Tray reaches it through its API, with the credential held in your workspace like any other. The rest of the workflow is the same.
How do you tell a user whose laptop is offline?
On their phone, through Slack or Teams, with their manager copied. Say what happened, that it is not their fault, and how to get a loan device.
Can an isolation be undone?
Yes. The device keeps its connection to the endpoint tool while it is isolated, so lifting isolation is one action. The release step does it once the checks pass, and a device isolated in error can be released straight away.
When should a device be released?
When an analyst marks the case resolved and the device is cleaned or rebuilt, shows no active detections, and is compliant again. The person who released it is recorded.
Related guides
IT and security
How to build security alert triage
Enrich before a human sees it, suppress the known-benign, escalate on asset value, and measure what you closed rather than what fired. The prompts.
IT and security
How to build compromised account response
Ask the user about a risky sign-in, revoke every session in every app on a confirmed takeover, and remove what the attacker left behind. The prompts.
IT and security
How to build a device lifecycle sync
Reconcile what management sees against what finance owns and what HR says, and make an unassigned device an exception instead of a row. The prompts.
Last reviewed October 2026.