Workflows
Create a workflow goal
Creates a goal and starts its first run for immediate goals, or creates its schedule for recurring goals.
POST
/
api
/
v1
/
tenant
/
automation
/
goals
Create a workflow goal
curl --request POST \
--url https://api.costgraph.ai/api/v1/tenant/automation/goals \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--header 'X-CostGraph-Tenant-ID: <x-costgraph-tenant-id>' \
--data '
{
"name": "<string>",
"objective": "<string>",
"autonomy_envelope": {},
"budgets": {},
"constraints": {},
"max_decisions": 100,
"scope": {},
"trigger": {},
"trigger_policy": {}
}
'import requests
url = "https://api.costgraph.ai/api/v1/tenant/automation/goals"
payload = {
"name": "<string>",
"objective": "<string>",
"autonomy_envelope": {},
"budgets": {},
"constraints": {},
"max_decisions": 100,
"scope": {},
"trigger": {},
"trigger_policy": {}
}
headers = {
"X-CostGraph-Tenant-ID": "<x-costgraph-tenant-id>",
"Idempotency-Key": "<idempotency-key>",
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-CostGraph-Tenant-ID': '<x-costgraph-tenant-id>',
'Idempotency-Key': '<idempotency-key>',
Authorization: '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: '<string>',
objective: '<string>',
autonomy_envelope: {},
budgets: {},
constraints: {},
max_decisions: 100,
scope: {},
trigger: {},
trigger_policy: {}
})
};
fetch('https://api.costgraph.ai/api/v1/tenant/automation/goals', 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.costgraph.ai/api/v1/tenant/automation/goals",
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([
'name' => '<string>',
'objective' => '<string>',
'autonomy_envelope' => [
],
'budgets' => [
],
'constraints' => [
],
'max_decisions' => 100,
'scope' => [
],
'trigger' => [
],
'trigger_policy' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>",
"X-CostGraph-Tenant-ID: <x-costgraph-tenant-id>"
],
]);
$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.costgraph.ai/api/v1/tenant/automation/goals"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"objective\": \"<string>\",\n \"autonomy_envelope\": {},\n \"budgets\": {},\n \"constraints\": {},\n \"max_decisions\": 100,\n \"scope\": {},\n \"trigger\": {},\n \"trigger_policy\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-CostGraph-Tenant-ID", "<x-costgraph-tenant-id>")
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("Authorization", "<api-key>")
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.costgraph.ai/api/v1/tenant/automation/goals")
.header("X-CostGraph-Tenant-ID", "<x-costgraph-tenant-id>")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"objective\": \"<string>\",\n \"autonomy_envelope\": {},\n \"budgets\": {},\n \"constraints\": {},\n \"max_decisions\": 100,\n \"scope\": {},\n \"trigger\": {},\n \"trigger_policy\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.costgraph.ai/api/v1/tenant/automation/goals")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-CostGraph-Tenant-ID"] = '<x-costgraph-tenant-id>'
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"objective\": \"<string>\",\n \"autonomy_envelope\": {},\n \"budgets\": {},\n \"constraints\": {},\n \"max_decisions\": 100,\n \"scope\": {},\n \"trigger\": {},\n \"trigger_policy\": {}\n}"
response = http.request(request)
puts response.read_body{
"message": "some message",
"status": "success",
"data": {
"goal_id": "<string>",
"goal_revision_id": "<string>",
"goal_status": "active",
"status": "<string>",
"run": {
"goal_id": "<string>",
"goal_revision_id": "<string>",
"run_id": "<string>",
"status": "<string>",
"workflow_id": "<string>"
},
"run_id": "<string>",
"schedule": {
"kind": "once",
"state": "armed",
"cadence": "<string>",
"last_fired_at": "<string>",
"localTime": "<string>",
"monthWeek": 123,
"next_run_at": "<string>",
"timezone": "<string>",
"weekday": 123
},
"workflow_id": "<string>"
}
}{
"message": "some message",
"status": "success",
"data": {
"goal_id": "<string>",
"goal_revision_id": "<string>",
"goal_status": "active",
"status": "<string>",
"run": {
"goal_id": "<string>",
"goal_revision_id": "<string>",
"run_id": "<string>",
"status": "<string>",
"workflow_id": "<string>"
},
"run_id": "<string>",
"schedule": {
"kind": "once",
"state": "armed",
"cadence": "<string>",
"last_fired_at": "<string>",
"localTime": "<string>",
"monthWeek": 123,
"next_run_at": "<string>",
"timezone": "<string>",
"weekday": 123
},
"workflow_id": "<string>"
}
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}Authorizations
Enter "Bearer {token}"
Headers
Tenant ID
UUID idempotency key
Body
application/json
Goal definition
Was this page helpful?
⌘I
Create a workflow goal
curl --request POST \
--url https://api.costgraph.ai/api/v1/tenant/automation/goals \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--header 'X-CostGraph-Tenant-ID: <x-costgraph-tenant-id>' \
--data '
{
"name": "<string>",
"objective": "<string>",
"autonomy_envelope": {},
"budgets": {},
"constraints": {},
"max_decisions": 100,
"scope": {},
"trigger": {},
"trigger_policy": {}
}
'import requests
url = "https://api.costgraph.ai/api/v1/tenant/automation/goals"
payload = {
"name": "<string>",
"objective": "<string>",
"autonomy_envelope": {},
"budgets": {},
"constraints": {},
"max_decisions": 100,
"scope": {},
"trigger": {},
"trigger_policy": {}
}
headers = {
"X-CostGraph-Tenant-ID": "<x-costgraph-tenant-id>",
"Idempotency-Key": "<idempotency-key>",
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-CostGraph-Tenant-ID': '<x-costgraph-tenant-id>',
'Idempotency-Key': '<idempotency-key>',
Authorization: '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: '<string>',
objective: '<string>',
autonomy_envelope: {},
budgets: {},
constraints: {},
max_decisions: 100,
scope: {},
trigger: {},
trigger_policy: {}
})
};
fetch('https://api.costgraph.ai/api/v1/tenant/automation/goals', 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.costgraph.ai/api/v1/tenant/automation/goals",
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([
'name' => '<string>',
'objective' => '<string>',
'autonomy_envelope' => [
],
'budgets' => [
],
'constraints' => [
],
'max_decisions' => 100,
'scope' => [
],
'trigger' => [
],
'trigger_policy' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>",
"X-CostGraph-Tenant-ID: <x-costgraph-tenant-id>"
],
]);
$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.costgraph.ai/api/v1/tenant/automation/goals"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"objective\": \"<string>\",\n \"autonomy_envelope\": {},\n \"budgets\": {},\n \"constraints\": {},\n \"max_decisions\": 100,\n \"scope\": {},\n \"trigger\": {},\n \"trigger_policy\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-CostGraph-Tenant-ID", "<x-costgraph-tenant-id>")
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("Authorization", "<api-key>")
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.costgraph.ai/api/v1/tenant/automation/goals")
.header("X-CostGraph-Tenant-ID", "<x-costgraph-tenant-id>")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"objective\": \"<string>\",\n \"autonomy_envelope\": {},\n \"budgets\": {},\n \"constraints\": {},\n \"max_decisions\": 100,\n \"scope\": {},\n \"trigger\": {},\n \"trigger_policy\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.costgraph.ai/api/v1/tenant/automation/goals")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-CostGraph-Tenant-ID"] = '<x-costgraph-tenant-id>'
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"objective\": \"<string>\",\n \"autonomy_envelope\": {},\n \"budgets\": {},\n \"constraints\": {},\n \"max_decisions\": 100,\n \"scope\": {},\n \"trigger\": {},\n \"trigger_policy\": {}\n}"
response = http.request(request)
puts response.read_body{
"message": "some message",
"status": "success",
"data": {
"goal_id": "<string>",
"goal_revision_id": "<string>",
"goal_status": "active",
"status": "<string>",
"run": {
"goal_id": "<string>",
"goal_revision_id": "<string>",
"run_id": "<string>",
"status": "<string>",
"workflow_id": "<string>"
},
"run_id": "<string>",
"schedule": {
"kind": "once",
"state": "armed",
"cadence": "<string>",
"last_fired_at": "<string>",
"localTime": "<string>",
"monthWeek": 123,
"next_run_at": "<string>",
"timezone": "<string>",
"weekday": 123
},
"workflow_id": "<string>"
}
}{
"message": "some message",
"status": "success",
"data": {
"goal_id": "<string>",
"goal_revision_id": "<string>",
"goal_status": "active",
"status": "<string>",
"run": {
"goal_id": "<string>",
"goal_revision_id": "<string>",
"run_id": "<string>",
"status": "<string>",
"workflow_id": "<string>"
},
"run_id": "<string>",
"schedule": {
"kind": "once",
"state": "armed",
"cadence": "<string>",
"last_fired_at": "<string>",
"localTime": "<string>",
"monthWeek": 123,
"next_run_at": "<string>",
"timezone": "<string>",
"weekday": 123
},
"workflow_id": "<string>"
}
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}