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

# Update an A/B variant

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

Changes a variant's weight, active flag, prompt or first message. At least one field must be defined.
Set `isActive: false` to stop a variant from being picked without losing its counters; set it back to
`true` to resume. Counters are never reset by an update — create a new variant to measure a changed
prompt from zero.

**Side effects.** A changed prompt or first message is screened for fraud (LLM call). The new
settings apply to the agent's next campaign dials. Writes an audit entry.

**Idempotency.** Safe to retry: the same body sets the same values.

**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/patch-agents-by-agent-id-ab-tests-by-variant-id

## 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 that owns the variant. A value that is not a UUID answers `400 Invalid params`.
- `variantId` (string, required) — UUID of the variant (`id` from `GET /api/agents/{agentId}/ab-tests`). A variant of another agent, another workspace or already deleted answers `404`; a value that is not a UUID answers `400 Invalid params`.

### Body (application/json)

This endpoint expects an object.

- `weight` (integer, optional) — New relative traffic weight, 0-100. Stored as an integer — send whole numbers; a fractional value fails the request.
- `isActive` (boolean, optional) — `false` stops the variant from being picked for new calls; counters are kept.
- `systemPrompt` (string, optional) — New prompt, 10-8000 characters. Blank is treated as absent. Screened for fraud.
- `firstMessage` (string, optional) — New opening line. Trimmed; blank is treated as absent (it cannot be cleared to null here).

## Response

### 200

The updated variant.

- `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 ids or body.

- `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 variant with this id for this agent in the workspace.

- `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_patchAgentsByAgentIdAbTestsByVariantId_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": 30,
    "is_active": true,
    "total_calls": 42,
    "total_conversions": 9,
    "total_duration_seconds": 5796,
    "avg_sentiment": 0.31,
    "created_at": "2026-09-02T10:16:30.000Z",
    "updated_at": "2026-09-15T14:45:10.000Z"
  }
}
```

**SDK Code**

```python Agents_patchAgentsByAgentIdAbTestsByVariantId_example
import requests

url = "https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b"

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

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

print(response.json())
```

```javascript Agents_patchAgentsByAgentIdAbTestsByVariantId_example
const url = 'https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b';
const options = {method: 'PATCH', 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_patchAgentsByAgentIdAbTestsByVariantId_example
package main

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

func main() {

	url := "https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b"

	req, _ := http.NewRequest("PATCH", 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_patchAgentsByAgentIdAbTestsByVariantId_example
require 'uri'
require 'net/http'

url = URI("https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b")

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

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'

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

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

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

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

$client = new \GuzzleHttp\Client();

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

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

```csharp Agents_patchAgentsByAgentIdAbTestsByVariantId_example
using RestSharp;

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

```swift Agents_patchAgentsByAgentIdAbTestsByVariantId_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/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
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()
```

### Shift traffic

**Request**

```json
{
  "weight": 30
}
```

**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": 30,
    "is_active": true,
    "total_calls": 42,
    "total_conversions": 9,
    "total_duration_seconds": 5796,
    "avg_sentiment": 0.31,
    "created_at": "2026-09-02T10:16:30.000Z",
    "updated_at": "2026-09-15T14:45:10.000Z"
  }
}
```

**SDK Code**

```python Shift traffic
import requests

url = "https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b"

payload = { "weight": 30 }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Shift traffic
const url = 'https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"weight":30}'
};

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

```go Shift traffic
package main

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

func main() {

	url := "https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b"

	payload := strings.NewReader("{\n  \"weight\": 30\n}")

	req, _ := http.NewRequest("PATCH", 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 Shift traffic
require 'uri'
require 'net/http'

url = URI("https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b")

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

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"weight\": 30\n}"

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

```java Shift traffic
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"weight\": 30\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b', [
  'body' => '{
  "weight": 30
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Shift traffic
using RestSharp;

var client = new RestClient("https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"weight\": 30\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Shift traffic
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["weight": 30] 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/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
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()
```

### Stop picking the variant

**Request**

```json
{
  "isActive": false
}
```

**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": 30,
    "is_active": true,
    "total_calls": 42,
    "total_conversions": 9,
    "total_duration_seconds": 5796,
    "avg_sentiment": 0.31,
    "created_at": "2026-09-02T10:16:30.000Z",
    "updated_at": "2026-09-15T14:45:10.000Z"
  }
}
```

**SDK Code**

```python Stop picking the variant
import requests

url = "https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b"

payload = { "isActive": False }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Stop picking the variant
const url = 'https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"isActive":false}'
};

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

```go Stop picking the variant
package main

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

func main() {

	url := "https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b"

	payload := strings.NewReader("{\n  \"isActive\": false\n}")

	req, _ := http.NewRequest("PATCH", 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 Stop picking the variant
require 'uri'
require 'net/http'

url = URI("https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b")

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

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"isActive\": false\n}"

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

```java Stop picking the variant
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"isActive\": false\n}")
  .asString();
```

```php Stop picking the variant
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b', [
  'body' => '{
  "isActive": false
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Stop picking the variant
using RestSharp;

var client = new RestClient("https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"isActive\": false\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Stop picking the variant
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["isActive": false] 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/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
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()
```

### New prompt

**Request**

```json
{
  "systemPrompt": "Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual y cierra con una pregunta de sí o no."
}
```

**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": 30,
    "is_active": true,
    "total_calls": 42,
    "total_conversions": 9,
    "total_duration_seconds": 5796,
    "avg_sentiment": 0.31,
    "created_at": "2026-09-02T10:16:30.000Z",
    "updated_at": "2026-09-15T14:45:10.000Z"
  }
}
```

**SDK Code**

```python New prompt
import requests

url = "https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b"

payload = { "systemPrompt": "Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual y cierra con una pregunta de sí o no." }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript New prompt
const url = 'https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"systemPrompt":"Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual y cierra con una pregunta de sí o no."}'
};

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

```go New prompt
package main

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

func main() {

	url := "https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b"

	payload := strings.NewReader("{\n  \"systemPrompt\": \"Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual y cierra con una pregunta de sí o no.\"\n}")

	req, _ := http.NewRequest("PATCH", 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 New prompt
require 'uri'
require 'net/http'

url = URI("https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b")

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

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"systemPrompt\": \"Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual y cierra con una pregunta de sí o no.\"\n}"

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

```java New prompt
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"systemPrompt\": \"Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual y cierra con una pregunta de sí o no.\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b', [
  'body' => '{
  "systemPrompt": "Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual y cierra con una pregunta de sí o no."
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp New prompt
using RestSharp;

var client = new RestClient("https://api.jelliu.co/api/agents/7c1e4b2a-9d3f-4e8a-b5c6-2f1a0d9e8b7c/ab-tests/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"systemPrompt\": \"Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual y cierra con una pregunta de sí o no.\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift New prompt
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["systemPrompt": "Eres Sofía, asesora de Cafés del Huila. Presenta la oferta del plan anual y cierra con una pregunta de sí o no."] 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/8e7f6a5b-4c3d-4e2f-9a1b-0c9d8e7f6a5b")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
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()
```