# Delete Record — Elastic Security

> Permanently delete an Elastic Security case or detection rule by ID. Cases are deleted via DELETE /api/cases; detection rules via DELETE /api/detection_engine/rules. Run Find Cases or Find Detection Rules first to obtain a valid ID for the…

- Key: `elastic_security-delete-record`
- Type: Action (Write)
- Version: 0.0.1
- App: Elastic Security (`elastic_security`) — https://pipedream.com/apps/elastic-security.md
- This page (HTML): https://pipedream.com/apps/elastic-security/actions/delete-record
- Hints: destructive · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/elastic_security/actions/delete-record/delete-record.mjs

## Description

Permanently delete an Elastic Security case or detection rule by ID. Cases are deleted via DELETE /api/cases; detection rules via DELETE /api/detection_engine/rules. Run **Find Cases** or **Find Detection Rules** first to obtain a valid ID for the object you want to delete. Example: calling with `objectType: "case"` and `recordId: "a1c1..."` returns `{ success: true, objectType: "case", recordId: "a1c1..." }`. This is destructive and cannot be undone. [See the delete case documentation](https://www.elastic.co/docs/api/doc/kibana/operation/operation-deletecasedefaultspace) and the [delete rule documentation](https://www.elastic.co/docs/api/doc/kibana/operation/operation-deleterule)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `objectType` | `string` | Yes | The type of object to delete. |
| `recordId` | `string` | Yes | The ID of the object to delete. For a case, its case ID from Find Cases (e.g. a1c10c9b-8448-483a-81f7-a4b3225eb6b8). For a detection rule, its Kibana internal UUID from Find Detection Rules' id field (e.g. 7ac3c66d-f0b4-4f7c-a576-7bb91bf4e9ce) — not the user-defined rule_id. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "elastic_security",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "elastic_security-delete-record",
  arguments: {
    objectType: "Object Type",
    recordId: "Record ID",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "elastic_security-delete-record",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    elastic_security: { authProvisionId: "apn_xxxxxxx" },
    objectType: "Object Type",
    recordId: "Record ID",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "elastic_security-delete-record",
    "configured_props": {
      "elastic_security": { "authProvisionId": "apn_xxxxxxx" },
      "objectType": "Object Type",
      "recordId": "Record ID"
    }
  }'
```

---

- App: https://pipedream.com/apps/elastic-security.md · All apps: https://pipedream.com/apps
