# Knowledge base

Search the knowledge base.

## Help articles for this site

`GET /sites/{site_id}/help` · scope `sites:read`

Knowledge-base articles that fit what is going on with this site right now (why it is paused, nameservers not pointed, offline...), with app and public links.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `site_id` | path | integer | yes | The site id (see GET /sites). |

### Example

```bash
curl -s "https://app.pbn.ltd/api/v1/sites/123/help" \
  -H "Authorization: Bearer $PBN_API_KEY"
```

```python
import os
import requests

headers = {"Authorization": "Bearer " + os.environ["PBN_API_KEY"]}
r = requests.get("https://app.pbn.ltd/api/v1/sites/123/help", headers=headers, timeout=120)
print(r.status_code, r.json())
```

```javascript
const res = await fetch("https://app.pbn.ltd/api/v1/sites/123/help", {
  method: "GET",
  headers: {Authorization: `Bearer ${process.env.PBN_API_KEY}`}
});
console.log(res.status, await res.json());
```

### Response

`200`

```json
{
  "data": {
    "site_id": 123,
    "topics": [
      "change nameservers at registrar"
    ],
    "articles": [
      {
        "title": "How to change nameservers",
        "slug": "change-nameservers",
        "app_url": "https://app.pbn.ltd/kb/a/change-nameservers/",
        "public_url": "https://pbn.ltd/knowledgebase/change-nameservers/",
        "because": "change nameservers at registrar"
      }
    ]
  }
}
```

Errors: `not_found`, `rate_limited`, `scope_missing`, `unauthorized`

## Search the knowledge base

`GET /kb/search` · scope `kb:read`

The dashboard's knowledge-base search (keyword + meaning). Every key may use it.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `q` | query | string | yes | What you are looking for, in plain words. |
| `limit` | query | integer | no | At most this many. Default: `8`. |

### Example

```bash
curl -s "https://app.pbn.ltd/api/v1/kb/search?q=change+nameservers" \
  -H "Authorization: Bearer $PBN_API_KEY"
```

```python
import os
import requests

headers = {"Authorization": "Bearer " + os.environ["PBN_API_KEY"]}
r = requests.get("https://app.pbn.ltd/api/v1/kb/search?q=change+nameservers", headers=headers, timeout=120)
print(r.status_code, r.json())
```

```javascript
const res = await fetch("https://app.pbn.ltd/api/v1/kb/search?q=change+nameservers", {
  method: "GET",
  headers: {Authorization: `Bearer ${process.env.PBN_API_KEY}`}
});
console.log(res.status, await res.json());
```

### Response

`200`

```json
{
  "data": {
    "query": "change nameservers",
    "mode": "semantic",
    "confident": true,
    "note": null,
    "results": [
      {
        "title": "How to change nameservers",
        "category": "DNS",
        "snippet": "...",
        "slug": "change-nameservers",
        "app_url": "https://app.pbn.ltd/kb/a/change-nameservers/",
        "public_url": "https://pbn.ltd/knowledgebase/change-nameservers/"
      }
    ]
  }
}
```

Errors: `rate_limited`, `scope_missing`, `unauthorized`

## Read an article

`GET /kb/articles/{slug}` · scope `kb:read`

One article as plain text and as sanitised HTML, with related articles.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `slug` | path | string | yes | Article slug from a search result. |

### Example

```bash
curl -s "https://app.pbn.ltd/api/v1/kb/articles/change-nameservers" \
  -H "Authorization: Bearer $PBN_API_KEY"
```

```python
import os
import requests

headers = {"Authorization": "Bearer " + os.environ["PBN_API_KEY"]}
r = requests.get("https://app.pbn.ltd/api/v1/kb/articles/change-nameservers", headers=headers, timeout=120)
print(r.status_code, r.json())
```

```javascript
const res = await fetch("https://app.pbn.ltd/api/v1/kb/articles/change-nameservers", {
  method: "GET",
  headers: {Authorization: `Bearer ${process.env.PBN_API_KEY}`}
});
console.log(res.status, await res.json());
```

### Response

`200`

```json
{
  "data": {
    "slug": "change-nameservers",
    "title": "How to change nameservers",
    "category": "DNS",
    "excerpt": "...",
    "text": "plain text...",
    "html": "<p>...</p>",
    "updated_at": null,
    "app_url": "https://app.pbn.ltd/kb/a/change-nameservers/",
    "public_url": "https://pbn.ltd/knowledgebase/change-nameservers/",
    "related": []
  }
}
```

Errors: `not_found`, `rate_limited`, `scope_missing`, `unauthorized`
