Automations
Start an automation run
Starts a run of an automation whose trigger is the API. The run works in Mercora; anything it would change waits for a person’s approval there. 201 a new run, 200 a retry of an external_id already used with the same body, 404 no such automation in this workspace, 409 the automation doesn’t run from the API or the external_id was used with another body, 429 the workspace’s daily run budget is used up.
Scope: automations.
POST
/
agents
/
{id}
/
run
Start an automation run
curl --request POST \
--url https://{workspace}.mercora.io/api/v1/agents/{id}/run \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"external_id": "PO-2026-0412",
"input": {
"purchase_order": "PO-2026-0412"
}
}
'import requests
url = "https://{workspace}.mercora.io/api/v1/agents/{id}/run"
payload = {
"external_id": "PO-2026-0412",
"input": { "purchase_order": "PO-2026-0412" }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({external_id: 'PO-2026-0412', input: {purchase_order: 'PO-2026-0412'}})
};
fetch('https://{workspace}.mercora.io/api/v1/agents/{id}/run', 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://{workspace}.mercora.io/api/v1/agents/{id}/run",
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([
'external_id' => 'PO-2026-0412',
'input' => [
'purchase_order' => 'PO-2026-0412'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://{workspace}.mercora.io/api/v1/agents/{id}/run"
payload := strings.NewReader("{\n \"external_id\": \"PO-2026-0412\",\n \"input\": {\n \"purchase_order\": \"PO-2026-0412\"\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(string(body))
}HttpResponse<String> response = Unirest.post("https://{workspace}.mercora.io/api/v1/agents/{id}/run")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"external_id\": \"PO-2026-0412\",\n \"input\": {\n \"purchase_order\": \"PO-2026-0412\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{workspace}.mercora.io/api/v1/agents/{id}/run")
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 \"external_id\": \"PO-2026-0412\",\n \"input\": {\n \"purchase_order\": \"PO-2026-0412\"\n }\n}"
response = http.request(request)
puts response.read_body{
"error": "<string>",
"issues": [
{
"field": "<string>",
"message": "<string>"
}
]
}{
"id": "1c9e2f3a-4b5d-4e6f-9a0b-1c2d3e4f5a6b",
"agent_id": "8b0d1c2e-3f4a-4b5c-8d6e-7f8091a2b3c4",
"status": "running",
"started_at": "2026-10-12T08:00:00.000Z"
}{
"error": "<string>",
"issues": [
{
"field": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"issues": [
{
"field": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"issues": [
{
"field": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"issues": [
{
"field": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"issues": [
{
"field": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"issues": [
{
"field": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"issues": [
{
"field": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"issues": [
{
"field": "<string>",
"message": "<string>"
}
]
}Authorizations
A workspace API key (mk_…), made under Settings → Administration → API.
Path Parameters
The automation's id.
Body
application/json
⌘I
Start an automation run
curl --request POST \
--url https://{workspace}.mercora.io/api/v1/agents/{id}/run \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"external_id": "PO-2026-0412",
"input": {
"purchase_order": "PO-2026-0412"
}
}
'import requests
url = "https://{workspace}.mercora.io/api/v1/agents/{id}/run"
payload = {
"external_id": "PO-2026-0412",
"input": { "purchase_order": "PO-2026-0412" }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({external_id: 'PO-2026-0412', input: {purchase_order: 'PO-2026-0412'}})
};
fetch('https://{workspace}.mercora.io/api/v1/agents/{id}/run', 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://{workspace}.mercora.io/api/v1/agents/{id}/run",
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([
'external_id' => 'PO-2026-0412',
'input' => [
'purchase_order' => 'PO-2026-0412'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://{workspace}.mercora.io/api/v1/agents/{id}/run"
payload := strings.NewReader("{\n \"external_id\": \"PO-2026-0412\",\n \"input\": {\n \"purchase_order\": \"PO-2026-0412\"\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(string(body))
}HttpResponse<String> response = Unirest.post("https://{workspace}.mercora.io/api/v1/agents/{id}/run")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"external_id\": \"PO-2026-0412\",\n \"input\": {\n \"purchase_order\": \"PO-2026-0412\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{workspace}.mercora.io/api/v1/agents/{id}/run")
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 \"external_id\": \"PO-2026-0412\",\n \"input\": {\n \"purchase_order\": \"PO-2026-0412\"\n }\n}"
response = http.request(request)
puts response.read_body{
"error": "<string>",
"issues": [
{
"field": "<string>",
"message": "<string>"
}
]
}{
"id": "1c9e2f3a-4b5d-4e6f-9a0b-1c2d3e4f5a6b",
"agent_id": "8b0d1c2e-3f4a-4b5c-8d6e-7f8091a2b3c4",
"status": "running",
"started_at": "2026-10-12T08:00:00.000Z"
}{
"error": "<string>",
"issues": [
{
"field": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"issues": [
{
"field": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"issues": [
{
"field": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"issues": [
{
"field": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"issues": [
{
"field": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"issues": [
{
"field": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"issues": [
{
"field": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"issues": [
{
"field": "<string>",
"message": "<string>"
}
]
}