---
title: "Search workflow records"
method: POST
path: "/api/workflow-records/search"
tags: ["workflow_records"]
---

# Search workflow records

`POST /api/workflow-records/search`

## Request

- Base URL: `https://beta.getsales.io/playtables/v1`
- URL: `https://beta.getsales.io/playtables/v1/api/workflow-records/search`
- Auth: HTTP bearer and API key in header `Team-SID`

People-in-workflow rows. Progress board: filter workflow_sid + status; counts.groups.current_step_id = board columns. Person card: filter people_sid ("which workflows is X in"). Staleness sweep: last_touch_at.lte + sort last_touch_at asc; for failed rows read error_code/error_message. include people hydrates names; workflow_tasks_counts = per-record execution shape. No q - resolve names via people search first. page_size:0 = funnel counts only. Adding people = workflow-sources.

Contract:
- MCP tool `search_workflow_records`, registry package `mcp.playtables/workflow_records`, mount `playtables.journeys`.
- Operation `search`, response envelope `search`.
- Flags: read only.

## Request body

- SearchWorkflowRecordsRequest: Request body of `search_workflow_records`.
  - `filter` object: Field filters, ANDed: {field: {eq | ne | in | nin | gte | lte | gt | lt | is_null}}; q inside it is free text. Omit for every row.
    - `sid` object: Prefix-validated wf_rc_ sid(s); also the single-row read (no get tool).
      - `eq` string: Workflow record sid (wf_rc_…).
      - `in` string[]
    - `workflow_sid` object: Progress-board scope (wf_wf_…).
      - `eq` string
      - `in` string[]
    - `workflow_version_sid` object: "Who is still on the old version" (wf_vr_…).
      - `eq` string
      - `in` string[]
    - `people_sid` object: Person card (cr_pp_…); bulk ops take sids from people search first.
      - `eq` string
      - `in` string[]
    - `entered_via_source_sid` object: Per-source cohort (wf_sr_…).
      - `eq` string
      - `in` string[]
    - `sender_profile_sid` object: Per-sender load (ub_sp_…); is_null:true = unpinned (no send steps).
      - `eq` string
      - `in` string[]
      - `is_null` boolean
    - `current_step_id` object: Step column of the board (int step id); meaningful only with a workflow_sid filter.
      - `eq` integer
      - `in` integer[]
    - `status` object
      - `eq` 'waiting_limit' | 'blocked' | 'active' | 'waiting' | 'paused_on_reply' | 'paused_manual' | 'paused_blocked' | 'failed' | 'completed' | 'exited'
      - `ne` 'waiting_limit' | 'blocked' | 'active' | 'waiting' | 'paused_on_reply' | 'paused_manual' | 'paused_blocked' | 'failed' | 'completed' | 'exited'
      - `in` string[]
      - `nin` string[]
    - `last_touch_at` object: Staleness - "no movement since …"; ISO 8601 bounds.
      - `gte` string
      - `lte` string
      - `gt` string
      - `lt` string
    - `finished_at` object: { is_null: true } = live records; datetime bounds = terminal cohort.
      - `gte` string
      - `lte` string
      - `is_null` boolean
    - `created_at` object: Enrollment window; ISO 8601 bounds, combine in one object.
      - `gte` string
      - `lte` string
      - `gt` string
      - `lt` string
    - `deleted_at` object: Default scope is { is_null: true } (live rows); set only by parent cascades.
      - `gte` string
      - `lte` string
      - `is_null` boolean
  - `include` string[]: Relations to attach to every item; omit for the bare rows.
  - `sort` object: One column and its direction; omit for the default order.
    - `field` 'created_at' | 'last_touch_at' | 'finished_at', required: The column to order by.
    - `direction` 'asc' | 'desc': asc or desc; default desc.
  - `page_size` integer: 0..500, default 50; 0 = counts only, 1 = the first row.
  - `cursor` string, nullable: pagination.next_cursor of the previous page.

## Response `200`

`search` success envelope.

- SearchWorkflowRecordsResponse
  - `success` true, required
  - `operation` 'search', required
  - `items` object[], required
    - `item` object, required
      - `sid` string, required
      - `team_sid` string, required
      - `workflow_sid` string, required: wf_wf_… owning workflow; DB-UNIQUE together with people_sid - one row per (workflow, person) pair, forever - see ./workflows.md.
      - `workflow_version_sid` string, required: wf_vr_… version pinned at enrollment - the record executes that step graph even after newer publishes - see ./workflow_versions.md.
      - `people_sid` string, required: cr_pp_… the enrolled person; second half of the DB-UNIQUE pair - see ./people.md.
      - `entered_via_source_sid` string, required: wf_sr_… entry point that produced the row (immutable audit) - see ./workflow_sources.md.
      - `sender_profile_sid` string, nullable, required: ub_sp_… sender pinned at enrollment; null when the version has no send steps; re-resolved at next dispatch if the profile is deleted - see ./sender_profiles.md.
      - `current_step_id` number, required: Small int step id inside the pinned version steps JSON (server-assigned, immutable, never reused) - a JSON node pointer, not a sid or row.
      - `status` 'waiting_limit' | 'blocked' | 'active' | 'waiting' | 'paused_on_reply' | 'paused_manual' | 'paused_blocked' | 'failed' | 'completed' | 'exited', required
      - `entered_at` string, nullable, required
      - `touches_done` integer, required
      - `rotations_done` integer, required
      - `error_code` string, nullable, required: Machine code of the last failure, from the failing task result (max 64).
      - `error_message` string, nullable, required: Human-readable detail of the last failure (max 1024).
      - `last_touch_at` string, required: ISO 8601 UTC - last step advance or status change; the staleness clock.
      - `finished_at` string, nullable, required: ISO 8601 UTC - stamped once when status enters a terminal state; null while live.
      - `created_by` object, required
        - `actor_type` 'user' | 'support' | 'api_key' | 'system' | 'agent', required
        - `actor_sid` string, nullable, required
        - `team_sid` string, required
        - `actor_name` string, nullable: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
        - `oauth_client_sid` string, nullable: The acting OAuth client (id_oc_*); null off the OAuth path.
        - `reason` string, nullable: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
        - `permissions` object, required: Internal audit context: the grant set the actor held at write time. Not a contract.
        - `cluster_id` integer, nullable: Internal audit context: the cluster that served the write.
        - `trace_id` string, nullable: Internal audit context: the trace id of the request that wrote the row.
      - `created_at` string, required
      - `updated_at` string, required
      - `deleted_at` string, nullable, required
    - `included` object, required
      - `people` object: PeopleDomain (1:1 via people_sid) - names/urls for board rendering - see ./people.md.
        - `sid` string, required
      - `workflow` object: WorkflowDomain (1:1 via workflow_sid) - see ./workflows.md.
        - `sid` string, required
      - `sender_profile` object, nullable: SenderProfileDomain (1:1 via sender_profile_sid); null when unpinned - see ./sender_profiles.md.
        - `sid` string, required
      - `workflow_tasks_counts` object: WorkflowTaskCounts computed over { workflow_record_sid: parent.sid } - status/type distribution of this record's tasks without loading rows (§4.17 parent-include) - see ./workflow_tasks.md.
        - `total_count` integer, required
        - `groups` object, required
          - `status` union, required: Funnel by WorkflowTaskStatusEnum - this record's execution shape.
            - object
            - unknown[]
              - …
          - `type` union, required
            - object
            - unknown[]
              - …
  - `pagination` object, required
    - `next_cursor` string, nullable, required
    - `has_more` boolean, required
    - `total_count` integer, nullable, required
  - `applied_filters` object, required
  - `includes` string[], required
  - `meta` object, required
    - `trace_id` string, required: UUID v7; same 128-bit value as the X-Trace-Id header.
    - `span_id` string, required: 16 hex chars, root span of this request.
    - `timestamp` string, required: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
    - `duration_ms` integer, required: Server-side wall clock.
    - `team_sid` string, nullable: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
    - `actor_type` string, nullable: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
  - `counts` object
    - `total_count` integer, required: Records matching the filter scope.
    - `groups` object, required
      - `status` union, required: The funnel axis - map keyed by the 8 WorkflowRecordStatusEnum values.
        - object
        - unknown[]
          - unknown
      - `workflow_sid` union, required: Per-workflow distribution across the team.
        - object
        - unknown[]
          - unknown
      - `current_step_id` union, required: Board columns - keys are STRINGIFIED step ids; read with a workflow_sid filter in scope.
        - object
        - unknown[]
          - unknown
      - `sender_profile_sid` union, required: Per-sender load; "null" bucket = unpinned (no send steps).
        - object
        - unknown[]
          - unknown
      - `entered_via_source_sid` union, required: Per-source funnel.
        - object
        - unknown[]
          - unknown

## Other responses

- `4XX`: MCP error envelope. `error.code` is one of validation_failed, nothing_to_update, not_found, relation_not_found, invalid_transition, limit_exceeded, payment_required, duplicate_rejected, conflict, delete_blocked, unauthorized, forbidden, rate_limited, not_implemented.
- `5XX`: MCP error envelope with `error.code` internal_error or service_unavailable.

---

[API](https://skmtc.dev/getsales/apis/getsales-public-contract-gs-service-playtables.md) - [All operations](https://skmtc.dev/getsales/apis/getsales-public-contract-gs-service-playtables/llms.txt) - [OpenAPI document](https://skmtc.dev/getsales/apis/getsales-public-contract-gs-service-playtables/revisions/aa394506515d?raw)
