Create a routine

Creates a routine owned by the caller. The example fires on new records of one type whose field matches recordTrigger.query.filters; filters on record.created and record.updated match the resulting record and are rechecked at admission, and the owner's current access is always rechecked. Creation may be refused when the owner has used the plan's per-user routine allowance (409). Requires: create permission on routines.

POST
/v1/routines/create

Authorization

apiKeyAuth
x-api-key<token>

API key authentication. Create an API key in your user profile and include it in the x-api-key header.

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://customermates.com/api/v1/routines/create" \  -H "Content-Type: application/json" \  -d '{    "name": "Brief new enterprise deals",    "prompt": "Summarize the new deal and suggest the next step for its owner.",    "triggerKind": "event",    "triggerEvents": [      "record.created"    ],    "recordTrigger": {      "query": {        "typeId": "6f1d2c3b-4a59-4e8f-8a7b-1c2d3e4f5a6b",        "filters": [          {            "fieldId": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",            "operator": "eq",            "value": {              "kind": "text",              "value": "Enterprise"            }          }        ]      },      "changedFieldIds": []    },    "expectedSchemaRevision": 12  }'
{
  "id": "0b5f3c1e-7a2d-4c8e-9f10-2a3b4c5d6e7f",
  "ownerUserId": "3c2b1a09-8f7e-4d6c-9b5a-4f3e2d1c0b9a",
  "owner": {
    "id": "3c2b1a09-8f7e-4d6c-9b5a-4f3e2d1c0b9a",
    "firstName": "Ada",
    "lastName": "Lovelace",
    "avatarUrl": null,
    "status": "active"
  },
  "name": "Brief new enterprise deals",
  "prompt": "Summarize the new deal and suggest the next step for its owner.",
  "enabled": true,
  "triggerKind": "event",
  "cronExpression": null,
  "timezone": null,
  "triggerEvents": [
    "record.created"
  ],
  "triggerFilters": [],
  "recordTrigger": {
    "query": {
      "typeId": "6f1d2c3b-4a59-4e8f-8a7b-1c2d3e4f5a6b",
      "filters": [
        {
          "fieldId": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
          "operator": "eq",
          "value": {
            "kind": "text",
            "value": "Enterprise"
          }
        }
      ],
      "relationships": []
    },
    "changedFieldIds": []
  },
  "recordSources": null,
  "debounceSeconds": 0,
  "nextRunAt": null,
  "lastRunAt": null,
  "lastRunStatus": null,
  "disabledReason": null,
  "createdAt": "2026-10-12T08:00:00.000Z",
  "updatedAt": "2026-10-12T08:00:00.000Z"
}
{
  "error": {
    "kind": "validation",
    "issues": [
      {
        "code": "string",
        "path": [
          "string"
        ],
        "message": "string",
        "customCode": "recordNotFound",
        "entitlement": "string"
      }
    ],
    "retryable": true
  }
}
{
  "error": {
    "kind": "validation",
    "issues": [
      {
        "code": "string",
        "path": [
          "string"
        ],
        "message": "string",
        "customCode": "recordNotFound",
        "entitlement": "string"
      }
    ],
    "retryable": true
  }
}
{
  "error": {
    "kind": "validation",
    "issues": [
      {
        "code": "string",
        "path": [
          "string"
        ],
        "message": "string",
        "customCode": "recordNotFound",
        "entitlement": "string"
      }
    ],
    "retryable": true
  }
}
{
  "error": {
    "kind": "validation",
    "issues": [
      {
        "code": "string",
        "path": [
          "string"
        ],
        "message": "string",
        "customCode": "recordNotFound",
        "entitlement": "string"
      }
    ],
    "retryable": true
  }
}
{
  "error": {
    "kind": "validation",
    "issues": [
      {
        "code": "string",
        "path": [
          "string"
        ],
        "message": "string",
        "customCode": "recordNotFound",
        "entitlement": "string"
      }
    ],
    "retryable": true
  }
}
{
  "error": {
    "kind": "validation",
    "issues": [
      {
        "code": "string",
        "path": [
          "string"
        ],
        "message": "string",
        "customCode": "recordNotFound",
        "entitlement": "string"
      }
    ],
    "retryable": true
  }
}
{
  "error": {
    "kind": "validation",
    "issues": [
      {
        "code": "string",
        "path": [
          "string"
        ],
        "message": "string",
        "customCode": "recordNotFound",
        "entitlement": "string"
      }
    ],
    "retryable": true
  }
}
Empty