Start Run
curl --request POST \
--url https://agentgate.mynewapi.com/api/v1/work-orders/{id}/runs \
--header 'Authorization: Bearer <token>'import requests
url = "https://agentgate.mynewapi.com/api/v1/work-orders/{id}/runs"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://agentgate.mynewapi.com/api/v1/work-orders/{id}/runs', 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://agentgate.mynewapi.com/api/v1/work-orders/{id}/runs",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
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://agentgate.mynewapi.com/api/v1/work-orders/{id}/runs"
req, _ := http.NewRequest("POST", 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.post("https://agentgate.mynewapi.com/api/v1/work-orders/{id}/runs")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://agentgate.mynewapi.com/api/v1/work-orders/{id}/runs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"runId": "<string>",
"status": "<string>",
"startedAt": "<string>"
}
}Work Orders
Start Run
Start a new run for an existing work order
POST
/
api
/
v1
/
work-orders
/
{id}
/
runs
Start Run
curl --request POST \
--url https://agentgate.mynewapi.com/api/v1/work-orders/{id}/runs \
--header 'Authorization: Bearer <token>'import requests
url = "https://agentgate.mynewapi.com/api/v1/work-orders/{id}/runs"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://agentgate.mynewapi.com/api/v1/work-orders/{id}/runs', 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://agentgate.mynewapi.com/api/v1/work-orders/{id}/runs",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
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://agentgate.mynewapi.com/api/v1/work-orders/{id}/runs"
req, _ := http.NewRequest("POST", 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.post("https://agentgate.mynewapi.com/api/v1/work-orders/{id}/runs")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://agentgate.mynewapi.com/api/v1/work-orders/{id}/runs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"runId": "<string>",
"status": "<string>",
"startedAt": "<string>"
}
}Start Run
Starts a new run for an existing work order. This is useful for retrying failed work orders or re-running successful ones.The work order must be in
queued or failed status to start a new run. Running or completed work orders cannot have new runs started.Request
string
required
The work order ID (e.g.,
wo_abc123)curl -X POST https://agentgate.mynewapi.com/api/v1/work-orders/wo_abc123/runs \
-H "Authorization: Bearer YOUR_API_KEY"
Response
boolean
required
Indicates if the request was successful
object
required
Example Response
{
"success": true,
"data": {
"runId": "run_xyz789",
"status": "building",
"startedAt": "2024-01-15T10:30:00.000Z"
},
"requestId": "req_abc123"
}
Error Responses
Work Order Not Found
{
"success": false,
"error": {
"code": "NOT_FOUND",
"message": "Work order not found: wo_invalid"
},
"requestId": "req_xyz789"
}
Invalid Status
Returns 409 Conflict if the work order is not in a runnable state.{
"success": false,
"error": {
"code": "CONFLICT",
"message": "Cannot start run for work order in status 'running'. Only queued or failed work orders can be run."
},
"requestId": "req_xyz789"
}
Insufficient Credits
Returns 402 Payment Required if credits are insufficient.{
"success": false,
"error": {
"code": "FORBIDDEN",
"message": "Insufficient credits to run work order"
},
"requestId": "req_xyz789"
}
Status Requirements
| Work Order Status | Can Start Run? |
|---|---|
queued | ✅ Yes |
failed | ✅ Yes (retry) |
running | ❌ No |
succeeded | ❌ No |
canceled | ❌ No |
Use Cases
Retry a Failed Work Order
# Check work order status
curl https://agentgate.mynewapi.com/api/v1/work-orders/wo_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"
# If failed, start a new run
curl -X POST https://agentgate.mynewapi.com/api/v1/work-orders/wo_abc123/runs \
-H "Authorization: Bearer YOUR_API_KEY"
Monitor the New Run
After starting a run, you can monitor its progress:# Get run details
curl https://agentgate.mynewapi.com/api/v1/runs/run_xyz789 \
-H "Authorization: Bearer YOUR_API_KEY"
# Or get work order details (includes all runs)
curl https://agentgate.mynewapi.com/api/v1/work-orders/wo_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"
Run Lifecycle
When you start a run:- Request received - Run ID is generated
- Status: queued - Run is queued for execution
- Status: building - Workspace is being prepared
- Status: running - Agent is executing
- Status: succeeded/failed - Run completes
Use WebSocket streaming or polling to monitor run progress in real-time.
Related
- Get Run - Monitor run progress
- List Runs - List all runs for a work order
- Cancel Run - Cancel a running run