Real Time Response
Real-Time Response (RTR) provides a direct, interactive interface to remote hosts. For automation users, RTR is the primary engine for remote incident response, forensic data collection, and large-scale remediation.
1. Understanding the Three Service Collections
Section titled “1. Understanding the Three Service Collections”RTR is split into three distinct APIs based on the level of authority and the type of data being accessed. Ensure your API Client has the correct Scopes assigned for the endpoints you intend to use.
2. The Automation Lifecycle (Step-by-Step)
Section titled “2. The Automation Lifecycle (Step-by-Step)”Automating RTR requires managing an asynchronous workflow. You cannot simply “run a command”; you must manage the session and poll for results.
Step 1: Initialize the Session
Section titled “Step 1: Initialize the Session”All actions start here. You must exchange a device_id (AID) for a session_id.
Endpoint: POST /real-time-response/entities/sessions/v1
POST /real-time-response/entities/sessions/v1 HTTP/1.1Host: api.crowdstrike.comAuthorization: Bearer `<TOKEN>`Content-Type: application/json
{ "device_id": "89890a8a890a890a890a890a890a890a", "queue_offline": true}- Response:
session_id(used in all subsequent command calls). - Tip: Use
queue_offline: trueso the command executes as soon as an offline host checks in.
Step 2: Dispatch a Command
Section titled “Step 2: Dispatch a Command”Once you have a session_id, send your command. This returns a cloud_request_id.
Endpoint: POST /real-time-response/entities/admin-command/v1
POST /real-time-response/entities/admin-command/v1 HTTP/1.1Host: api.crowdstrike.comAuthorization: Bearer `<TOKEN>`
{ "base_command": "runscript", "command_string": "runscript -CloudMSL='Collect-Logs' -CommandLine='-Target=System'", "session_id": "abc-123-your-session-id"}Step 3: Iterate Until Output is Available (Polling)
Section titled “Step 3: Iterate Until Output is Available (Polling)”Commands are asynchronous. You must poll the status endpoint until the complete flag is true.
Endpoint: GET /real-time-response/entities/admin-command/v1?cloud_request_id={ID}&sequence_id=0
Logic Loop:
- Check
"complete": true. - If
false, wait 1–2 seconds and repeat. - If
true, move to Step 4.
Step 4: Iterating on Chunks (Sequencing)
Section titled “Step 4: Iterating on Chunks (Sequencing)”Large outputs are broken into chunks. If the response contains a next_sequence_id greater than 0, there is more data to fetch.
Logic Loop:
- Read
stdoutfrom the current response. - If
next_sequence_id > 0, call the status endpoint again using that newsequence_id. - Concatenate the output until
next_sequence_idreturns0.
3. Command Capabilities
Section titled “3. Command Capabilities”Investigation (Read-Only)
Section titled “Investigation (Read-Only)”ls: List directory contents.ps: List running processes.netstat: View network connections.filehash: Calculate MD5/SHA256 of a remote file.
Remediation (Active Responder / Admin)
Section titled “Remediation (Active Responder / Admin)”kill: Terminate a process by ID.rm: Delete a malicious file.put/get: Upload a tool to the host or retrieve a file from the host.runscript: Execute a pre-uploaded PowerShell, Bash, or Zsh script.
4. Managing Scripts and Files (RTR Admin)
Section titled “4. Managing Scripts and Files (RTR Admin)”Before using runscript or put, you must manage your library in the Falcon Cloud.
Uploading a Custom Script
Section titled “Uploading a Custom Script”Endpoint: POST /real-time-response/entities/scripts/v1 (Multipart Form Data)
POST /real-time-response/entities/scripts/v1 HTTP/1.1Host: api.crowdstrike.comAuthorization: Bearer `<TOKEN>`Content-Type: multipart/form-data; boundary=boundary
--boundaryContent-Disposition: form-data; name="name"
Remediate.ps1--boundaryContent-Disposition: form-data; name="content"
## Your PowerShell Logic HereStop-Process -Name "malware"--boundary--5. Investigating Past Actions (RTR Audit)
Section titled “5. Investigating Past Actions (RTR Audit)”Use the Audit API to review what actions were taken programmatically or manually.
Endpoint: GET /real-time-response-audit/combined/sessions/v1?with_command_info=true
This returns a list of sessions, including:
user_id: Who (or which API key) started the session.logs: The rawstdoutandstderrof every command executed during that session.cloud_request_ids: A trail of every specific command issued.
⚡ Developer Best Practices
Section titled “⚡ Developer Best Practices”- Always Delete Sessions: When your automation is finished, call
DELETE /real-time-response/entities/sessions/v1?session_id={ID}. Leaving sessions open hits concurrency limits. - Session Pulse: Sessions expire after 10 minutes of inactivity. For long-running scripts, call the
pulse_sessionendpoint to keep the connection alive. - Error Handling: Always check
stderrin the command output. A command can be “complete” but have failed (e.g., “Access Denied”). - Wait Indicators: Implement a back-off strategy for polling (e.g., wait 1s, then 2s, then 5s) to avoid unnecessary API rate-limiting.