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

# Chat with Agent

POST https://api.signalcore.ai/api/v1/agents/{agent_id}/chat
Content-Type: application/json

Send a message to an agent over HTTP and receive its reply. Uses the same prompt, tools, and channel profile as production text channels, without delivering to WhatsApp/SMS. Ideal for custom web chat widgets: call this from your backend with your API key. Omit `session_id` on the first turn; reuse the returned value for multi-turn conversations.

Reference: https://docs.signalcore.ai/api-reference/chat/agent

## Authentication

- `X-API-Key` header (required) — Your API key from [Dashboard → Settings → API Keys](https://dashboard.signalcore.ai/settings)

## Servers

- `https://api.signalcore.ai/api/v1` (Producción, default)
- `https://staging.api.signalcore.ai/api/v1` (Staging)

## Request

### Path parameters

- `agent_id` (string, required) — Agent ID to chat with

### Body (application/json)

This endpoint expects an AgentChatRequest.

- `message` (string, required) — User message to send to the agent
- `channel` (enum, required) — Channel profile to use for prompt, tools, and model. Use the same channel you configured for WhatsApp/SMS so behavior matches that channel.
  - Allowed values: `sms`, `whatsapp`, `instagram`, `gmail`, `outlook`, `linkedin`, `voice`, `imessage`
- `session_id` (string, optional) — Omit on the first turn to create a session. Pass the returned session_id on later turns to keep conversation context.
- `learn_from_conversation` (boolean, optional, default: false) — When true, read/write business agent memory for this session
- `contact` (AgentChatContact, optional) — Optional contact identity for the chat session (used by scheduling and similar tools)

## Response

### 200

Agent reply

- `response` (string, optional) — The agent's generated reply
- `session_id` (string, optional) — Session ID. Store this and send it on the next request.
- `conversation_history` (list of AgentChatResponseConversationHistoryItems, optional) — Conversation history for this session
- `tool_calls` (list of AgentChatResponseToolCallsItems, optional) — Tools the agent executed while generating the reply
- `usage` (AgentChatResponseUsage, optional) — Token usage for billing
- `business_memory` (AgentChatResponseBusinessMemory, optional, nullable) — Present when learn_from_conversation is true

## Errors

### 404 Not Found Error

Agent not found or does not belong to your business

- `any`

## Types

### AgentChatContact

Optional contact identity for the chat session (used by scheduling and similar tools)

- `first_name` (string, optional)
- `last_name` (string, optional)
- `email` (string, optional)
- `phone` (string, optional) — Phone number (E.164 recommended)

### AgentChatResponseConversationHistoryItems

- `role` (enum, optional)
  - Allowed values: `user`, `assistant`
- `content` (string, optional)
- `timestamp` (double, optional)
- `tool_calls` (list of AgentChatResponseConversationHistoryItemsToolCallsItems, optional)

### AgentChatResponseToolCallsItems

### AgentChatResponseUsage

Token usage for billing

- `prompt_tokens` (integer, optional)
- `completion_tokens` (integer, optional)
- `total_tokens` (integer, optional)

### AgentChatResponseBusinessMemory

Present when learn_from_conversation is true

### AgentChatResponseConversationHistoryItemsToolCallsItems

## Examples

### Chat_agent_example

**Response**

```json
{
  "response": "¡Claro! ¿Qué día te vendría bien?",
  "session_id": "550e8400-e29b-41d4-a716-446655440000",
  "conversation_history": [
    {
      "role": "user",
      "content": "Hola, quiero agendar una cita"
    },
    {
      "role": "assistant",
      "content": "¡Claro! ¿Qué día te vendría bien?"
    }
  ],
  "tool_calls": [],
  "usage": {
    "prompt_tokens": 1200,
    "completion_tokens": 40,
    "total_tokens": 1240
  }
}
```

**SDK Code**

```python Chat_agent_example
import requests

url = "https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat"

headers = {"X-API-Key": "<apiKey>"}

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

print(response.json())
```

```javascript Chat_agent_example
const url = 'https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat';
const options = {method: 'POST', headers: {'X-API-Key': '<apiKey>'}};

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

```go Chat_agent_example
package main

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

func main() {

	url := "https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat"

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

	req.Header.Add("X-API-Key", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

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

url = URI("https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat")

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

request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<apiKey>'

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

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

HttpResponse<String> response = Unirest.post("https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat")
  .header("X-API-Key", "<apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat', [
  'headers' => [
    'X-API-Key' => '<apiKey>',
  ],
]);

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

```csharp Chat_agent_example
using RestSharp;

var client = new RestClient("https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat");
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-Key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Chat_agent_example
import Foundation

let headers = ["X-API-Key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat")! 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()
```

### Start a new chat session

**Request**

```json
{
  "message": "Hola, quiero agendar una cita",
  "channel": "whatsapp"
}
```

**Response**

```json
{
  "response": "¡Claro! ¿Qué día te vendría bien?",
  "session_id": "550e8400-e29b-41d4-a716-446655440000",
  "conversation_history": [
    {
      "role": "user",
      "content": "Hola, quiero agendar una cita"
    },
    {
      "role": "assistant",
      "content": "¡Claro! ¿Qué día te vendría bien?"
    }
  ],
  "tool_calls": [],
  "usage": {
    "prompt_tokens": 1200,
    "completion_tokens": 40,
    "total_tokens": 1240
  }
}
```

**SDK Code**

```python Start a new chat session
import requests

url = "https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat"

payload = {
    "message": "Hola, quiero agendar una cita",
    "channel": "whatsapp"
}
headers = {
    "X-API-Key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Start a new chat session
const url = 'https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat';
const options = {
  method: 'POST',
  headers: {'X-API-Key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"message":"Hola, quiero agendar una cita","channel":"whatsapp"}'
};

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

```go Start a new chat session
package main

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

func main() {

	url := "https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat"

	payload := strings.NewReader("{\n  \"message\": \"Hola, quiero agendar una cita\",\n  \"channel\": \"whatsapp\"\n}")

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

	req.Header.Add("X-API-Key", "<apiKey>")
	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 Start a new chat session
require 'uri'
require 'net/http'

url = URI("https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat")

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

request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"message\": \"Hola, quiero agendar una cita\",\n  \"channel\": \"whatsapp\"\n}"

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

```java Start a new chat session
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat")
  .header("X-API-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"message\": \"Hola, quiero agendar una cita\",\n  \"channel\": \"whatsapp\"\n}")
  .asString();
```

```php Start a new chat session
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat', [
  'body' => '{
  "message": "Hola, quiero agendar una cita",
  "channel": "whatsapp"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-Key' => '<apiKey>',
  ],
]);

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

```csharp Start a new chat session
using RestSharp;

var client = new RestClient("https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat");
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"message\": \"Hola, quiero agendar una cita\",\n  \"channel\": \"whatsapp\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Start a new chat session
import Foundation

let headers = [
  "X-API-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "message": "Hola, quiero agendar una cita",
  "channel": "whatsapp"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat")! 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()
```

### Continue an existing session

**Request**

```json
{
  "message": "Mañana por la tarde me va bien",
  "channel": "whatsapp",
  "session_id": "550e8400-e29b-41d4-a716-446655440000"
}
```

**Response**

```json
{
  "response": "¡Claro! ¿Qué día te vendría bien?",
  "session_id": "550e8400-e29b-41d4-a716-446655440000",
  "conversation_history": [
    {
      "role": "user",
      "content": "Hola, quiero agendar una cita"
    },
    {
      "role": "assistant",
      "content": "¡Claro! ¿Qué día te vendría bien?"
    }
  ],
  "tool_calls": [],
  "usage": {
    "prompt_tokens": 1200,
    "completion_tokens": 40,
    "total_tokens": 1240
  }
}
```

**SDK Code**

```python Continue an existing session
import requests

url = "https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat"

payload = {
    "message": "Mañana por la tarde me va bien",
    "channel": "whatsapp",
    "session_id": "550e8400-e29b-41d4-a716-446655440000"
}
headers = {
    "X-API-Key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Continue an existing session
const url = 'https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat';
const options = {
  method: 'POST',
  headers: {'X-API-Key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"message":"Mañana por la tarde me va bien","channel":"whatsapp","session_id":"550e8400-e29b-41d4-a716-446655440000"}'
};

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

```go Continue an existing session
package main

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

func main() {

	url := "https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat"

	payload := strings.NewReader("{\n  \"message\": \"Mañana por la tarde me va bien\",\n  \"channel\": \"whatsapp\",\n  \"session_id\": \"550e8400-e29b-41d4-a716-446655440000\"\n}")

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

	req.Header.Add("X-API-Key", "<apiKey>")
	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 Continue an existing session
require 'uri'
require 'net/http'

url = URI("https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat")

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

request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"message\": \"Mañana por la tarde me va bien\",\n  \"channel\": \"whatsapp\",\n  \"session_id\": \"550e8400-e29b-41d4-a716-446655440000\"\n}"

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

```java Continue an existing session
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat")
  .header("X-API-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"message\": \"Mañana por la tarde me va bien\",\n  \"channel\": \"whatsapp\",\n  \"session_id\": \"550e8400-e29b-41d4-a716-446655440000\"\n}")
  .asString();
```

```php Continue an existing session
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat', [
  'body' => '{
  "message": "Mañana por la tarde me va bien",
  "channel": "whatsapp",
  "session_id": "550e8400-e29b-41d4-a716-446655440000"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-Key' => '<apiKey>',
  ],
]);

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

```csharp Continue an existing session
using RestSharp;

var client = new RestClient("https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat");
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"message\": \"Mañana por la tarde me va bien\",\n  \"channel\": \"whatsapp\",\n  \"session_id\": \"550e8400-e29b-41d4-a716-446655440000\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Continue an existing session
import Foundation

let headers = [
  "X-API-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "message": "Mañana por la tarde me va bien",
  "channel": "whatsapp",
  "session_id": "550e8400-e29b-41d4-a716-446655440000"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat")! 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()
```

### Pass contact identity for tools

**Request**

```json
{
  "message": "Quiero reservar",
  "channel": "whatsapp",
  "contact": {
    "first_name": "Ana",
    "email": "ana@example.com",
    "phone": "+34600111222"
  }
}
```

**Response**

```json
{
  "response": "¡Claro! ¿Qué día te vendría bien?",
  "session_id": "550e8400-e29b-41d4-a716-446655440000",
  "conversation_history": [
    {
      "role": "user",
      "content": "Hola, quiero agendar una cita"
    },
    {
      "role": "assistant",
      "content": "¡Claro! ¿Qué día te vendría bien?"
    }
  ],
  "tool_calls": [],
  "usage": {
    "prompt_tokens": 1200,
    "completion_tokens": 40,
    "total_tokens": 1240
  }
}
```

**SDK Code**

```python Pass contact identity for tools
import requests

url = "https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat"

payload = {
    "message": "Quiero reservar",
    "channel": "whatsapp",
    "contact": {
        "first_name": "Ana",
        "email": "ana@example.com",
        "phone": "+34600111222"
    }
}
headers = {
    "X-API-Key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Pass contact identity for tools
const url = 'https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat';
const options = {
  method: 'POST',
  headers: {'X-API-Key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"message":"Quiero reservar","channel":"whatsapp","contact":{"first_name":"Ana","email":"ana@example.com","phone":"+34600111222"}}'
};

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

```go Pass contact identity for tools
package main

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

func main() {

	url := "https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat"

	payload := strings.NewReader("{\n  \"message\": \"Quiero reservar\",\n  \"channel\": \"whatsapp\",\n  \"contact\": {\n    \"first_name\": \"Ana\",\n    \"email\": \"ana@example.com\",\n    \"phone\": \"+34600111222\"\n  }\n}")

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

	req.Header.Add("X-API-Key", "<apiKey>")
	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 Pass contact identity for tools
require 'uri'
require 'net/http'

url = URI("https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat")

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

request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"message\": \"Quiero reservar\",\n  \"channel\": \"whatsapp\",\n  \"contact\": {\n    \"first_name\": \"Ana\",\n    \"email\": \"ana@example.com\",\n    \"phone\": \"+34600111222\"\n  }\n}"

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

```java Pass contact identity for tools
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat")
  .header("X-API-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"message\": \"Quiero reservar\",\n  \"channel\": \"whatsapp\",\n  \"contact\": {\n    \"first_name\": \"Ana\",\n    \"email\": \"ana@example.com\",\n    \"phone\": \"+34600111222\"\n  }\n}")
  .asString();
```

```php Pass contact identity for tools
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat', [
  'body' => '{
  "message": "Quiero reservar",
  "channel": "whatsapp",
  "contact": {
    "first_name": "Ana",
    "email": "ana@example.com",
    "phone": "+34600111222"
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-Key' => '<apiKey>',
  ],
]);

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

```csharp Pass contact identity for tools
using RestSharp;

var client = new RestClient("https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat");
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"message\": \"Quiero reservar\",\n  \"channel\": \"whatsapp\",\n  \"contact\": {\n    \"first_name\": \"Ana\",\n    \"email\": \"ana@example.com\",\n    \"phone\": \"+34600111222\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Pass contact identity for tools
import Foundation

let headers = [
  "X-API-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "message": "Quiero reservar",
  "channel": "whatsapp",
  "contact": [
    "first_name": "Ana",
    "email": "ana@example.com",
    "phone": "+34600111222"
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.signalcore.ai/api/v1/agents/agt_abc123xyz/chat")! 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()
```