# Search Log Events — Papertrail

> Search Papertrail log events programmatically. Supports query syntax, system/group scope, time or ID bounds, limit, and tail mode. See the documentation

- Key: `papertrail-search-events`
- Type: Action (Read-only)
- Version: 0.0.2
- App: Papertrail (`papertrail`) — https://pipedream.com/apps/papertrail.md
- This page (HTML): https://pipedream.com/apps/papertrail/actions/search-events
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/papertrail/actions/search-events/search-events.mjs

## Description

Search Papertrail log events programmatically. Supports query syntax, system/group scope, time or ID bounds, limit, and tail mode. [See the documentation](https://www.papertrail.com/help/search-api/)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `q` | `string` | No | Search query (Papertrail search syntax). Omit to return recent events. |
| `systemId` | `string` | No | Papertrail system ID Options are loaded from the connected account. |
| `groupId` | `string` | No | The ID of the group Options are loaded from the connected account. |
| `minId` | `string` | No | Oldest message ID to examine (64-bit ID as string). |
| `maxId` | `string` | No | Newest message ID to examine. |
| `minTime` | `integer` | No | Oldest timestamp to examine (epoch seconds, UTC). |
| `maxTime` | `integer` | No | Newest timestamp to examine (epoch seconds, UTC). |
| `limit` | `integer` | No | Maximum messages to return (default 1000, max 10,000). |
| `tail` | `boolean` | No | When true, prioritizes recency (useful for live tail). Defaults to true when min_id is set without max_id/max_time on the API side. |

## 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": "papertrail",
      },
    },
  },
)

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: "papertrail-search-events",
  arguments: {
    q: "Query",
    systemId: "System 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: "papertrail-search-events",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    papertrail: { authProvisionId: "apn_xxxxxxx" },
    q: "Query",
    systemId: "System 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": "papertrail-search-events",
    "configured_props": {
      "papertrail": { "authProvisionId": "apn_xxxxxxx" },
      "q": "Query",
      "systemId": "System ID"
    }
  }'
```

---

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