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

# Retrieve campaign analytics

GET https://api.jelliu.co/api/analytics/campaigns/{campaignId}

Returns the all-time results of one campaign: interactions, completed calls, successes,
success rate, average duration, average sentiment and the count of every outcome. There
is no `days` window; for a windowed view of one campaign use
`GET /api/analytics/overview?campaignId=...` or `GET /api/analytics/calls-per-day?campaignId=...`.

**Success is category-specific here.** Successes are counted with the campaign's own
success outcomes (for `sales` only `sale_closed`; for `scheduling`
`appointment_booked` and `appointment_rescheduled`; and so on), which is stricter than
the cross-category definition used by the overview and leaderboards. `successRateLabel`
names the rate the way the category does (`conversionRate`, `bookingRate`, ...). An
unrecognised stored category is treated as `general`.

**Filters.** `direction` narrows every number; an unknown value is ignored and treated
as `all` (no `400`).

**Partial failure.** The aggregates and the outcome breakdown are read in parallel. If
one of them fails, the response is still `200` with that part zeroed and its name listed
in `_degraded`. When nothing failed, `_degraded` is absent.

**No data.** Counts and `successRate` are `0`, `outcomeBreakdown` is `{}`, `avgSentiment`
is `null`. `averageDurationSeconds` is `0` for a voice campaign without completed calls
and `null` for any other channel.

**Idempotency.** Safe to retry: this is a read.

**Consistency.** Cached for 120 seconds, then served stale for up to 15 minutes while a
background refresh runs. A `404` is never cached.

**Access**

* **Required scope:** `read`. Signed-in users need the owner, admin, member or viewer role.
* **Rate limit:** Analytics — 30 requests/min per workspace, in addition to the general API budget of your plan. See [Rate limits](/rate-limits).
* **Plan:** Available on every plan. A workspace without an active subscription (active, trialing or past due) gets `403 BILLING_ERROR`.

Reference: https://developer.jelliu.co/api-reference/analytics/get-analytics-campaigns-by-campaign-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

- `campaignId` (string, required) — Id of a campaign in your workspace. Deleted campaigns answer `404`.

### Query parameters

- `direction` (enum, optional, default: all) — Restrict the numbers to inbound or outbound calls. `all` (the default) counts both. An unknown value is ignored and treated as `all`.
  - Allowed values: `inbound`, `outbound`, `all`

## Response

### 200

The campaign's all-time analytics.

- `data` (object, optional)
  - `campaignId` (string, optional) — The campaign these numbers belong to (echo of the path id).
  - `channel` (string, optional) — Campaign channel: `voice`, `whatsapp`, `webchat` or `email`. Defaults to `voice` when unset.
  - `category` (string, optional) — Campaign category after normalisation (`sales`, `support`, `scheduling`, `surveys`, `collections`, `retention`, `notifications`, `interview`, `language_assessment`, `personal`, `general`). Unknown stored values become `general`.
  - `totalInteractions` (integer, optional) — Every call of the campaign, in any status.
  - `completedInteractions` (integer, optional) — Calls with status `completed`.
  - `successes` (integer, optional) — Calls whose outcome is one of the category's success outcomes.
  - `successRate` (double, optional) — Percentage 0-100, `successes / completedInteractions`, two decimals, capped at 100. `0` when nothing completed.
  - `successRateLabel` (enum, optional) — Category-specific name of `successRate`.
    - Allowed values: `conversionRate`, `resolutionRate`, `bookingRate`, `completionRate`, `recoveryRate`, `retentionRate`, `deliveryRate`, `interviewRate`, `assessmentRate`, `successRate`
  - `averageDurationSeconds` (integer, optional, nullable) — Mean duration of completed calls, whole seconds. `0` for a voice campaign without completed calls; `null` for non-voice campaigns.
  - `avgSentiment` (double, optional, nullable) — Mean sentiment (-1 to 1) over scored calls, two decimals. `null` when no call was scored.
  - `outcomeBreakdown` (map from string to integer, optional) — Number of calls per outcome value, any status. Outcomes with no calls are absent.
  - `excludedMetrics` (list of enum, optional) — Metrics that do not apply to this channel and category and should not be shown: `averageDurationSeconds`, `callsByHour` and `prepaidMinutes` for non-voice channels; `conversionRate` for `support` and `scheduling`.
    - Allowed values: `averageDurationSeconds`, `callsByHour`, `prepaidMinutes`, `conversionRate`
  - `_degraded` (list of enum, optional) — Present only when part of the computation failed. `aggregates`: totals, completed, duration and sentiment are zero/null. `outcomeBreakdown`: the breakdown is `{}` and `successes` is 0.
    - Allowed values: `aggregates`, `outcomeBreakdown`

## Errors

### 400 Bad Request Error

The campaign id is not a UUID.

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

No active subscription, a signed-in role outside owner/admin/member/viewer, an API key without the `read` scope, or a suspended 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).

### 404 Not Found Error

The campaign does not exist, was deleted or belongs to another 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

The analytics budget (30 requests/min) or the plan's general API budget is 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

### A voice sales campaign

**Response**

```json
{
  "data": {
    "campaignId": "3f2b8c1e-7a4d-4e9b-9c21-5d8e6f1a2b30",
    "channel": "voice",
    "category": "sales",
    "totalInteractions": 1142,
    "completedInteractions": 968,
    "successes": 247,
    "successRate": 25.52,
    "successRateLabel": "conversionRate",
    "averageDurationSeconds": 197,
    "avgSentiment": 0.29,
    "outcomeBreakdown": {
      "callback_scheduled": 158,
      "follow_up_needed": 61,
      "no_answer": 196,
      "rejected": 231,
      "sale_closed": 247,
      "voicemail": 142
    },
    "excludedMetrics": []
  }
}
```

**SDK Code**

```python A voice sales campaign
import requests

url = "https://api.jelliu.co/api/analytics/campaigns/3f2b8c1e-7a4d-4e9b-9c21-5d8e6f1a2b30"

querystring = {"direction":"outbound"}

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

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

print(response.json())
```

```javascript A voice sales campaign
const url = 'https://api.jelliu.co/api/analytics/campaigns/3f2b8c1e-7a4d-4e9b-9c21-5d8e6f1a2b30?direction=outbound';
const options = {method: 'GET', 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 A voice sales campaign
package main

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

func main() {

	url := "https://api.jelliu.co/api/analytics/campaigns/3f2b8c1e-7a4d-4e9b-9c21-5d8e6f1a2b30?direction=outbound"

	req, _ := http.NewRequest("GET", 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 A voice sales campaign
require 'uri'
require 'net/http'

url = URI("https://api.jelliu.co/api/analytics/campaigns/3f2b8c1e-7a4d-4e9b-9c21-5d8e6f1a2b30?direction=outbound")

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

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

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

```java A voice sales campaign
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.jelliu.co/api/analytics/campaigns/3f2b8c1e-7a4d-4e9b-9c21-5d8e6f1a2b30?direction=outbound")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php A voice sales campaign
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.jelliu.co/api/analytics/campaigns/3f2b8c1e-7a4d-4e9b-9c21-5d8e6f1a2b30?direction=outbound', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp A voice sales campaign
using RestSharp;

var client = new RestClient("https://api.jelliu.co/api/analytics/campaigns/3f2b8c1e-7a4d-4e9b-9c21-5d8e6f1a2b30?direction=outbound");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift A voice sales campaign
import Foundation

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.jelliu.co/api/analytics/campaigns/3f2b8c1e-7a4d-4e9b-9c21-5d8e6f1a2b30?direction=outbound")! 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()
```

### The outcome query failed

**Response**

```json
{
  "data": {
    "campaignId": "b71e0d42-19c5-4a8f-a3e6-0c94d2f7e815",
    "channel": "voice",
    "category": "scheduling",
    "totalInteractions": 96,
    "completedInteractions": 88,
    "successes": 0,
    "successRate": 0,
    "successRateLabel": "bookingRate",
    "averageDurationSeconds": 142,
    "avgSentiment": 0.44,
    "outcomeBreakdown": {},
    "excludedMetrics": [
      "conversionRate"
    ],
    "_degraded": [
      "outcomeBreakdown"
    ]
  }
}
```

**SDK Code**

```python The outcome query failed
import requests

url = "https://api.jelliu.co/api/analytics/campaigns/3f2b8c1e-7a4d-4e9b-9c21-5d8e6f1a2b30"

querystring = {"direction":"outbound"}

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

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

print(response.json())
```

```javascript The outcome query failed
const url = 'https://api.jelliu.co/api/analytics/campaigns/3f2b8c1e-7a4d-4e9b-9c21-5d8e6f1a2b30?direction=outbound';
const options = {method: 'GET', 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 The outcome query failed
package main

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

func main() {

	url := "https://api.jelliu.co/api/analytics/campaigns/3f2b8c1e-7a4d-4e9b-9c21-5d8e6f1a2b30?direction=outbound"

	req, _ := http.NewRequest("GET", 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 The outcome query failed
require 'uri'
require 'net/http'

url = URI("https://api.jelliu.co/api/analytics/campaigns/3f2b8c1e-7a4d-4e9b-9c21-5d8e6f1a2b30?direction=outbound")

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

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

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

```java The outcome query failed
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.jelliu.co/api/analytics/campaigns/3f2b8c1e-7a4d-4e9b-9c21-5d8e6f1a2b30?direction=outbound")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php The outcome query failed
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.jelliu.co/api/analytics/campaigns/3f2b8c1e-7a4d-4e9b-9c21-5d8e6f1a2b30?direction=outbound', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp The outcome query failed
using RestSharp;

var client = new RestClient("https://api.jelliu.co/api/analytics/campaigns/3f2b8c1e-7a4d-4e9b-9c21-5d8e6f1a2b30?direction=outbound");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift The outcome query failed
import Foundation

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.jelliu.co/api/analytics/campaigns/3f2b8c1e-7a4d-4e9b-9c21-5d8e6f1a2b30?direction=outbound")! 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()
```