> This page is for Itential Platform On-Prem, version 6 (default).
> For other versions, use one of these documentation indexes:
> - 6 (default): https://docs.itential.com/itential-platform/6/llms.txt
> - 2023.2: https://docs.itential.com/itential-platform/2023-2/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.itential.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.itential.com/_mcp/server.

# Create a trigger

POST https://example.itential.io/trigger-service/triggers
Content-Type: application/json

A manual on-demand trigger's `inputs` are cleaned against its form when they're saved. The form is looked up, even for empty `inputs`, and the values it no longer has, such as a removed field or a removed dropdown option, are dropped. The response's `inputs` are what was saved. A manual trigger with no `formId` makes no lookup and saves its `inputs` as sent.

A form that can't be loaded fails the request and nothing is created. The error says why in `formFailure`: 422 NOT_FOUND, 403 FORBIDDEN, 503 UNAVAILABLE.

Reference: https://docs.itential.com/itential-platform/6/api-reference/trigger-service/triggers-create-trigger

## Authentication

- `Authorization` header (basic auth, required) — Basic authentication of the form `Basic <base64(username:password)>`.

## Request

### Body (application/json)

This endpoint expects an object.

- `automationId` (string, required)
- `name` (string, required) — Must contain at least one character that is not whitespace.
- `kind` (enum, required)
  - Allowed values: `on_demand`, `schedule`, `event`
- `description` (string, optional)
- `variant` (enum, optional) — Required when kind === on_demand.
  - Allowed values: `manual`, `api`
- `routeName` (string, optional) — Required when variant === api. Letters of either case, digits, underscores and hyphens; case-sensitive and stored exactly as typed. Rejected when another API Trigger, enabled or disabled, already has it.
- `jst` (string, optional) — Only for variant === api; omit to pass the request body through unchanged.
- `bodySchema` (TriggerServiceTriggersPostRequestBodyContentApplicationJsonSchemaBodySchema, optional) — Only for variant === api. A JSON schema describing the POST body callers send to the endpoint; it is stored as given, and a body that does not match it is rejected when the endpoint is called. A schema that cannot be used (an unknown keyword, a $ref to nothing, an unknown $schema or format, or $async) is rejected with a 400 and the reason.
- `formId` (string, optional) — Id of the form the inputs were filled in on. Only for kind === schedule, or kind === on_demand with variant === manual; omit for a Trigger with no form. For a manual Trigger the form is looked up when the Trigger is created.
- `legacyWrapper` (boolean, optional) — Legacy field, kept only to support workflows written for the old input shape: before July 2023, Operations Manager passed form values to the workflow inside one variable named `formData`. Defaults to false. Turning it on is refused unless the automation's asset is a workflow. Not allowed when variant === api.
- `schedule` (TriggerServiceTriggersPostRequestBodyContentApplicationJsonSchemaSchedule, optional)
- `inputs` (TriggerServiceTriggersPostRequestBodyContentApplicationJsonSchemaInputs, optional) — Required when kind === schedule, or kind === on_demand with variant === manual. For a manual Trigger with a `formId`, the values the form no longer has (a removed field, a removed dropdown option) are dropped when it is saved.
- `source` (string, optional)
- `topic` (string, optional)
- `schema` (TriggerServiceTriggersPostRequestBodyContentApplicationJsonSchemaSchema, optional) — Only for kind === event. A JSON schema the payload of a received event must match. A schema that cannot be used (an unknown keyword, a $ref to nothing, an unknown $schema or format, or $async) is rejected with a 400 and the reason.
- `jstId` (string, optional) — JST id used to turn an event payload into job variables. Event kind only.
- `resourceAction` (TriggerServiceTriggersPostRequestBodyContentApplicationJsonSchemaResourceAction, optional) — Required when the automation targets a resource model, and rejected for any other asset type.

## Response

### 200

result

- `triggerId` (string, required)
- `serviceId` (string, optional) — The Service that exposes the Trigger to end users. Present only for a manual on-demand Trigger; absent for an API on-demand, schedule or event Trigger, which has none.
- `resourceAction` (TriggerServiceTriggersPostResponsesContentApplicationJsonSchemaResourceAction, optional)
- `inputs` (TriggerServiceTriggersPostResponsesContentApplicationJsonSchemaInputs, optional) — The inputs exactly as saved. Present only for a manual on-demand Trigger. When it has a form, these are the inputs sent without the values the form no longer has (a removed field, a removed dropdown option).

## Errors

### 500 Internal Server Error

Error response from API

- `any`

## Types

### TriggerServiceTriggersPostRequestBodyContentApplicationJsonSchemaBodySchema

Only for variant === api. A JSON schema describing the POST body callers send to the endpoint; it is stored as given, and a body that does not match it is rejected when the endpoint is called. A schema that cannot be used (an unknown keyword, a $ref to nothing, an unknown $schema or format, or $async) is rejected with a 400 and the reason.

### TriggerServiceTriggersPostRequestBodyContentApplicationJsonSchemaSchedule

- `recurrence` (TriggerServiceTriggersPostRequestBodyContentApplicationJsonSchemaScheduleRecurrence, optional) — How a recurring schedule repeats. Exclusive with `concreteDate`.
- `startsAt` (string, optional) — A recurring schedule does not fire before this instant. An every-N-seconds-minutes-or-hours schedule with no window and no weekdays counts every gap from it.
- `endsAt` (string, optional) — A recurring schedule does not fire after this instant.
- `maxOccurrences` (double, optional) — End the schedule after this many occurrences, counting every scheduled time including any skipped during downtime. A limit of 1 makes a one-time run. Exclusive with `endsAt`. Recurring schedules only.
- `concreteDate` (string, optional) — One-time firing instant. Exclusive with `recurrence`.

### TriggerServiceTriggersPostRequestBodyContentApplicationJsonSchemaInputs

Required when kind === schedule, or kind === on_demand with variant === manual. For a manual Trigger with a `formId`, the values the form no longer has (a removed field, a removed dropdown option) are dropped when it is saved.

### TriggerServiceTriggersPostRequestBodyContentApplicationJsonSchemaSchema

Only for kind === event. A JSON schema the payload of a received event must match. A schema that cannot be used (an unknown keyword, a $ref to nothing, an unknown $schema or format, or $async) is rejected with a 400 and the reason.

### TriggerServiceTriggersPostRequestBodyContentApplicationJsonSchemaResourceAction

Required when the automation targets a resource model, and rejected for any other asset type.

- `actionId` (string, required) — Id of the Lifecycle Manager action to run: four hexadecimal characters.
- `targetType` (enum, optional) — Whether the target is one instance or a group. Goes with targetIdentifier.
  - Allowed values: `instance`, `group`
- `targetIdentifier` (string, optional) — Name of the target instance or group.
- `chooseTargetAtRuntime` (boolean, optional) — Choose the target each time the Trigger is fired instead of storing one. Only for on-demand Triggers; any target given with it is dropped.

### TriggerServiceTriggersPostResponsesContentApplicationJsonSchemaResourceAction

- `actionId` (string, required)
- `chooseTargetAtRuntime` (boolean, required)
- `targetType` (enum, optional)
  - Allowed values: `instance`, `group`
- `targetIdentifier` (string, optional)

### TriggerServiceTriggersPostResponsesContentApplicationJsonSchemaInputs

The inputs exactly as saved. Present only for a manual on-demand Trigger. When it has a form, these are the inputs sent without the values the form no longer has (a removed field, a removed dropdown option).

### TriggerServiceTriggersPostRequestBodyContentApplicationJsonSchemaScheduleRecurrence

How a recurring schedule repeats. Exclusive with `concreteDate`.

- `kind` (enum, required) — How the schedule repeats: `cron` for a cron expression, `periodic` for every so many seconds, minutes or hours, `daily` for every so many days, `weekly` for chosen weekdays, `monthly` for chosen months and a day within them.
  - Allowed values: `cron`, `periodic`, `daily`, `weekly`, `monthly`
- `cron` (string, optional) — Standard 5-field cron, or 6 with a leading seconds field, evaluated in UTC. Fires no more often than every 10 seconds. Used when `kind` is `cron`.
- `months` (list of double, optional) — Months to fire in, 1 (January) to 12 (December), without repeats. Used when `kind` is `monthly`.
- `on` (TriggerServiceTriggersPostRequestBodyContentApplicationJsonSchemaScheduleRecurrenceOn, optional) — Which day of the month to fire on. Used when `kind` is `monthly`.
- `everyDays` (double, optional) — Days between runs, 1 up to 3650: 1 for every day, 2 for every other day. From 2 up, counting starts on the day of the first run. Used when `kind` is `daily`.
- `everyWeeks` (double, optional) — Weeks between runs, 1 up to 520: 1 for every week, 2 for every other week. Weeks run Sunday to Saturday. From 2 up, counting starts in the week of the first run. Used when `kind` is `weekly`.
- `every` (TriggerServiceTriggersPostRequestBodyContentApplicationJsonSchemaScheduleRecurrenceEvery, optional) — How often to run, in seconds (10 or more), minutes or hours. With no `window` and no `weekdays`, every gap is counted from the start of the schedule. Used when `kind` is `periodic`.
- `window` (TriggerServiceTriggersPostRequestBodyContentApplicationJsonSchemaScheduleRecurrenceWindow, optional) — The stretch of the day to run in. The count restarts at its start each day. Leave out to run through the whole day: with `weekdays` the count restarts at 00:00, and without `weekdays` it never restarts and counts every gap from the start of the schedule. Used when `kind` is `periodic`.
- `weekdays` (list of enum, optional) — Days of the week to run on, without repeats. All seven means every day. Required when `kind` is `weekly`; when `kind` is `periodic`, leave out to run every day.
  - Allowed values: `sun`, `mon`, `tue`, `wed`, `thu`, `fri`, `sat`
- `at` (string, optional) — Time of day in UTC, written HH:mm on a 24-hour clock. Used when `kind` is `daily`, `weekly` or `monthly`.

### TriggerServiceTriggersPostRequestBodyContentApplicationJsonSchemaScheduleRecurrenceOn

Which day of the month to fire on. Used when `kind` is `monthly`.

- `kind` (enum, required) — How the day is chosen: `dayOfMonth` for a fixed date, `nthWeekday` for a counted weekday such as the first Tuesday, `lastDay` for the last day of the month.
  - Allowed values: `dayOfMonth`, `nthWeekday`, `lastDay`
- `day` (double, optional) — Day of the month, 1 to 31. A month too short for it uses its last day. Used when `kind` is `dayOfMonth`.
- `ordinal` (enum, optional) — Which occurrence of the weekday in the month: `first` to `fourth`, or `last`. Used when `kind` is `nthWeekday`.
  - Allowed values: `first`, `second`, `third`, `fourth`, `last`
- `weekday` (enum, optional) — Day of the week. Used when `kind` is `nthWeekday`.
  - Allowed values: `sun`, `mon`, `tue`, `wed`, `thu`, `fri`, `sat`

### TriggerServiceTriggersPostRequestBodyContentApplicationJsonSchemaScheduleRecurrenceEvery

How often to run, in seconds (10 or more), minutes or hours. With no `window` and no `weekdays`, every gap is counted from the start of the schedule. Used when `kind` is `periodic`.

- `quantity` (double, required) — How many seconds, minutes or hours between runs, 1 or more. Counted in seconds, at least 10, the same minimum as a cron expression.
- `unit` (enum, required) — Whether `quantity` counts `seconds`, `minutes` or `hours`.
  - Allowed values: `seconds`, `minutes`, `hours`

### TriggerServiceTriggersPostRequestBodyContentApplicationJsonSchemaScheduleRecurrenceWindow

The stretch of the day to run in. The count restarts at its start each day. Leave out to run through the whole day: with `weekdays` the count restarts at 00:00, and without `weekdays` it never restarts and counts every gap from the start of the schedule. Used when `kind` is `periodic`.

- `from` (string, required) — When the window opens each day, in UTC, written HH:mm on a 24-hour clock. The first run of each day is at this time.
- `to` (string, required) — When the window closes, in UTC, written HH:mm. A run at exactly this time is included. A time earlier than `from` closes the window the next morning.

## Examples

**Request**

```json
{
  "automationId": "string",
  "name": "string",
  "kind": "on_demand"
}
```

**Response**

```json
{
  "triggerId": "string",
  "serviceId": "string",
  "resourceAction": {
    "actionId": "string",
    "chooseTargetAtRuntime": true,
    "targetType": "instance",
    "targetIdentifier": "string"
  },
  "inputs": {}
}
```

**SDK Code**

```python
import requests

url = "https://example.itential.io/trigger-service/triggers"

payload = {
    "automationId": "string",
    "name": "string",
    "kind": "on_demand"
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://example.itential.io/trigger-service/triggers';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"automationId":"string","name":"string","kind":"on_demand"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://example.itential.io/trigger-service/triggers"

	payload := strings.NewReader("{\n  \"automationId\": \"string\",\n  \"name\": \"string\",\n  \"kind\": \"on_demand\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://example.itential.io/trigger-service/triggers")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"automationId\": \"string\",\n  \"name\": \"string\",\n  \"kind\": \"on_demand\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://example.itential.io/trigger-service/triggers")
  .header("Content-Type", "application/json")
  .body("{\n  \"automationId\": \"string\",\n  \"name\": \"string\",\n  \"kind\": \"on_demand\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://example.itential.io/trigger-service/triggers', [
  'body' => '{
  "automationId": "string",
  "name": "string",
  "kind": "on_demand"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://example.itential.io/trigger-service/triggers");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"automationId\": \"string\",\n  \"name\": \"string\",\n  \"kind\": \"on_demand\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "automationId": "string",
  "name": "string",
  "kind": "on_demand"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://example.itential.io/trigger-service/triggers")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```