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

# Get campaign chat stats

GET https://api.youratlas.com/v1/api/campaign-chat/{campaignId}/stats

Aggregated message and session statistics for a campaign's chat channel. Counts sent, received and failed messages, delivery and response rates, session status buckets, and a week-over-week comparison. Past-week buckets hold rows older than seven days.

Reference: https://docs.youratlas.com/api-reference/atlas-api/campaign-chat/get-campaign-chat-stats

## Authentication

- `api-key` header (required) — Your Atlas API key. Get it from the Atlas Portal under Settings > API Keys.

## Request

### Path parameters

- `campaignId` (string, required)

## Response

### 200

Successful response

- `totals` (CampaignChatTotalStats, optional) — Aggregated chat statistics for a campaign. Past-week buckets hold messages older than seven days, matching campaign stats semantics.

## Errors

### 400 Bad Request Error

Bad request

- `error` (ErrorError, optional)

### 500 Internal Server Error

Internal server error

- `error` (ErrorError, optional)

## Types

### CampaignChatTotalStats

Aggregated chat statistics for a campaign. Past-week buckets hold messages older than seven days, matching campaign stats semantics.

- `sessions` (integer, optional) — Total number of chat sessions.
- `activeSessions` (integer, optional) — Sessions currently in `active` status.
- `completedSessions` (integer, optional) — Sessions in `completed` status.
- `handoffSessions` (integer, optional) — Sessions where human handoff is enabled.
- `messages` (integer, optional) — Total sent + received messages (excludes system/tool and undelivered).
- `messagesSent` (integer, optional) — Outbound messages that reached the contact.
- `messagesReceived` (integer, optional) — Inbound messages from the contact.
- `failedMessages` (integer, optional) — Outbound messages that failed delivery.
- `deliveryRate` (float, optional) — Percentage of attempted outbound messages that were not failed. Rounded to one decimal place.
- `responseRate` (float, optional) — Percentage of sessions with at least one user reply. Rounded to one decimal place.
- `lastMessageDate` (datetime, optional) — ISO 8601 timestamp of the most recent message, or empty string if none.
- `pastWeekMessages` (integer, optional) — Messages older than seven days.
- `messagesDifference` (float, optional) — Week-over-week percentage change. `((messages - pastWeekMessages) / pastWeekMessages) * 100`, rounded to one decimal place. `100` when there are messages but none in the past week; `0` when there are no messages at all.

### ErrorError

- `message` (string, optional)
- `code` (string, optional)
- `requestId` (string, optional)

## Examples

**Response**

```json
{
  "totals": {
    "sessions": 1,
    "activeSessions": 1,
    "completedSessions": 1,
    "handoffSessions": 1,
    "messages": 1,
    "messagesSent": 1,
    "messagesReceived": 1,
    "failedMessages": 1,
    "deliveryRate": 1.1,
    "responseRate": 1.1,
    "lastMessageDate": "2024-01-15T09:30:00Z",
    "pastWeekMessages": 1,
    "messagesDifference": 1.1
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.youratlas.com/v1/api/campaign-chat/campaignId/stats"

headers = {"api-key": "<apiKey>"}

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

print(response.json())
```

```javascript
const url = 'https://api.youratlas.com/v1/api/campaign-chat/campaignId/stats';
const options = {method: 'GET', headers: {'api-key': '<apiKey>'}};

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"
	"net/http"
	"io"
)

func main() {

	url := "https://api.youratlas.com/v1/api/campaign-chat/campaignId/stats"

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

	req.Header.Add("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
require 'uri'
require 'net/http'

url = URI("https://api.youratlas.com/v1/api/campaign-chat/campaignId/stats")

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

request = Net::HTTP::Get.new(url)
request["api-key"] = '<apiKey>'

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.get("https://api.youratlas.com/v1/api/campaign-chat/campaignId/stats")
  .header("api-key", "<apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.youratlas.com/v1/api/campaign-chat/campaignId/stats', [
  'headers' => [
    'api-key' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.youratlas.com/v1/api/campaign-chat/campaignId/stats");
var request = new RestRequest(Method.GET);
request.AddHeader("api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.youratlas.com/v1/api/campaign-chat/campaignId/stats")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
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()
```