Skip to main content
POST
/
v2
/
agents
/
execution
/
count
Count Executions
curl --request POST \
  --url https://api.velt.dev/v2/agents/execution/count \
  --header 'Content-Type: application/json' \
  --header 'x-velt-api-key: <x-velt-api-key>' \
  --header 'x-velt-auth-token: <x-velt-auth-token>' \
  --data '
{
  "data": {
    "agentIds": [
      "<string>"
    ],
    "status": "<string>"
  }
}
'
import requests

url = "https://api.velt.dev/v2/agents/execution/count"

payload = { "data": {
"agentIds": ["<string>"],
"status": "<string>"
} }
headers = {
"x-velt-api-key": "<x-velt-api-key>",
"x-velt-auth-token": "<x-velt-auth-token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {
'x-velt-api-key': '<x-velt-api-key>',
'x-velt-auth-token': '<x-velt-auth-token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({data: {agentIds: ['<string>'], status: '<string>'}})
};

fetch('https://api.velt.dev/v2/agents/execution/count', 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.velt.dev/v2/agents/execution/count",
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([
'data' => [
'agentIds' => [
'<string>'
],
'status' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-velt-api-key: <x-velt-api-key>",
"x-velt-auth-token: <x-velt-auth-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"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.velt.dev/v2/agents/execution/count"

payload := strings.NewReader("{\n \"data\": {\n \"agentIds\": [\n \"<string>\"\n ],\n \"status\": \"<string>\"\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-velt-api-key", "<x-velt-api-key>")
req.Header.Add("x-velt-auth-token", "<x-velt-auth-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://api.velt.dev/v2/agents/execution/count")
.header("x-velt-api-key", "<x-velt-api-key>")
.header("x-velt-auth-token", "<x-velt-auth-token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"agentIds\": [\n \"<string>\"\n ],\n \"status\": \"<string>\"\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.velt.dev/v2/agents/execution/count")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-velt-api-key"] = '<x-velt-api-key>'
request["x-velt-auth-token"] = '<x-velt-auth-token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"agentIds\": [\n \"<string>\"\n ],\n \"status\": \"<string>\"\n }\n}"

response = http.request(request)
puts response.read_body
{
  "result": {
    "status": "success",
    "message": "Agent execution count fetched successfully",
    "data": {
      "counts": { "agent_brand_check": 2 }
    }
  }
}
Use this API to get a workspace-wide aggregate count of executions, optionally filtered by agentIds and/or status. Designed for poll-based “N running” counters — poll periodically with an array of agent IDs and get back a { counts: { [agentId]: number } } map. Read-only. Never enqueues a Cloud Task.

Endpoint

POST https://api.velt.dev/v2/agents/execution/count

Headers

x-velt-api-key
string
required
Your API key.
x-velt-auth-token
string
required

Body

Params

data
object
required
The schema uses .strict() — unknown top-level fields are rejected.

Example Requests

1. Count running executions for a set of agents

{
  "data": {
    "agentIds": ["agent_brand_check", "spell-check", "broken-links"],
    "status": "running"
  }
}

2. Count all executions of a single agent

{
  "data": {
    "agentIds": "agent_brand_check"
  }
}

3. Workspace-wide total (no filter)

{
  "data": {}
}

4. Workspace-wide total, filtered by status

{
  "data": {
    "status": "running"
  }
}

Response

The response shape depends on whether agentIds was provided. counts and total are mutually exclusive — exactly one is present.

Success Response (agentIds provided → counts map)

{
  "result": {
    "status": "success",
    "message": "Agent execution count fetched successfully",
    "data": {
      "counts": {
        "agent_brand_check": 2,
        "spell-check": 0,
        "broken-links": 1
      }
    }
  }
}
Partial-failure contract: if a per-agent count fails, the response is still 200 success and that agent’s value is the integer sentinel -1 (not null, not omitted). The map stays a uniform Record<string, number>, so clients never need to parse JSON null. Unknown agent IDs simply return 0.

Success Response (agentIds omitted → total)

{
  "result": {
    "status": "success",
    "message": "Agent execution count fetched successfully",
    "data": {
      "total": 128
    }
  }
}
FieldTypeDescription
data.countsobjectPresent when agentIds was provided. One key per unique agent ID (deduped). Failed counts → -1.
data.totalnumberPresent when agentIds was omitted. Single workspace-wide count, optionally narrowed by status.

Failure Response

{
  "error": {
    "message": "ERROR_MESSAGE",
    "status": "INVALID_ARGUMENT"
  }
}
Errors: INVALID_ARGUMENT (empty agentIds array, agentIds exceeding 200 elements, invalid status, or an unknown top-level field) / NOT_FOUND (workspace store database could not be resolved).
{
  "result": {
    "status": "success",
    "message": "Agent execution count fetched successfully",
    "data": {
      "counts": { "agent_brand_check": 2 }
    }
  }
}