AI Routines

Create a routine

Changed on

Create a routine that runs a saved prompt on a schedule and delivers the AI response through a single destination — email (one or more recipients / user groups), Slack (a single channel or direct message), or a webhook (a public HTTPS URL each run is posted to as JSON). Each scheduled run executes once using the routine owner's permissions, and every recipient receives the same result. Supply condition to deliver only when a stated condition holds. Omni returns the authored semantic query and verifies it once before creation to establish the initial comparison baseline. Organization API keys can pass ?userId=<userId> to create the routine for a specific organization member.

post/api/v1/ai/routines

Request

  • Base URL
    https://omniapp.co (the document declares no server; this is the origin it was published from)
  • URL
    https://omniapp.co/api/v1/ai/routines
  • Auth
    HTTP bearer

Query parameters

userIdstring uuid

Target user ID (for org-scoped API keys)

Request body

branchIdstring uuid

Optional branch ID for the model. Must be a branch of the shared model specified by modelId.

descriptionstring

Optional human-readable notes about the routine. Display-only — never used as model input.

modelIdstring uuid required

The UUID of the model the prompt runs against. Must be a shared model, or a shared-extension model usable as a workbook base.

namestring required

Customer-visible name of the routine. Used as the email subject for email destinations, shown on Slack deliveries, and sent as name in webhook payloads.

promptstring required

Natural language prompt Omni runs on each scheduled run. A /identifier in it runs that saved skill, resolved as the routine owner when the routine fires.

schedulestring required

Six-field cron expression (minute, hour, day-of-month, month, day-of-week, year; use ? for an unspecified day field). Minimum frequency is once per hour; contact Omni support if you need more frequent scheduling.

timezonestring required

IANA timezone identifier used to evaluate the schedule.

topicNamestring

Topic name to scope query generation. If omitted, the AI picks the best topic.

Example request

{
  "branchId": "550e8400-e29b-41d4-a716-446655440000",
  "description": "Weekly signups summary for the growth team.",
  "modelId": "770e8400-e29b-41d4-a716-446655440002",
  "name": "Weekly user signups",
  "prompt": "How many users signed up last week?",
  "schedule": "0 9 ? * MON *",
  "timezone": "America/New_York",
  "topicName": "users",
  "condition": {
    "conditionPrompt": "there are failed orders"
  },
  "destination": {
    "recipientEmails": [
      "alice@example.com",
      "bob@example.com"
    ],
    "type": "email",
    "userGroupIds": [
      "X9kQ2mPz"
    ]
  }
}

Response

Routine created successfully.

idstring uuid required

The unique identifier for the newly created routine.

Example response

{
  "condition": {
    "conditionPrompt": "there are failed orders",
    "conditionType": "RESULTS_PRESENT",
    "query": {
      "aiGenerated": true,
      "calculations": [],
      "column_totals": {},
      "fields": [
        "orders.id"
      ],
      "fill_fields": [],
      "filters": {
        "orders.status": {
          "case_insensitive": true,
          "kind": "EQUALS",
          "type": "string",
          "values": [
            "failed"
          ]
        }
      },
      "limit": 1,
      "modelId": "770e8400-e29b-41d4-a716-446655440002",
      "pivots": [],
      "row_totals": {},
      "sorts": [],
      "table": "orders",
      "userEditedSQL": "SELECT ${orders.id}\nFROM ${orders}\nWHERE UPPER(${orders.status}) = UPPER('failed')\nLIMIT 1",
      "version": 9
    }
  },
  "id": "880e8400-e29b-41d4-a716-446655440003"
}

Changes

    • info

      added webhook discriminator mapping keys to the request property

    • info

      added to the request property oneOf list

    • breaking

      the ////// request property's minLength was increased from 0 to 1

    • info

      the ////// request property format was generalized from uuid to no format