Skip to main content
POST
/
test-sets
/
{test_set_id}
/
agents:add
Associate agents with a test set
curl --request POST \
  --url https://api.coval.dev/v1/test-sets/{test_set_id}/agents:add \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "agent_ids": [
    "abc123def456ghi789jklm"
  ]
}
'
import requests

url = "https://api.coval.dev/v1/test-sets/{test_set_id}/agents:add"

payload = { "agent_ids": ["abc123def456ghi789jklm"] }
headers = {
    "X-API-Key": "<api-key>",
    "Content-Type": "application/json"
}

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

print(response.text)
const options = {
  method: 'POST',
  headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
  body: JSON.stringify({agent_ids: ['abc123def456ghi789jklm']})
};

fetch('https://api.coval.dev/v1/test-sets/{test_set_id}/agents:add', 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.coval.dev/v1/test-sets/{test_set_id}/agents:add",
  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([
    'agent_ids' => [
        'abc123def456ghi789jklm'
    ]
  ]),
  CURLOPT_HTTPHEADER => [
    "Content-Type: application/json",
    "X-API-Key: <api-key>"
  ],
]);

$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.coval.dev/v1/test-sets/{test_set_id}/agents:add"

	payload := strings.NewReader("{\n  \"agent_ids\": [\n    \"abc123def456ghi789jklm\"\n  ]\n}")

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

	req.Header.Add("X-API-Key", "<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.coval.dev/v1/test-sets/{test_set_id}/agents:add")
  .header("X-API-Key", "<api-key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"agent_ids\": [\n    \"abc123def456ghi789jklm\"\n  ]\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.coval.dev/v1/test-sets/{test_set_id}/agents:add")

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

request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"agent_ids\": [\n    \"abc123def456ghi789jklm\"\n  ]\n}"

response = http.request(request)
puts response.read_body
{
  "agents": [
    {
      "name": "test-sets/abc12345/agents/abc123def456ghi789jklm",
      "agent_id": "abc123def456ghi789jklm",
      "display_name": "Support Bot"
    }
  ]
}
{
  "error": {
    "code": "INVALID_ARGUMENT",
    "message": "Invalid request parameters",
    "details": [
      {
        "field": "display_name",
        "description": "display_name is required and cannot be empty"
      }
    ]
  }
}
{
  "error": {
    "code": "UNAUTHENTICATED",
    "message": "Authentication failed",
    "details": [
      {
        "field": "X-API-Key",
        "description": "Invalid or missing API key"
      }
    ]
  }
}
{
  "error": {
    "code": "INVALID_ARGUMENT",
    "message": "Invalid request parameters",
    "details": [
      {
        "field": "slug",
        "description": "slug already exists for this organization"
      }
    ]
  }
}
{
  "error": {
    "code": "INTERNAL",
    "message": "Internal server error",
    "details": [
      {
        "description": "An unexpected error occurred while processing the request"
      }
    ]
  }
}

Authorizations

X-API-Key
string
header
required

Organization API key for authentication

Path Parameters

test_set_id
string
required

Test set ID (8-character ID)

Required string length: 8

Body

application/json

Associate one or more agents with the test set.

agent_ids
string[]
required

Agent IDs (22-char ShortUUIDs) to associate. Already-associated IDs are a no-op, and unknown or inactive IDs are ignored; the response reflects the resulting association set.

Required array length: 1 - 1000 elements
Required string length: 1 - 22
Pattern: ^[A-Za-z0-9]+$
Example:
["abc123def456ghi789jklm"]

Response

Agents associated successfully

The agents currently associated with the test set.

agents
object[]
required