> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ascendgtm.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Admin API Reference

> Protected endpoints for tenant and token management.

# Admin API Reference

Protected endpoints for tenant and token management. Requires `x-admin-key` header.

## Authentication

```
x-admin-key: {admin_key}
```

The admin key is validated against the SHA-256 hash stored in the `ADMIN_API_KEY` Wrangler secret.

## Tenant Management

### GET /admin/tenants/TENANT\_ID

Read tenant configuration.

### PUT /admin/tenants/TENANT\_ID

Create or update tenant configuration.

```json theme={null}
{
  "name": "Kahuna Workforce Solutions",
  "status": "active",
  "providers": {
    "hubspot": {
      "accounts": [{"id": "default", "label": "Production"}],
      "default": "default"
    }
  }
}
```

### POST /admin/auth

Register a new tenant bearer token.

```json theme={null}
{"tenant_id": "kahuna", "token": "your-secret-bearer-token-min-16-chars"}
```

## Token Management

### PUT /admin/tokens/TENANT\_ID/PROVIDER/ACCOUNT\_ID

Store a token directly.

```json theme={null}
{
  "access_token": "...",
  "expires_at": 1712764800,
  "token_type": "Bearer"
}
```

### POST /admin/seed-oauth

Configure a Durable Object with OAuth credentials for automatic token refresh.

```json theme={null}
{
  "tenant_id": "ascend",
  "provider": "google",
  "account_id": "default",
  "client_id": "...",
  "client_secret": "...",
  "token_endpoint": "https://oauth2.googleapis.com/token",
  "refresh_token": "..."
}
```

## Billing

### GET /admin/usage/TENANT\_ID

Get usage summary for a tenant.

### PUT /admin/billing/TENANT\_ID

Update billing configuration.

## Audit Log

### GET /admin/audit

Query KV audit log. Supports filters: `tenant`, `action`, `source`, `key`, `since`, `limit`.

### GET /admin/audit/stats

Aggregated audit statistics (24h, 7d, 30d breakdowns).

## Agent Schedules

### GET /admin/agent-schedules

List all scheduled agent jobs.

### PUT /admin/agent-schedules/JOB\_ID

Create or update a scheduled agent job.

### DELETE /admin/agent-schedules/JOB\_ID

Delete a scheduled job.

## Daily Brief

### GET /admin/daily-brief

Retrieve the latest AI-generated daily GTM intelligence brief.

### POST /admin/daily-brief/trigger

Manually trigger a daily brief generation.

## System

### POST /admin/run-cron

Manually trigger a cron job. Body: `{"cron": "*/5 * * * *"}`.

### GET /admin/system-health

Returns the latest system health snapshot from KV.

### POST /admin/replay

Replay a failed request from the error ledger.

## Approval Gates

### GET /admin/approvals

List pending quality gate approvals.

### POST /admin/approvals/APPROVAL\_ID/approve

Approve a pending gate.

### POST /admin/approvals/APPROVAL\_ID/reject

Reject a pending gate with a reason.
