Skip to main content
Create a routine from an existing object — a function (a table) or a workflow. The routine id is built from the type and objectId you pass: e.g. function + tbl_abc becomes function:tbl_abc. Returns the new routine in the same shape as clay routines get; update it later with clay routines update.
clay routines create <type> <objectId> [flags]

Arguments

ArgumentDescription
typeRoutine type. One of function or workflow. Required.
objectIdUnderlying object id — a table id for function, a workflow id for workflow. Required.

Flags

FlagDescription
--name <name>Routine name (6–100 characters).
--description <description>Optional description (max 500 characters).
--entity-type <type>MCP entity type. One of contact or company. Required for function routines; rejected for workflow routines.
--integrations <csv>Integrations to expose the routine on. Comma-separated list of api, mcp, or claygent.

Output

{
  "id": "function:tbl_abc123",
  "type": "function",
  "name": "My contact routine",
  "description": null,
  "entityType": "contact",
  "access": {
    "integrations": ["api", "mcp"]
  }
}
FieldTypeDescription
idstringRoutine id, built as <type>:<objectId>.
type"function" | "workflow"Routine type.
namestringDisplay name.
descriptionstring | nullDescription, or null if not set.
entityType"contact" | "company"MCP entity type. Omitted for workflow routines.
access.integrationsstring[]Integrations the routine is exposed on. Each is api, mcp, or claygent.
inputSchemaobjectInput schema for the routine. Omitted when the routine has none.

Errors

CodeExitNotes
validation_error2Invalid type, missing required flags, --entity-type on a workflow routine, or invalid integration value.
auth_forbidden3The API key lacks the cli:all scope (or all).

Examples

clay routines create function tbl_abc123 --name "My contact routine" --entity-type contact --integrations api,mcp
clay routines create workflow wf_abc123 --name "My workflow routine" --integrations api,mcp
clay routines create function tbl_abc123 --name "My contact routine" --entity-type contact --integrations api,mcp | jq -r '.id'