Workflows
Follow a workflow
A stream of a workflow’s changes and its runs as they move, as server-sent events.
GET
/
workflows
/
{id}
/
events
Follow a workflow’s changes and runs
curl --request GET \
--url https://www.orgo.ai/api/workflows/{id}/events \
--header 'Authorization: Bearer <token>'import requests
url = "https://www.orgo.ai/api/workflows/{id}/events"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://www.orgo.ai/api/workflows/{id}/events', 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://www.orgo.ai/api/workflows/{id}/events",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://www.orgo.ai/api/workflows/{id}/events"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://www.orgo.ai/api/workflows/{id}/events")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.orgo.ai/api/workflows/{id}/events")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyretry: 1000
: open
event: run
data: {"run":{"run_id":"0d9c6c1e-5b8e-4a59-9d3b-7a1f2c3d4e5f","state":"running"},"by":"You"}
{
"error": "<string>",
"code": "<string>",
"say": "<string>",
"next": "<string>",
"to_fix": [
"<string>"
],
"problems": [
{}
],
"version": 123,
"lines": "<string>"
}{
"error": "<string>",
"code": "<string>",
"say": "<string>",
"next": "<string>",
"to_fix": [
"<string>"
],
"problems": [
{}
],
"version": 123,
"lines": "<string>"
}{
"error": "<string>",
"code": "<string>",
"say": "<string>",
"next": "<string>",
"to_fix": [
"<string>"
],
"problems": [
{}
],
"version": 123,
"lines": "<string>"
}{
"error": "Too many API requests this minute (120 a minute on your plan). Try again in 12 seconds.",
"code": "rate_limited",
"limit": "api_other_per_minute",
"retry_after": 12
}{
"error": "Service temporarily unavailable. The database is not accepting requests. Retry shortly."
}Opens a
Lines that start with
text/event-stream of one workflow: its steps changing, it being turned on or off, renamed or deleted, and every run moving step by step. The canvas follows a workflow the same way.
The stream closes after 5 minutes. Open it again: an EventSource does that by itself, after the retry: 1000 the stream sends. At most 10 streams are open at once per credential, and 5 per workflow; one more answers 429.
Path parameters
string
required
The workflow’s id, like
morning-report.Events
| Event | Data | When |
|---|---|---|
| (unnamed) | { lines, by, changed } | Its steps changed. by names who wrote them. |
state | { on, settings, name, by, changed } | It was turned on or off, renamed, or its settings changed. changed holds only what changed. |
run | { run, by } | A run moved. run has the shape Get a run describes. |
deleted | { by } | It was deleted. |
: are comments that keep the connection open.
Example
curl -N https://www.orgo.ai/api/workflows/morning-report/events \
-H "Authorization: Bearer $ORGO_API_KEY"
const r = await fetch("https://www.orgo.ai/api/workflows/morning-report/events", {
headers: { Authorization: `Bearer ${process.env.ORGO_API_KEY}` },
});
const reader = r.body.pipeThrough(new TextDecoderStream()).getReader();
for (;;) {
const { value, done } = await reader.read();
if (done) break;
process.stdout.write(value);
}
Stream
retry: 1000
: open
event: run
data: {"run":{"run_id":"0d9c6c1e-5b8e-4a59-9d3b-7a1f2c3d4e5f","state":"running"},"by":"You"}
Errors
| Status | Code | When |
|---|---|---|
401 | No key, or a key Orgo doesn’t know. | |
403 | key_permission | A restricted key without Workflows read. |
404 | (no body) | Workflows aren’t open to your account. |
429 | rate_limited | Too many streams open. Close one, then try again. Carries Retry-After. |
503 | Orgo couldn’t verify the key because of a server-side fault. Retry. |
⌘I
Follow a workflow’s changes and runs
curl --request GET \
--url https://www.orgo.ai/api/workflows/{id}/events \
--header 'Authorization: Bearer <token>'import requests
url = "https://www.orgo.ai/api/workflows/{id}/events"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://www.orgo.ai/api/workflows/{id}/events', 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://www.orgo.ai/api/workflows/{id}/events",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://www.orgo.ai/api/workflows/{id}/events"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://www.orgo.ai/api/workflows/{id}/events")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.orgo.ai/api/workflows/{id}/events")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyretry: 1000
: open
event: run
data: {"run":{"run_id":"0d9c6c1e-5b8e-4a59-9d3b-7a1f2c3d4e5f","state":"running"},"by":"You"}
{
"error": "<string>",
"code": "<string>",
"say": "<string>",
"next": "<string>",
"to_fix": [
"<string>"
],
"problems": [
{}
],
"version": 123,
"lines": "<string>"
}{
"error": "<string>",
"code": "<string>",
"say": "<string>",
"next": "<string>",
"to_fix": [
"<string>"
],
"problems": [
{}
],
"version": 123,
"lines": "<string>"
}{
"error": "<string>",
"code": "<string>",
"say": "<string>",
"next": "<string>",
"to_fix": [
"<string>"
],
"problems": [
{}
],
"version": 123,
"lines": "<string>"
}{
"error": "Too many API requests this minute (120 a minute on your plan). Try again in 12 seconds.",
"code": "rate_limited",
"limit": "api_other_per_minute",
"retry_after": 12
}{
"error": "Service temporarily unavailable. The database is not accepting requests. Retry shortly."
}