Clay ルーティン — 既存の関数やワークフロー(業務の自動化手順)から定型作業を作成し、このワークペース(作業空間)に保存された定型作業を実行できます。 次のような場合に使用: - ユーザーが定型作業の作成・登録を求めている - 関数、ワークフロー、または定型作業を実行・トリガー(起動)するよう指示されている - 名前または ID で特定の処理を指定してから入力値を渡す - 実行結果や実行状況を確認する 新しいワークフロー全体を構築する場合は、代わりにワークフロー入口スキルを使用してください。
Clay routines — create a routine from an existing function/workflow, then run a saved routine that exists in this workspace. Use when the user asks to create/register a routine, or to run, execute, or trigger a function, workflow, or routine (by name or id), pass it inputs, or check the results/status of a run. For building a new workflow, use the workflows entry-point skill instead.
ルーチンは Clay における実行可能な単位です。このワークスペースに既に存在する保存済みの関数またはワークフローを指します。このスキルは、ルーチンを実行して結果を得ることが目的です。ルーチン自体を作成することではありません。
searches スキルを、保存済みのオーディエンスのメンバーの場合は audiences スキルを使用してから、結果をこちらに渡してください。upsert-audiences-record が含まれているルーチンを実行してください(たとえば、検索結果を保存する場合)。アイテムは他の実行と同じパイプを通し、function:<id> の代わりに workflow:<id> を使用します。そのようなワークフローが存在しない場合は、workflows スキルの audiences.md で作成してから clay routines create workflow を実行してください。public-api スキルを使用してください。ルーチンは非同期で実行されます。実行を開始してから、結果をポーリング(定期的に確認)します。
ルーチン ID を推測しないでください。存在するものをリストアップしてユーザーのリクエストに合致するものを探してください。
clay routines list # このワークスペース内のルーチン
clay routines get <id> # 完全な設定と入力スキーマ
clay routines list はページネーション対応です。ワークスペースには 1 ページより多くのルーチンが存在する可能性があります。--cursor でページを進め、レスポンスに cursor がなくなるまでページをめくり続けてください。ルーチンが存在しないと判断します。各ルーチンはレスポンス内に source フィールドを持ちます。list にはフィルター機能がないため、クライアント側でフィルタリングしてください(例:| jq '.data | map(select(.source == "managed"))')。managed ルーチンは Clay の組み込みエンリッチャー(メールアドレス、ドメイン、企業情報)で、標準的なデータ拡張の第一選択肢です。custom はワークスペースで構築されたものです。名前では判断せず、入力スキーマで決定してください。たとえば、管理下の Work Email ルーチンは「フルネーム」「企業名」「企業ドメイン」が必要なため、企業名だけの場合は先に管理下の Company Domain ルーチンでドメインを解決してください。
実行前に clay routines get <id> を実行することが重要です。ルーチンの入力スキーマが表示され、各アイテムに必要なフィールドが正確にわかります。
clay routines list または clay routines get からユーザーにルーチンを表示するときは、Clay アプリでその基となるオブジェクトを開く画面遷移リンクを提供してください。ユーザーが検査または編集できるようにします。これは Clay タブが開いていないヘッドレス環境(Claude Code、Cursor、シェルなど)で特に重要です。
ルーチン ID はそれがラップするオブジェクトをエンコードしています。function:<tableId> はテーブルをラップし、workflow:<workflowId> はワークフローをラップしています。: の後の ID を分割し、ワークスペース ID(clay whoami | jq -r '.workspace.id')と組み合わせてリンクを構築してください。
function:<tableId>) → https://app.clay.com/workspaces/<workspaceId>/tables/<tableId>workflow:<workflowId>) → https://app.clay.com/workspaces/<workspaceId>/terracotta/tc-workflows/<workflowId>関数ルーチンの場合、list と get の両方が source(Clay が管理するデフォルト関数の場合は managed、このワークスペースで構築されたものの場合は custom)を返し、カスタム関数の場合は createdBy({ id, name, email }、管理下のものは null)も返します。これらを使用して、どの関数が Clay の管理下のものか、チームの独自のものか、またカスタム関数を作成したのは誰かをユーザーに知らせてください(たとえば、source でグループ化するか、似た関数を区別するときに作成者を記載します)。
関数(テーブル)またはワークフローのルーチンがまだ存在しない場合は、create で実行可能なルーチンとして公開してください。これにより、基となるオブジェクトがルーチンとして登録されます。
clay routines create function <tableId> --name "My contact routine" --entity-type contact
clay routines create workflow <workflowId> --name "My workflow routine"
type は function または workflow。objectId はテーブル ID(関数)またはワークフロー ID(ワークフロー)です。--name は両方の種類で必須です。--entity-type(contact または company)は関数ルーチンで必須で、ワークフロールーチンでは拒否されます。function:t_abc。後で clay routines update <id> を使用してルーチンの名前、説明、またはエンティティタイプを変更できます。完全なフラグと JSON 形式については clay routines create --help / clay routines update --help を参照してください。
実行を開始する前に、その推定コストとワークスペースの残高を内部で検査してください。公開およ び確認については、workflows-discover-actions/cost-and-budget.md の共有コストポリシーに従ってください。通常の認可済み実行はコスト確認チェックインを必要としません。
clay routines get function:t_abc123 | jq '.estimatedCreditCost'
clay credits balance | jq '{ balance, actionExecutionBalance }'
2 つの独立した予算があり、実行にはそれぞれ十分な残高が必要です。
estimatedCreditCost.perRun はデータクレジット balance に対して請求されます。estimatedCreditCost.actionExecution(指定されている場合)はアクション実行価格設定プランの別の actionExecutionBalance に対して請求されます。ワークスペースに十分な balance があってもアクション実行の残高がない場合があります。一方の予算に十分でも、もう一方の予算はカバーされません。指定されていない場合、ワークスペースはまだレガシー課金中であり、この残高は無視できます。残高の読み取り方法とコストフィールドの動作について、ヘルプテキストを参照してください。
clay credits balance --help
1 アイテムあたりのコストが設定済みの実行に適用され、すべての関連実行カウントがわかっている場合のみ掛け算してください。ワークフロー推定ではノードを 1 回カウントし、分岐とファンアウト(複数への分散)を省略できます。containsVariablePricing: false は完全性を保証しません。不完全な基本推定値を、概略としてラベル付けしても、合計値には変換しないでください。
いずれかの予算のサポートされた推定合計がその対応する残高を超える場合(perRun × items > balance、または actionExecution × items > actionExecutionBalance)、実行を開始せず、代わりにユーザーに知らせてください。実行は部分的に完了するだけです。
未定義、null、不完全、または適用不可能なコストは不明です。質問された場合、合計を確実に推定できないことを説明してください。そうでない場合は、認可されたスコープ内で続行してください。
サポートされている価格設定で残高不足が表示されている場合、または実際の請求エラーが発生した場合は、credits-quotas-plans スキルを読み、CLI トップアップ、自動トップアップ、請求 UI オプションに従ってください。
非同期実行を開始し、アイテムごとに入力を渡してください。
clay routines runs start <id> # --help でアイテム/入力の渡し方を確認
inputs のセットです。正確なフラグ、入力/JSON 形式、アイテムの提供方法については、clay routines runs start --help を実行してください。
実行は非同期です。手動のポーリングループを作成する代わりに、--wait を使用した単一のブロッキング呼び出しを優先してください。
clay routines runs get <run-id> --wait 60 # 完了/検証失敗/処理失敗またはタイムアウト 60 秒まで定期確認
clay routines runs get <run-id> --bulk --wait 60 # バッチ実行の場合も同様(インライン確認をスキップ)
clay routines runs get <run-id> --wait # 完了/検証失敗/処理失敗まで定期確認(タイムアウトなし)
clay routines runs get <run-id> # 単一リクエスト(in_progress の可能性あり)
clay routines runs get <run-id> --bulk # バッチ実行として検索(フラグのみ、値なし)
clay routines runs list # 最近の実行とそのステータス
JSON の .status をチェックしてから、実行を完了したものとして扱ってください。--wait のみの場合、コマンドは complete、validation_failed、または processing_failed になるまでブロック状態になります。--wait <seconds> の場合、予算がまだ in_progress の間に期限切れになると、コマンドはその最新ステータスで終了コード 0 で終了します。成功を想定しないでください。バッチ実行では、有限の --wait <seconds> をお勧めします。停止されたバッチ実行は in_progress を報告し続けるため、--wait のみだと永遠に待ち続ける可能性があります。
すべてのレスポンスと runs start の出力に inline または bulk の mode が付きます。bulk の場合、runs get で --bulk を渡してから、実行を直接検索してください。モードがわからない場合(渡された実行 ID、または runs list からの実行 ID でモードが報告されない)、--bulk を省略してください。レスポンスがモードを伝えます。
完了したバッチ実行は、インライン data の代わりに resultUrl を報告します。その URL は短期間有効です(数分間)。すぐにダウンロードし、古いリンクを再利用する代わりに runs get --bulk を再実行して新しいリンクを作成してください。結果は実行完了後約 1 日間、取得可能なままです。その後、ID は応答しなくなります。
アイテムごとの結果は、ステータス(complete / failed)と result または error とともに返されます。
clay routines runs get は単一ページのインライン結果を返します。インライン実行は最大 100 アイテムであるため、--limit 100 は 1 ページですべての結果を返します。より小さいページサイズを使用した場合、レスポンスにはより多くの結果がある場合、トップレベルの cursor が含まれます。--cursor で渡して次のページを取得してください。
clay routines --help
clay routines <cmd> --help
A routine is the runnable unit in Clay: a saved function or workflow that already exists in this workspace. This skill is about running an existing routine and getting its results — not building one.
searches skill for net-new people
or companies, or the audiences skill for members of a saved audience, then feed the
results in here.upsert-audiences-record (for example, to persist Search results).
Items pipe in the same as other runs, using workflow:<id> instead of function:<id>.
If no such workflow exists, build it via the workflows skill's
audiences.md, then clay routines create workflow.public-api skill.Routines run asynchronously: you start a run, then poll for results.
Don't assume a routine id. List what exists and match the user's request to one:
clay routines list # routines in this workspace
clay routines get <id> # full config and input schema
clay routines list is paginated — a workspace can have far more routines than one
page. Page through with --cursor until the response has no cursor before concluding a
routine doesn't exist. Each routine carries a source field in the response — list has no
filter flag, so filter client-side (e.g. | jq '.data | map(select(.source == "managed"))').
managed routines are Clay's built-in enrichers
(emails, domains, firmographics) and should be your first choice for standard enrichment;
custom are workspace-built. Decide by input schema, not name — e.g. the managed
Work Email routine needs Full Name + Company Name + Company Domain, so resolve the
domain first with the managed Company Domain routine when you only have a company name.
clay routines get <id> is important before running: it shows the routine's input
schema so you know exactly which fields each item needs.
Whenever you show the user a routine — from clay routines list or clay routines get —
give them a link to open its underlying object in the Clay app so they can inspect or edit
it. This matters most in a headless environment (Claude Code, Cursor, a shell) where the
user has no Clay tab open.
A routine id encodes the object it wraps: function:<tableId> wraps a table,
workflow:<workflowId> wraps a workflow. Split off the id after the : and combine it
with the workspace id (clay whoami | jq -r '.workspace.id') to build the link:
function:<tableId>) → https://app.clay.com/workspaces/<workspaceId>/tables/<tableId>workflow:<workflowId>) → https://app.clay.com/workspaces/<workspaceId>/terracotta/tc-workflows/<workflowId>For function routines, both list and get return a source (managed for a
Clay-managed default function, custom for one built in this workspace) and, for custom
functions, a createdBy ({ id, name, email }; null for managed ones). Use these to tell
the user which functions are Clay-managed vs. their team's own, and who authored a custom
one — e.g. group them by source, or note the author when disambiguating similar functions.
If no routine exists yet for a function (a table) or a workflow, expose it as a runnable
routine with create. This registers the underlying object as a routine.
clay routines create function <tableId> --name "My contact routine" --entity-type contact
clay routines create workflow <workflowId> --name "My workflow routine"
type is function or workflow; objectId is the table id (function) or workflow id.--name is required for both types.--entity-type (contact or company) is required for function routines and rejected
for workflow routines.function:t_abc.Use clay routines update <id> to change a routine's name, description, or entity-type
later. See clay routines create --help / clay routines update --help for the full flags
and JSON shape.
Before starting a run, inspect its estimate and the workspace balance internally. Follow
the shared cost policy in workflows-discover-actions/cost-and-budget.md for disclosure and confirmation; ordinary authorized
runs do not need a cost-only check-in. clay routines get <id> includes a per-item estimate;
clay credits balance returns the remaining balance.
clay routines get function:t_abc123 | jq '.estimatedCreditCost'
clay credits balance | jq '{ balance, actionExecutionBalance }'
There are two independent budgets, and a run needs enough of each:
estimatedCreditCost.perRun is charged against the data-credit balance.estimatedCreditCost.actionExecution (when supplied) is charged against the separate
actionExecutionBalance on action-execution pricing plans. A workspace can have plenty
of balance but no action executions left — enough of one budget does not cover the other. When not supplied the workspace is still on legacy billing and this balance can be ignoredFor how to read the balance and how the cost fields work, see the help text:
clay credits balance --help
Only multiply per-item costs when they apply to the configured execution and all relevant
execution counts are known. Workflow estimates count nodes once and can omit branching
and fan-out; containsVariablePricing: false does not establish completeness. Do not turn
an incomplete base estimate into a total, even by labeling it approximate.
If a supported estimated total for either
budget exceeds its matching balance — perRun × items > balance, or
actionExecution × items > actionExecutionBalance — stop and tell the user instead of
starting a run that will only partially complete.
Undefined, null, incomplete, or inapplicable costs are unknown, not free. If asked, explain that the total cannot be reliably estimated; otherwise continue within the authorized scope.
When supported pricing shows insufficient balance, or a real billing failure occurs, read the
credits-quotas-plans skill and follow it for CLI top-up, auto top-up, and
billing UI options.
Start an async run, passing inputs per item:
clay routines runs start <id> # see --help for how to pass items/inputs
inputs matching the
routine's input schema.Run clay routines runs start --help for the exact flags, the input/JSON shape, and how
to supply items.
Runs are asynchronous. Prefer a single blocking call with --wait instead of hand-rolling a
poll loop:
clay routines runs get <run-id> --wait 60 # poll until complete / validation_failed / processing_failed, or 60s
clay routines runs get <run-id> --bulk --wait 60 # same for a bulk run (skip the inline probe)
clay routines runs get <run-id> --wait # poll until complete / validation_failed / processing_failed (no budget)
clay routines runs get <run-id> # single request (may still be in_progress)
clay routines runs get <run-id> --bulk # look up as a bulk run (bare flag, no value)
clay routines runs list # recent runs and their statuses
Check .status on the JSON before treating the run as done. With bare --wait, the command
blocks until complete, validation_failed, or processing_failed. With --wait <seconds>, if the budget expires
while still in_progress, the command exits 0 with that latest status — do not assume success.
Prefer a bounded --wait <seconds> for bulk runs: a bulk run that was stopped keeps reporting
in_progress, so bare --wait can wait forever.
Every response carries a mode of inline or bulk, and so does the output of
runs start. When it is bulk, pass --bulk on runs get so the run is looked up directly.
If you don't know the mode — a run id you were handed, or one from runs list, which does not
report it — omit --bulk; the response tells you the mode.
A completed bulk run reports a resultUrl rather than inline data. That URL is short-lived
(minutes) — download it promptly, and re-run runs get --bulk to mint a fresh one rather
than reusing a stale link. Results stay retrievable for about a day after the run finishes,
after which the id stops resolving.
Per-item results come back with a status (complete / failed) and either a result
or an error.
clay routines runs get returns a single page of inline results. Since an inline run
has at most 100 items, --limit 100 returns every result in one page. If you use a
smaller page size, the response includes a top-level cursor when more results remain —
pass it back via --cursor to fetch the next page.
clay routines --help
clay routines <cmd> --help
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。