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

# Create a new trigger

POST https://api.scoutos.com/v2/triggers
Content-Type: application/json

Reference: https://ref.scoutos.com/api-sdk/endpoints/triggers/create

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Body (application/json)

This endpoint expects a triggers_create_Request.

- `triggers_create_Request`
  - SlackTriggerConfig: SlackTriggerConfig-Input
  - TelegramTriggerConfig: TelegramTriggerConfig
  - CronTriggerConfig: CronTriggerConfig

## Response

### 200

Successful Response

- `data` (Trigger, optional, nullable)

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### SlackTriggerConfig-Input

- `action` (SlackTriggerConfigInputAction, required)
- `trigger_display_name` ("When message is sent to Slack Channel", optional)
- `trigger_type` ("slack.message", optional)
- `status` (enum, optional)
  - Allowed values: `active`, `inactive`
- `run_conditions` (Rules-Input, optional)

### TelegramTriggerConfig

- `action` (TelegramTriggerConfigAction, required)
- `trigger_display_name` (string, optional, nullable)
- `trigger_type` ("telegram.message", optional)
- `status` (enum, optional)
  - Allowed values: `active`, `inactive`
- `connection_id` (string, optional, default: )

### CronTriggerConfig

- `action` (CronTriggerConfigAction, required)
- `cron_expression` (string, required)
- `trigger_display_name` (string, optional, nullable)
- `trigger_type` ("cron", optional)
- `status` (enum, optional)
  - Allowed values: `active`, `inactive`
- `timezone` (string, optional, default: UTC)
- `trigger_inputs` (map from string to any, optional)

### Trigger

- `trigger_config` (TriggerTriggerConfig, required)
- `organization_id` (string, required)
- `trigger_id` (string, required)
- `last_updated_at` (datetime, required)
- `created_at` (datetime, required)
- `revision_id` (string, required)

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### SlackTriggerConfigInputAction

- WorkflowExecute: WorkflowExecute
- SourceSync: SourceSync
- AgentExecute: AgentExecute

### Rules-Input

- `rules` (list of Rule, optional)

### TelegramTriggerConfigAction

- WorkflowExecute: WorkflowExecute
- SourceSync: SourceSync
- AgentExecute: AgentExecute

### CronTriggerConfigAction

- WorkflowExecute: WorkflowExecute
- SourceSync: SourceSync
- AgentExecute: AgentExecute

### TriggerTriggerConfig

- SlackTriggerConfig: SlackTriggerConfig-Output
- TelegramTriggerConfig: TelegramTriggerConfig
- CronTriggerConfig: CronTriggerConfig

### ValidationErrorLocItems

- string
- integer

### WorkflowExecute

- `workflow_id` (string, required)
- `action_type` ("workflow.execute", optional)

### SourceSync

- `sync_id` (string, required)
- `action_type` ("source.sync", optional)

### AgentExecute

- `agent_id` (string, required)
- `action_type` ("agent.execute", optional)
- `additional_instructions` (string, optional, nullable)
- `respond_if_prompt` (string, optional, nullable)
- `include_thread_context` (boolean, optional, default: true)

### Rule

- `conditions` (list of Condition, required)

### SlackTriggerConfig-Output

- `action` (SlackTriggerConfigOutputAction, required)
- `trigger_display_name` ("When message is sent to Slack Channel", optional)
- `trigger_type` ("slack.message", optional)
- `status` (enum, optional)
  - Allowed values: `active`, `inactive`
- `run_conditions` (Rules-Output, optional)

### Condition

- `field` (enum, required)
  - Allowed values: `channel_id`, `team_id`, `user_id`, `thread_id`, `user_message`, `is_first_message_in_thread`, `channel_name`, `bot_is_mentioned`, `is_bot_message`
- `operator` (enum, required)
  - Allowed values: `Any Of`, `None Of`, `Is true`, `Is false`, `Is null`, `Is not null`, `Contains Any Of`, `Contains None Of`
- `value` (list of string, required)

### SlackTriggerConfigOutputAction

- WorkflowExecute: WorkflowExecute
- SourceSync: SourceSync
- AgentExecute: AgentExecute

### Rules-Output

- `rules` (list of Rule, optional)

## Examples

**Request**

```json
{
  "action": {
    "workflow_id": "a1b2c3d4-e5f6-7890-ab12-cd34ef567890"
  }
}
```

**Response**

```json
{
  "data": {
    "trigger_config": {
      "trigger_display_name": "When message is sent to Slack Channel",
      "trigger_type": "slack.message",
      "action": {
        "action_type": "workflow.execute",
        "workflow_id": "a1b2c3d4-e5f6-7890-ab12-cd34ef567890"
      },
      "status": "active",
      "run_conditions": {
        "rules": [
          {
            "conditions": [
              {
                "field": "channel_id",
                "operator": "Any Of",
                "value": [
                  "C1234567890"
                ]
              }
            ]
          }
        ]
      }
    },
    "organization_id": "org-9876543210",
    "trigger_id": "trg-1234567890",
    "last_updated_at": "2024-01-15T09:30:00Z",
    "created_at": "2024-01-15T09:30:00Z",
    "revision_id": "rev-20240115-01"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.scoutos.com/v2/triggers"

payload = { "action": { "workflow_id": "a1b2c3d4-e5f6-7890-ab12-cd34ef567890" } }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```typescript
import { ScoutClient } from "scoutos";

const client = new ScoutClient({ apiKey: "YOUR_API_KEY" });
await client.triggers.create({
    action: {
        action_type: "agent.execute",
        agent_id: "agent_id"
    }
});

```

```go
package main

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

func main() {

	url := "https://api.scoutos.com/v2/triggers"

	payload := strings.NewReader("{\n  \"action\": {\n    \"workflow_id\": \"a1b2c3d4-e5f6-7890-ab12-cd34ef567890\"\n  }\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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://api.scoutos.com/v2/triggers")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"action\": {\n    \"workflow_id\": \"a1b2c3d4-e5f6-7890-ab12-cd34ef567890\"\n  }\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://api.scoutos.com/v2/triggers")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"action\": {\n    \"workflow_id\": \"a1b2c3d4-e5f6-7890-ab12-cd34ef567890\"\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.scoutos.com/v2/triggers', [
  'body' => '{
  "action": {
    "workflow_id": "a1b2c3d4-e5f6-7890-ab12-cd34ef567890"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.scoutos.com/v2/triggers");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"action\": {\n    \"workflow_id\": \"a1b2c3d4-e5f6-7890-ab12-cd34ef567890\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["action": ["workflow_id": "a1b2c3d4-e5f6-7890-ab12-cd34ef567890"]] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.scoutos.com/v2/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()
```