Create a trigger in a workspace
Requires workspaces:write and agents:read. A key may create time (schedule) triggers only — webhook and api triggers are a 403. workspace_agent_id must name an agent installed in this workspace. The key is recorded as the trigger’s creator. See Schedule triggers.
curl --request POST \
--url https://api.guild.ai/v1/workspaces/{workspace_id_or_name}/triggers \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"workspace_agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "time",
"agent_input": {},
"time_of_day": "<string>",
"days_of_week": "<string>",
"days_of_month": "<string>",
"minutes_of_hour": "<string>",
"cron_expression": "<string>",
"cron_timezone": "<string>"
}
'import requests
url = "https://api.guild.ai/v1/workspaces/{workspace_id_or_name}/triggers"
payload = {
"workspace_agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "time",
"agent_input": {},
"time_of_day": "<string>",
"days_of_week": "<string>",
"days_of_month": "<string>",
"minutes_of_hour": "<string>",
"cron_expression": "<string>",
"cron_timezone": "<string>"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
workspace_agent_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
type: 'time',
agent_input: {},
time_of_day: '<string>',
days_of_week: '<string>',
days_of_month: '<string>',
minutes_of_hour: '<string>',
cron_expression: '<string>',
cron_timezone: '<string>'
})
};
fetch('https://api.guild.ai/v1/workspaces/{workspace_id_or_name}/triggers', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.guild.ai/v1/workspaces/{workspace_id_or_name}/triggers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'workspace_agent_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'type' => 'time',
'agent_input' => [
],
'time_of_day' => '<string>',
'days_of_week' => '<string>',
'days_of_month' => '<string>',
'minutes_of_hour' => '<string>',
'cron_expression' => '<string>',
'cron_timezone' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.guild.ai/v1/workspaces/{workspace_id_or_name}/triggers"
payload := strings.NewReader("{\n \"workspace_agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"type\": \"time\",\n \"agent_input\": {},\n \"time_of_day\": \"<string>\",\n \"days_of_week\": \"<string>\",\n \"days_of_month\": \"<string>\",\n \"minutes_of_hour\": \"<string>\",\n \"cron_expression\": \"<string>\",\n \"cron_timezone\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.guild.ai/v1/workspaces/{workspace_id_or_name}/triggers")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"workspace_agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"type\": \"time\",\n \"agent_input\": {},\n \"time_of_day\": \"<string>\",\n \"days_of_week\": \"<string>\",\n \"days_of_month\": \"<string>\",\n \"minutes_of_hour\": \"<string>\",\n \"cron_expression\": \"<string>\",\n \"cron_timezone\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.guild.ai/v1/workspaces/{workspace_id_or_name}/triggers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"workspace_agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"type\": \"time\",\n \"agent_input\": {},\n \"time_of_day\": \"<string>\",\n \"days_of_week\": \"<string>\",\n \"days_of_month\": \"<string>\",\n \"minutes_of_hour\": \"<string>\",\n \"cron_expression\": \"<string>\",\n \"cron_timezone\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}Authorizations
Account API key: key id as the username, secret as the password.
Path Parameters
Body
The installed workspace agent the trigger runs.
time HOURLY, DAILY, WEEKLY, MONTHLY, CRON The fixed input the agent receives each time the trigger fires.
Time of day in ISO format, such as 09:00. Used by DAILY, WEEKLY, and MONTHLY.
Comma-separated day names, such as monday,thursday. Used by WEEKLY.
Comma-separated days from 1 to 31, or -1 for the last day of the month. Used by MONTHLY.
Comma-separated minutes from 0 to 59.
A five-field cron expression, such as 0 9 * * 1-5. Required for CRON and rejected for other frequencies.
An IANA timezone name for cron_expression, such as America/Los_Angeles. Valid only for CRON.
Response
The created trigger
The response is of type object.
curl --request POST \
--url https://api.guild.ai/v1/workspaces/{workspace_id_or_name}/triggers \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"workspace_agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "time",
"agent_input": {},
"time_of_day": "<string>",
"days_of_week": "<string>",
"days_of_month": "<string>",
"minutes_of_hour": "<string>",
"cron_expression": "<string>",
"cron_timezone": "<string>"
}
'import requests
url = "https://api.guild.ai/v1/workspaces/{workspace_id_or_name}/triggers"
payload = {
"workspace_agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "time",
"agent_input": {},
"time_of_day": "<string>",
"days_of_week": "<string>",
"days_of_month": "<string>",
"minutes_of_hour": "<string>",
"cron_expression": "<string>",
"cron_timezone": "<string>"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
workspace_agent_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
type: 'time',
agent_input: {},
time_of_day: '<string>',
days_of_week: '<string>',
days_of_month: '<string>',
minutes_of_hour: '<string>',
cron_expression: '<string>',
cron_timezone: '<string>'
})
};
fetch('https://api.guild.ai/v1/workspaces/{workspace_id_or_name}/triggers', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.guild.ai/v1/workspaces/{workspace_id_or_name}/triggers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'workspace_agent_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'type' => 'time',
'agent_input' => [
],
'time_of_day' => '<string>',
'days_of_week' => '<string>',
'days_of_month' => '<string>',
'minutes_of_hour' => '<string>',
'cron_expression' => '<string>',
'cron_timezone' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.guild.ai/v1/workspaces/{workspace_id_or_name}/triggers"
payload := strings.NewReader("{\n \"workspace_agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"type\": \"time\",\n \"agent_input\": {},\n \"time_of_day\": \"<string>\",\n \"days_of_week\": \"<string>\",\n \"days_of_month\": \"<string>\",\n \"minutes_of_hour\": \"<string>\",\n \"cron_expression\": \"<string>\",\n \"cron_timezone\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.guild.ai/v1/workspaces/{workspace_id_or_name}/triggers")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"workspace_agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"type\": \"time\",\n \"agent_input\": {},\n \"time_of_day\": \"<string>\",\n \"days_of_week\": \"<string>\",\n \"days_of_month\": \"<string>\",\n \"minutes_of_hour\": \"<string>\",\n \"cron_expression\": \"<string>\",\n \"cron_timezone\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.guild.ai/v1/workspaces/{workspace_id_or_name}/triggers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"workspace_agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"type\": \"time\",\n \"agent_input\": {},\n \"time_of_day\": \"<string>\",\n \"days_of_week\": \"<string>\",\n \"days_of_month\": \"<string>\",\n \"minutes_of_hour\": \"<string>\",\n \"cron_expression\": \"<string>\",\n \"cron_timezone\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}