> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developer.jelliu.co/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developer.jelliu.co/_mcp/server.

# Create an A/B variant

POST https://api.jelliu.co/api/agents/{agentId}/ab-tests
Content-Type: application/json

Creates a prompt variant for the agent (maximum 10 live variants per agent). When an agent has
active variants, each **outbound campaign voice call** placed by the dialer picks one at random,
weighted by `weight`, and uses its `systemPrompt` (and `firstMessage`, when set) in place of the
agent's for that call. Inbound calls, manual calls and text channels always use the agent's own
prompt. Weights are relative: two active variants at 50 and 25 split traffic two to one. A single
active variant receives every campaign call.

The call's outcome, duration and sentiment are added to the variant's counters when post-call
analysis produces an outcome; `GET /api/agents/{agentId}/ab-tests/results` compares them.

**Side effects.** Screens the prompt and the first message for fraud (LLM call; a blocked prompt is
recorded as a fraud flag). Inserts the variant, which starts affecting the agent's next campaign
dials immediately. Writes an audit entry.

**Idempotency.** Not idempotent: a retry creates a second variant with the same content and splits
traffic further.

**Webhook events.** `audit.log_recorded` (when subscribed). See [Webhooks](/webhooks).

**Access**

* **Required scope:** `write`.
* **Rate limit:** Agent mutations — 10 requests/min per workspace, shared with every agent write; the request is also counted (twice) against the General API limit. See [Rate limits](/rate-limits).
* **Plan:** A/B testing is gated by plan feature; every plan includes it today.

Reference: https://developer.jelliu.co/api-reference/agents/post-agents-by-agent-id-ab-tests

## Authentication

- `Authorization` header (bearer token, required) — Workspace API key: `jl_` followed by 64 lowercase hex characters, created by the workspace owner in the dashboard (**Settings → API Keys**) and sent as `Authorization: Bearer jl_...`. The plaintext is shown once, at creation; Jelliu stores only a SHA-256 hash. A workspace can hold up to 25 active keys. | Scope | GET / HEAD | POST / PUT / PATCH / DELETE | Admin-only routes | | --- | --- | --- | --- | | `read` | Yes | No | No | | `write` | Yes | Yes | No | | `full` | Yes | Yes | Yes | Operations restricted to admins or owners reject keys without the `full` scope with `403`, and say so in their description. No key, whatever its scope, can mint or revoke API keys or rotate a webhook secret — that requires a signed-in owner session. A revoked key stops authenticating within about 10 seconds. See [Authentication](/authentication).

## Request

### Path parameters

- `agentId` (string, required) — UUID of the agent the variant belongs to. An unknown id or one from another workspace answers `404`; a value that is not a UUID answers `400`.

### Body (application/json)

This endpoint expects an object.

- `name` (string, required) — Label shown in results. Trimmed; 1-100 characters after trimming.
- `systemPrompt` (string, required) — The prompt this variant uses instead of the agent's `system_prompt` on the calls that pick it. 10-8000 characters, stored as sent (not trimmed). Screened for fraud.
- `firstMessage` (string, optional) — Opening line for calls that pick this variant. Trimmed; blank is treated as absent, and then the agent's first message is used.
- `weight` (integer, optional, default: 50) — Relative traffic weight, 0-100. Defaults to 50. `0` keeps the variant active but it is never picked while another active variant has weight. Stored as an integer — send whole numbers; a fractional value fails the request.

## Response

### 201

Variant created (active).

- `data` (object, required) — A prompt variant row (snake_case), with its raw performance counters.
  - `id` (string, optional) — Unique identifier of the variant.
  - `tenant_id` (string, optional) — Workspace that owns the variant.
  - `agent_id` (string, optional) — Agent the variant belongs to.
  - `name` (string, optional) — Label shown in results.
  - `system_prompt` (string, optional) — Prompt used instead of the agent's on calls that pick this variant.
  - `first_message` (string, optional, nullable) — Opening line for calls that pick this variant; `null` uses the agent's.
  - `weight` (integer, optional) — Relative traffic weight among active variants.
  - `is_active` (boolean, optional) — Whether the variant can be picked for new campaign calls.
  - `total_calls` (integer, optional) — Calls with an outcome recorded for this variant.
  - `total_conversions` (integer, optional) — Of those, calls whose outcome is a success outcome.
  - `total_duration_seconds` (integer, optional) — Sum of recorded call durations, in seconds.
  - `avg_sentiment` (double, optional, nullable) — Running average sentiment (-1 to 1) of calls that had a score; `null` when none had one.
  - `created_at` (datetime, optional) — Creation time (UTC).
  - `updated_at` (datetime, optional) — Last change, including counter updates (UTC).
  - `deleted_at` (any, optional) — Always `null` on returned variants.

## Errors

### 400 Bad Request Error

Invalid id or body (`details` is Zod's flattened error), or the agent already has 10 live variants.

- `error` (object, required) — The error object. Always has `code` and `message`.
  - `code` (string, required) — Stable machine-readable error code (for example `VALIDATION_FAILED`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `BILLING_ERROR`, `COMPLIANCE_BLOCKED`, `RATE_LIMIT_EXCEEDED`, `INTERNAL_ERROR`). Switch on this, not on `message`. See [Errors](/errors).
  - `message` (string, required) — Human-readable explanation. English or Spanish depending on the route; may change without notice.
  - `details` (object or list of object, optional) — Present on `VALIDATION_FAILED` only. Its shape depends on how the route validates: * a field map, either Zod's `flatten()` output (`{ "formErrors": [], "fieldErrors": { "name": ["..."] } }`) or just its `fieldErrors` part (`{ "name": ["..."] }`); * an issue list, where each issue has at least `path`, `message` and `code`. `path` is a dot-separated string on routes that let the schema throw, and an array of keys on routes that forward Zod's raw issues (those also carry Zod's extra issue fields).
    - Field map
      - `formErrors` (list of string, optional)
      - `fieldErrors` (map from string to list of string, optional)
  - `metadata` (map from string to any, optional) — Structured detail exposed for a small allowlist of codes only — for example `BILLING_ERROR` carries `limit`, `current` and `tier` (resource caps) or `tier` and `feature` (feature gates).

### 401 Unauthorized Error

No usable credential. Either the `Authorization` header is missing or is not a well-formed `Bearer jl_…` key, or the key is unknown, revoked or expired. Do not retry with the same key. See [Authentication](/authentication#401-unauthorized).

- `error` (object, required) — The error object. Always has `code` and `message`.
  - `code` (string, required) — Stable machine-readable error code (for example `VALIDATION_FAILED`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `BILLING_ERROR`, `COMPLIANCE_BLOCKED`, `RATE_LIMIT_EXCEEDED`, `INTERNAL_ERROR`). Switch on this, not on `message`. See [Errors](/errors).
  - `message` (string, required) — Human-readable explanation. English or Spanish depending on the route; may change without notice.
  - `details` (object or list of object, optional) — Present on `VALIDATION_FAILED` only. Its shape depends on how the route validates: * a field map, either Zod's `flatten()` output (`{ "formErrors": [], "fieldErrors": { "name": ["..."] } }`) or just its `fieldErrors` part (`{ "name": ["..."] }`); * an issue list, where each issue has at least `path`, `message` and `code`. `path` is a dot-separated string on routes that let the schema throw, and an array of keys on routes that forward Zod's raw issues (those also carry Zod's extra issue fields).
    - Field map
      - `formErrors` (list of string, optional)
      - `fieldErrors` (map from string to list of string, optional)
  - `metadata` (map from string to any, optional) — Structured detail exposed for a small allowlist of codes only — for example `BILLING_ERROR` carries `limit`, `current` and `tier` (resource caps) or `tier` and `feature` (feature gates).

### 403 Forbidden Error

Prompt blocked by fraud screening (`COMPLIANCE_BLOCKED`), API-key scope (`FORBIDDEN`), suspended workspace, or (not reachable on current plans) A/B testing missing from the plan.

- `error` (object, required) — The error object. Always has `code` and `message`.
  - `code` (string, required) — Stable machine-readable error code (for example `VALIDATION_FAILED`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `BILLING_ERROR`, `COMPLIANCE_BLOCKED`, `RATE_LIMIT_EXCEEDED`, `INTERNAL_ERROR`). Switch on this, not on `message`. See [Errors](/errors).
  - `message` (string, required) — Human-readable explanation. English or Spanish depending on the route; may change without notice.
  - `details` (object or list of object, optional) — Present on `VALIDATION_FAILED` only. Its shape depends on how the route validates: * a field map, either Zod's `flatten()` output (`{ "formErrors": [], "fieldErrors": { "name": ["..."] } }`) or just its `fieldErrors` part (`{ "name": ["..."] }`); * an issue list, where each issue has at least `path`, `message` and `code`. `path` is a dot-separated string on routes that let the schema throw, and an array of keys on routes that forward Zod's raw issues (those also carry Zod's extra issue fields).
    - Field map
      - `formErrors` (list of string, optional)
      - `fieldErrors` (map from string to list of string, optional)
  - `metadata` (map from string to any, optional) — Structured detail exposed for a small allowlist of codes only — for example `BILLING_ERROR` carries `limit`, `current` and `tier` (resource caps) or `tier` and `feature` (feature gates).

### 404 Not Found Error

No live agent with this id in the workspace. Fraud screening runs first, so a blocked prompt answers `403` even for an unknown agent.

- `error` (object, required) — The error object. Always has `code` and `message`.
  - `code` (string, required) — Stable machine-readable error code (for example `VALIDATION_FAILED`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `BILLING_ERROR`, `COMPLIANCE_BLOCKED`, `RATE_LIMIT_EXCEEDED`, `INTERNAL_ERROR`). Switch on this, not on `message`. See [Errors](/errors).
  - `message` (string, required) — Human-readable explanation. English or Spanish depending on the route; may change without notice.
  - `details` (object or list of object, optional) — Present on `VALIDATION_FAILED` only. Its shape depends on how the route validates: * a field map, either Zod's `flatten()` output (`{ "formErrors": [], "fieldErrors": { "name": ["..."] } }`) or just its `fieldErrors` part (`{ "name": ["..."] }`); * an issue list, where each issue has at least `path`, `message` and `code`. `path` is a dot-separated string on routes that let the schema throw, and an array of keys on routes that forward Zod's raw issues (those also carry Zod's extra issue fields).
    - Field map
      - `formErrors` (list of string, optional)
      - `fieldErrors` (map from string to list of string, optional)
  - `metadata` (map from string to any, optional) — Structured detail exposed for a small allowlist of codes only — for example `BILLING_ERROR` carries `limit`, `current` and `tier` (resource caps) or `tier` and `feature` (feature gates).

### 429 Too Many Requests Error

Agent-mutation budget (10/min) or the general API limit exhausted.

- `error` (object, required) — The error object. Always has `code` and `message`.
  - `code` (string, required) — Stable machine-readable error code (for example `VALIDATION_FAILED`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `BILLING_ERROR`, `COMPLIANCE_BLOCKED`, `RATE_LIMIT_EXCEEDED`, `INTERNAL_ERROR`). Switch on this, not on `message`. See [Errors](/errors).
  - `message` (string, required) — Human-readable explanation. English or Spanish depending on the route; may change without notice.
  - `details` (object or list of object, optional) — Present on `VALIDATION_FAILED` only. Its shape depends on how the route validates: * a field map, either Zod's `flatten()` output (`{ "formErrors": [], "fieldErrors": { "name": ["..."] } }`) or just its `fieldErrors` part (`{ "name": ["..."] }`); * an issue list, where each issue has at least `path`, `message` and `code`. `path` is a dot-separated string on routes that let the schema throw, and an array of keys on routes that forward Zod's raw issues (those also carry Zod's extra issue fields).
    - Field map
      - `formErrors` (list of string, optional)
      - `fieldErrors` (map from string to list of string, optional)
  - `metadata` (map from string to any, optional) — Structured detail exposed for a small allowlist of codes only — for example `BILLING_ERROR` carries `limit`, `current` and `tier` (resource caps) or `tier` and `feature` (feature gates).

## Examples

### Agents_postAgentsByAgentIdAbTests_example

**Request**

```json
undefined
```

**Response**

```json
{
  "data": {
    "id": "8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b",
    "tenant_id": "2d9f6c1e-3b4a-4c5d-9e8f-7a6b5c4d3e2f",
    "agent_id": "7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c",
    "name": "Variante B — oferta directa",
    "system_prompt": "Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual en la primera respuesta.",
    "first_message": "Hola, le habla Sofía de Cafés del Huila. Este mes el plan anual tiene dos meses gratis.",
    "weight": 50,
    "is_active": true,
    "total_calls": 0,
    "total_conversions": 0,
    "total_duration_seconds": 0,
    "avg_sentiment": null,
    "created_at": "2026-09-15T14:40:00.000Z",
    "updated_at": "2026-09-15T14:40:00.000Z"
  }
}
```

**SDK Code**

```python Agents_postAgentsByAgentIdAbTests_example
import requests

url = "https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests"

headers = {"Authorization": "Bearer <token>"}

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

print(response.json())
```

```javascript Agents_postAgentsByAgentIdAbTests_example
const url = 'https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Agents_postAgentsByAgentIdAbTests_example
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests"

	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(res)
	fmt.Println(string(body))

}
```

```ruby Agents_postAgentsByAgentIdAbTests_example
require 'uri'
require 'net/http'

url = URI("https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests")

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
```

```java Agents_postAgentsByAgentIdAbTests_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php Agents_postAgentsByAgentIdAbTests_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp Agents_postAgentsByAgentIdAbTests_example
using RestSharp;

var client = new RestClient("https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Agents_postAgentsByAgentIdAbTests_example
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Variant with its own opening line

**Request**

```json
{
  "name": "Variante B — oferta directa",
  "systemPrompt": "Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual en la primera respuesta.",
  "firstMessage": "Hola, le habla Sofía de Cafés del Huila. Este mes el plan anual tiene dos meses gratis.",
  "weight": 50
}
```

**Response**

```json
{
  "data": {
    "id": "8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b",
    "tenant_id": "2d9f6c1e-3b4a-4c5d-9e8f-7a6b5c4d3e2f",
    "agent_id": "7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c",
    "name": "Variante B — oferta directa",
    "system_prompt": "Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual en la primera respuesta.",
    "first_message": "Hola, le habla Sofía de Cafés del Huila. Este mes el plan anual tiene dos meses gratis.",
    "weight": 50,
    "is_active": true,
    "total_calls": 0,
    "total_conversions": 0,
    "total_duration_seconds": 0,
    "avg_sentiment": null,
    "created_at": "2026-09-15T14:40:00.000Z",
    "updated_at": "2026-09-15T14:40:00.000Z"
  }
}
```

**SDK Code**

```python Variant with its own opening line
import requests

url = "https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests"

payload = {
    "name": "Variante B — oferta directa",
    "systemPrompt": "Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual en la primera respuesta.",
    "firstMessage": "Hola, le habla Sofía de Cafés del Huila. Este mes el plan anual tiene dos meses gratis.",
    "weight": 50
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Variant with its own opening line
const url = 'https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"Variante B — oferta directa","systemPrompt":"Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual en la primera respuesta.","firstMessage":"Hola, le habla Sofía de Cafés del Huila. Este mes el plan anual tiene dos meses gratis.","weight":50}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Variant with its own opening line
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests"

	payload := strings.NewReader("{\n  \"name\": \"Variante B — oferta directa\",\n  \"systemPrompt\": \"Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual en la primera respuesta.\",\n  \"firstMessage\": \"Hola, le habla Sofía de Cafés del Huila. Este mes el plan anual tiene dos meses gratis.\",\n  \"weight\": 50\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(res)
	fmt.Println(string(body))

}
```

```ruby Variant with its own opening line
require 'uri'
require 'net/http'

url = URI("https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests")

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  \"name\": \"Variante B — oferta directa\",\n  \"systemPrompt\": \"Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual en la primera respuesta.\",\n  \"firstMessage\": \"Hola, le habla Sofía de Cafés del Huila. Este mes el plan anual tiene dos meses gratis.\",\n  \"weight\": 50\n}"

response = http.request(request)
puts response.read_body
```

```java Variant with its own opening line
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Variante B — oferta directa\",\n  \"systemPrompt\": \"Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual en la primera respuesta.\",\n  \"firstMessage\": \"Hola, le habla Sofía de Cafés del Huila. Este mes el plan anual tiene dos meses gratis.\",\n  \"weight\": 50\n}")
  .asString();
```

```php Variant with its own opening line
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests', [
  'body' => '{
  "name": "Variante B — oferta directa",
  "systemPrompt": "Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual en la primera respuesta.",
  "firstMessage": "Hola, le habla Sofía de Cafés del Huila. Este mes el plan anual tiene dos meses gratis.",
  "weight": 50
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Variant with its own opening line
using RestSharp;

var client = new RestClient("https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Variante B — oferta directa\",\n  \"systemPrompt\": \"Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual en la primera respuesta.\",\n  \"firstMessage\": \"Hola, le habla Sofía de Cafés del Huila. Este mes el plan anual tiene dos meses gratis.\",\n  \"weight\": 50\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Variant with its own opening line
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Variante B — oferta directa",
  "systemPrompt": "Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual en la primera respuesta.",
  "firstMessage": "Hola, le habla Sofía de Cafés del Huila. Este mes el plan anual tiene dos meses gratis.",
  "weight": 50
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Prompt only, default weight

**Request**

```json
{
  "name": "Variante A — consultiva",
  "systemPrompt": "Eres Sofía, asesora de Cafés del Huila. Pregunta primero cuánto café consume el cliente al mes antes de recomendar un plan."
}
```

**Response**

```json
{
  "data": {
    "id": "8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b",
    "tenant_id": "2d9f6c1e-3b4a-4c5d-9e8f-7a6b5c4d3e2f",
    "agent_id": "7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c",
    "name": "Variante B — oferta directa",
    "system_prompt": "Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual en la primera respuesta.",
    "first_message": "Hola, le habla Sofía de Cafés del Huila. Este mes el plan anual tiene dos meses gratis.",
    "weight": 50,
    "is_active": true,
    "total_calls": 0,
    "total_conversions": 0,
    "total_duration_seconds": 0,
    "avg_sentiment": null,
    "created_at": "2026-09-15T14:40:00.000Z",
    "updated_at": "2026-09-15T14:40:00.000Z"
  }
}
```

**SDK Code**

```python Prompt only, default weight
import requests

url = "https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests"

payload = {
    "name": "Variante A — consultiva",
    "systemPrompt": "Eres Sofía, asesora de Cafés del Huila. Pregunta primero cuánto café consume el cliente al mes antes de recomendar un plan."
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Prompt only, default weight
const url = 'https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"Variante A — consultiva","systemPrompt":"Eres Sofía, asesora de Cafés del Huila. Pregunta primero cuánto café consume el cliente al mes antes de recomendar un plan."}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Prompt only, default weight
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests"

	payload := strings.NewReader("{\n  \"name\": \"Variante A — consultiva\",\n  \"systemPrompt\": \"Eres Sofía, asesora de Cafés del Huila. Pregunta primero cuánto café consume el cliente al mes antes de recomendar un plan.\"\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(res)
	fmt.Println(string(body))

}
```

```ruby Prompt only, default weight
require 'uri'
require 'net/http'

url = URI("https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests")

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  \"name\": \"Variante A — consultiva\",\n  \"systemPrompt\": \"Eres Sofía, asesora de Cafés del Huila. Pregunta primero cuánto café consume el cliente al mes antes de recomendar un plan.\"\n}"

response = http.request(request)
puts response.read_body
```

```java Prompt only, default weight
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Variante A — consultiva\",\n  \"systemPrompt\": \"Eres Sofía, asesora de Cafés del Huila. Pregunta primero cuánto café consume el cliente al mes antes de recomendar un plan.\"\n}")
  .asString();
```

```php Prompt only, default weight
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests', [
  'body' => '{
  "name": "Variante A — consultiva",
  "systemPrompt": "Eres Sofía, asesora de Cafés del Huila. Pregunta primero cuánto café consume el cliente al mes antes de recomendar un plan."
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Prompt only, default weight
using RestSharp;

var client = new RestClient("https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Variante A — consultiva\",\n  \"systemPrompt\": \"Eres Sofía, asesora de Cafés del Huila. Pregunta primero cuánto café consume el cliente al mes antes de recomendar un plan.\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Prompt only, default weight
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Variante A — consultiva",
  "systemPrompt": "Eres Sofía, asesora de Cafés del Huila. Pregunta primero cuánto café consume el cliente al mes antes de recomendar un plan."
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```