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

# Chat with an agent (text mode)

POST https://api.voicebip.com/v1/agents/{agent_id}/playground
Content-Type: application/json

Sends a text message to the agent and returns the AI response.
Uses the agent's configured system_prompt, ai_provider, and ai_model.
Pass conversation history to maintain context across turns.
Does not create a call or use telephony. Intended for testing
the agent's prompt before making live calls.

Reference: https://docs.voicebip.com/api/agents/agent-playground

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Servers

- `https://api.voicebip.com` (Production, default)
- `https://sandbox.voicebip.com` (Sandbox)

## Request

### Path parameters

- `agent_id` (string, required)

### Body (application/json)

This endpoint expects an object.

- `message` (string, required) — The user's text message
- `history` (list of AgentPlaygroundRequestHistoryItem, optional) — Previous conversation turns for context
- `channel` (enum, optional, default: voice) — Channel context for the simulation (Phase I). `voice` (default) returns just the AI reply. `sms` / `whatsapp` augment the system prompt with channel-specific guidance (brevity, no markdown for SMS; minimal markdown for WhatsApp) AND return a `validation` block with length / encoding / segment metadata so developers see whether the reply fits channel constraints BEFORE wiring the live path.
  - Allowed values: `voice`, `sms`, `whatsapp`

## Response

### 200

Agent response

- `response` (string, required) — The agent's AI-generated response
- `channel` (enum, required) — Echo of the request channel
  - Allowed values: `voice`, `sms`, `whatsapp`
- `validation` (AgentPlaygroundResponseValidation, optional) — Messaging-channel reply metadata. Present only for `sms` and `whatsapp` channels. Omitted for `voice`.

## Errors

### 400 Agent Playground Request Bad Request Error

Invalid request (e.g. unknown channel)

- `error_code` (enum, required)
  - Allowed values: `NOT_FOUND`, `ALREADY_EXISTS`, `INVALID_ARGUMENT`, `PERMISSION_DENIED`, `UNAUTHENTICATED`, `RATE_LIMITED`, `INTERNAL`, `UNAVAILABLE`, `QUOTA_EXCEEDED`, `NUMBER_UNAVAILABLE`, `CALL_FAILED`, `MESSAGE_FAILED`, `WEBHOOK_FAILED`, `AI_PROVIDER_ERROR`, `CALL_WINDOW_RESTRICTED`, `INVALID_REQUEST`, `INVALID_PLAN`, `NO_OP`, `NO_ACTIVE_SUBSCRIPTION`, `WORKSPACE_NOT_FOUND`, `TIER_SWITCH_UNSUPPORTED`, `INSUFFICIENT_BALANCE`, `WORKSPACE_BLOCKED`, `TIER_SWITCH_TOO_FREQUENT`, `CHANNEL_MISMATCH`, `OPT_OUT_ENFORCED`, `UPSTREAM_ERROR`, `REQUEST_BODY_TOO_LARGE`, `INVALID_BODY`, `AI_ERROR`, `ADMIN_DISABLED`, `STORE_UNAVAILABLE`, `ADMIN_DB_UNAVAILABLE`, `MISSING_ACTOR`, `ACTOR_TOO_LONG`, `MISSING_FIELD`, `INVALID_JSON`, `INVALID_AMOUNT`, `INVALID_INCLUDED_QTY`, `INVALID_CURRENCY`, `INVALID_PROFILE`, `INVALID_RESOURCE`, `INVALID_UNIT`, `INVALID_TIER`, `INVALID_EFFECTIVE_FROM`, `NOTES_TOO_LONG`, `INVALID_LIMIT`, `LIST_FAILED`, `UPSERT_FAILED`, `WORKSPACE_OVERRIDE_DISABLED`, `WORKSPACE_OVERRIDE_UNCONFIRMED`, `MISSING_WORKSPACE_HEADER`, `INVALID_PASSWORD`, `INVALID_EMAIL`, `INVALID_CREDENTIALS`, `EMAIL_EXISTS`, `EMAIL_NOT_VERIFIED`, `WEAK_PASSWORD`, `MISSING_COMPANY`, `MISSING_TOKEN`, `INVALID_TOKEN`, `TOO_MANY_ATTEMPTS`
- `message` (string, required)
- `request_id` (string, required)
- `documentation_url` (string, optional)

### 404 Agent Playground Request Not Found Error

Not found

- `error_code` (enum, required)
  - Allowed values: `NOT_FOUND`, `ALREADY_EXISTS`, `INVALID_ARGUMENT`, `PERMISSION_DENIED`, `UNAUTHENTICATED`, `RATE_LIMITED`, `INTERNAL`, `UNAVAILABLE`, `QUOTA_EXCEEDED`, `NUMBER_UNAVAILABLE`, `CALL_FAILED`, `MESSAGE_FAILED`, `WEBHOOK_FAILED`, `AI_PROVIDER_ERROR`, `CALL_WINDOW_RESTRICTED`, `INVALID_REQUEST`, `INVALID_PLAN`, `NO_OP`, `NO_ACTIVE_SUBSCRIPTION`, `WORKSPACE_NOT_FOUND`, `TIER_SWITCH_UNSUPPORTED`, `INSUFFICIENT_BALANCE`, `WORKSPACE_BLOCKED`, `TIER_SWITCH_TOO_FREQUENT`, `CHANNEL_MISMATCH`, `OPT_OUT_ENFORCED`, `UPSTREAM_ERROR`, `REQUEST_BODY_TOO_LARGE`, `INVALID_BODY`, `AI_ERROR`, `ADMIN_DISABLED`, `STORE_UNAVAILABLE`, `ADMIN_DB_UNAVAILABLE`, `MISSING_ACTOR`, `ACTOR_TOO_LONG`, `MISSING_FIELD`, `INVALID_JSON`, `INVALID_AMOUNT`, `INVALID_INCLUDED_QTY`, `INVALID_CURRENCY`, `INVALID_PROFILE`, `INVALID_RESOURCE`, `INVALID_UNIT`, `INVALID_TIER`, `INVALID_EFFECTIVE_FROM`, `NOTES_TOO_LONG`, `INVALID_LIMIT`, `LIST_FAILED`, `UPSERT_FAILED`, `WORKSPACE_OVERRIDE_DISABLED`, `WORKSPACE_OVERRIDE_UNCONFIRMED`, `MISSING_WORKSPACE_HEADER`, `INVALID_PASSWORD`, `INVALID_EMAIL`, `INVALID_CREDENTIALS`, `EMAIL_EXISTS`, `EMAIL_NOT_VERIFIED`, `WEAK_PASSWORD`, `MISSING_COMPANY`, `MISSING_TOKEN`, `INVALID_TOKEN`, `TOO_MANY_ATTEMPTS`
- `message` (string, required)
- `request_id` (string, required)
- `documentation_url` (string, optional)

### 503 Agent Playground Request Service Unavailable Error

AI service unavailable

- `any`

## Types

### AgentPlaygroundRequestHistoryItem

- `role` (enum, optional)
  - Allowed values: `user`, `agent`
- `text` (string, optional)

### AgentPlaygroundResponseValidation

Messaging-channel reply metadata. Present only for `sms` and `whatsapp` channels. Omitted for `voice`.

- `channel` (enum, optional)
  - Allowed values: `sms`, `whatsapp`
- `length` (integer, optional) — Byte length of the response.
- `rune_count` (integer, optional) — Unicode code-point count.
- `encoding` (enum, optional) — SMS only. GSM-7 (160/segment) or UCS-2 (70/segment).
  - Allowed values: `GSM7`, `UCS2`
- `segments` (integer, optional) — SMS only. Number of SMS segments the reply would split into.
- `fits_one_segment` (boolean, optional) — SMS only. true if the reply fits a single 160/70-char segment.
- `exceeds_carrier_limit` (boolean, optional) — SMS only. true if segments > 10 (carrier-reliability ceiling).
- `fits_single_message` (boolean, optional) — WhatsApp only. true if the reply fits the 4096-char single-message limit.
- `exceeds_limit` (boolean, optional) — WhatsApp only. Inverse of fits_single_message.

## Examples

**Request**

```json
{
  "message": "message"
}
```

**Response**

```json
{
  "response": "response",
  "channel": "voice",
  "validation": {
    "channel": "sms",
    "length": 1,
    "rune_count": 1,
    "encoding": "GSM7",
    "segments": 1,
    "fits_one_segment": true,
    "exceeds_carrier_limit": true,
    "fits_single_message": true,
    "exceeds_limit": true
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.voicebip.com/v1/agents/agent_id/playground"

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

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

print(response.json())
```

```javascript
const url = 'https://api.voicebip.com/v1/agents/agent_id/playground';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"message":"message"}'
};

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

```go
package main

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

func main() {

	url := "https://api.voicebip.com/v1/agents/agent_id/playground"

	payload := strings.NewReader("{\n  \"message\": \"message\"\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
require 'uri'
require 'net/http'

url = URI("https://api.voicebip.com/v1/agents/agent_id/playground")

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  \"message\": \"message\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.voicebip.com/v1/agents/agent_id/playground")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"message\": \"message\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.voicebip.com/v1/agents/agent_id/playground', [
  'body' => '{
  "message": "message"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.voicebip.com/v1/agents/agent_id/playground");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"message\": \"message\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["message": "message"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.voicebip.com/v1/agents/agent_id/playground")! 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()
```