# Knowledge base

Manage help center collections and articles.

Scopes: `kb:read` to read (including drafts), `kb:write` to change.

| Method | Path | Description |
| --- | --- | --- |
| `GET`, `POST` | `/v1/kb/collections` | List or create collections |
| `GET`, `PATCH`, `DELETE` | `/v1/kb/collections/{id}` | |
| `GET`, `POST` | `/v1/kb/articles` | List or create articles. Filters: `collection_id`, `status`, `q` |
| `GET`, `PATCH`, `DELETE` | `/v1/kb/articles/{id}` | |

For the public, unauthenticated help center endpoints, see [Public help center and CSAT](/api/resources/public/).

## Objects

```ts
type KbCollection = { id: string; name: string; slug: string; description: string; position: number; article_count: number };

type KbArticle = {
  id: string;
  collection_id: string | null;
  title: string;
  slug: string;
  excerpt: string;
  body_html: string;
  status: "draft" | "published";
  author: UserRef | null;
  views: number;
  published_at: string | null;
  updated_at: string;
};
```

## Publish an article

```sh
curl https://api.opendesk.sh/v1/kb/articles \
  -H "Authorization: Bearer od_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "collection_id": "0192f0c4-...",
    "title": "Reset your password",
    "slug": "reset-your-password",
    "excerpt": "Get back into your account in a minute.",
    "body_html": "<p>Open the sign-in page and choose <strong>Forgot password</strong>.</p>",
    "status": "published"
  }'
```

`body_html` is sanitized before storage.

## Events

`kb_collection.*` and `kb_article.*`.
