# Intelligence Digests & Metrics API Reference

> Platform documentation snapshot. Access, charging and provider requirements remain operation-specific; examples do not execute requests.

### What it does

Schedule recurring roll-ups of your workspace's intelligence events to Slack or a webhook, inspect delivery history, and read platform observability metrics with live signal calibration multipliers. No credits are consumed.

### Use cases

- Send the product team a daily digest of high-scoring signals across tracked companies.
- Mirror every intelligence event into your CRM or data warehouse via webhook.
- Review calibration multipliers to see which signal types are the most accurate for your workspace.

### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `target` | string | HTTPS endpoint that receives the digest — a webhook URL or a Slack incoming-webhook URL (required on create) |
| `name` | string | Digest display name (max 120 chars, default: "Intelligence digest") |
| `cadence` | "daily" | "weekly" | How often the digest is sent. Default "daily". |
| `channel` | "webhook" | "slack" | Delivery channel. Default "webhook". |
| `event_types` | string[] | Restrict the digest to these event types (subset of the supported event types; empty = all) |
| `signal_types` | string[] | Restrict to these signal types (max 30) |
| `min_score` | integer | Only include items scoring at least this value (0-100, default 0) |
| `digest_ref` | string | Digest identifier (rule_xxxx style), used by update/delete/send/sends |
| `days` | integer | Metrics lookback window in days (1-90, default 14) |

### Response Schema

_Complete documented fields for this section, with nested notation preserved. Endpoint-specific envelopes, availability and additional fields are described under each endpoint below._

| Field | Notes |
|-------|-------|
| digests[] → digest_ref, name, cadence, channel, target, event_types, signal_types, min_score, is_active, last_sent_at, next_send_at, sends_count, created_at | |
| digest → digest_ref, name, cadence, channel, target, is_active, next_send_at | |
| sends[] → period_start, period_end, event_count, company_count, status, response_status, error, created_at | |
| metrics → days, totals, metrics[] (day, metric, dims, value), calibration[] (signal_type, accurate_count, inaccurate_count, unclear_count, multiplier, updated_at) | |

**Illustrative Example Response (synthetic, not a complete endpoint schema):**

```json
{
  "data": {
    "digests": [
      {
        "digest_ref": "string",
        "name": "string",
        "cadence": "string",
        "channel": "string",
        "target": "string",
        "event_types": "string",
        "signal_types": "string",
        "min_score": 0,
        "is_active": false,
        "last_sent_at": "2025-06-01T12:00:00Z",
        "next_send_at": "2025-06-01T12:00:00Z",
        "sends_count": 0,
        "created_at": "2025-06-01T12:00:00Z"
      }
    ],
    "digest": {
      "digest_ref": "string",
      "name": "string",
      "cadence": "string",
      "channel": "string",
      "target": "string",
      "is_active": false,
      "next_send_at": "2025-06-01T12:00:00Z"
    },
    "sends": [
      {
        "period_start": "string",
        "period_end": "string",
        "event_count": 0,
        "company_count": 0,
        "status": "string",
        "response_status": "string",
        "error": "string",
        "created_at": "2025-06-01T12:00:00Z"
      }
    ],
    "metrics": {
      "days": "string",
      "totals": "string",
      "metrics[] (day": "string",
      "metric": "string",
      "dims": "string",
      "value)": 0,
      "calibration[] (signal_type": "string",
      "accurate_count": 0,
      "inaccurate_count": 0,
      "unclear_count": 0,
      "multiplier": "string",
      "updated_at)": "2025-06-01T12:00:00Z"
    }
  }
}
```

### GET /company/intelligence/digests — List Digests

All scheduled intelligence digests for your workspace, with their next send time. Free.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/company/intelligence/digests",
  "method": "GET"
}'
```

### POST /company/intelligence/digests — Create Digest

Schedule a recurring roll-up of your workspace's intelligence events, delivered to a webhook or Slack. Free — delivery admin does not consume credits.

**Example Request Body:**

```json
{
  "name": "Weekly Competitive Digest",
  "target": "https://hooks.slack.com/services/…",
  "cadence": "weekly",
  "channel": "slack",
  "event_types": [
    "signal.detected"
  ],
  "min_score": 70
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/company/intelligence/digests",
  "method": "POST",
  "body": {
    "name": "Weekly Competitive Digest",
    "target": "https://hooks.slack.com/services/…",
    "cadence": "weekly",
    "channel": "slack",
    "event_types": [
      "signal.detected"
    ],
    "min_score": 70
  }
}'
```

### POST /company/intelligence/digests/update — Update Digest

Change a digest's name, target, cadence, channel, event/signal filters, minimum score or active flag. Free.

**Example Request Body:**

```json
{
  "digest_ref": "dig_1a2b3c4d5e6f",
  "cadence": "daily",
  "is_active": true
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/company/intelligence/digests/update",
  "method": "POST",
  "body": {
    "digest_ref": "dig_1a2b3c4d5e6f",
    "cadence": "daily",
    "is_active": true
  }
}'
```

### POST /company/intelligence/digests/delete — Delete Digest

Remove a scheduled digest. Free.

**Example Request Body:**

```json
{
  "digest_ref": "dig_1a2b3c4d5e6f"
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/company/intelligence/digests/delete",
  "method": "POST",
  "body": {
    "digest_ref": "dig_1a2b3c4d5e6f"
  }
}'
```

### POST /company/intelligence/digests/send — Send Digest Now

Trigger an immediate digest run outside the schedule and deliver it to the configured target. Free.

**Example Request Body:**

```json
{
  "digest_ref": "dig_1a2b3c4d5e6f"
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/company/intelligence/digests/send",
  "method": "POST",
  "body": {
    "digest_ref": "dig_1a2b3c4d5e6f"
  }
}'
```

### POST /company/intelligence/digests/sends — List Digest Sends

Delivery history for one digest (or all digests): the period covered, event/company counts and delivery status. Free.

**Example Request Body:**

```json
{
  "digest_ref": "dig_1a2b3c4d5e6f",
  "limit": 50
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/company/intelligence/digests/sends",
  "method": "POST",
  "body": {
    "digest_ref": "dig_1a2b3c4d5e6f",
    "limit": 50
  }
}'
```

### POST /company/intelligence/metrics — Get Intelligence Metrics

Platform observability for your workspace: daily counters over a lookback window plus live signal calibration multipliers. Free.

**Example Request Body:**

```json
{
  "days": 14
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/company/intelligence/metrics",
  "method": "POST",
  "body": {
    "days": 14
  }
}'
```

