# API: Knowledge

| Method | Path | What it does | Scope |
|---|---|---|---|
| GET | `/v1/inbox/imports` | Spreadsheets that arrived in an agent inbox and are ready to import (CSV), newest first, that you're allowed to see. Import one by posting its content to /v1/imports. | `records:read` |
| GET | `/v1/inbox/imports/:id/content` | The CSV text of an inbox spreadsheet you're allowed to see, to post to /v1/imports | `records:read` |
| PUT | `/v1/kb/:key/audience` | Who a knowledge base section is for: internal (the team), public (the website agent may quote and cite it) or private_context (it may reason with it, never show it) (owners) | `settings:write` |
| GET | `/v1/knowledge/references` | Customer references: which customers may (or may not) be named in outreach. The knowledge base's answer wins over an account's own field | `knowledge:read` |
| PUT | `/v1/knowledge/references` | Say whether a customer may be named in outreach (owner; audited) (web app only) | `settings:write` |
| DELETE | `/v1/knowledge/references/:id` | Remove a customer reference (the account's own field applies again; owner) (web app only) | `settings:write` |
| GET | `/v1/knowledge/search` | Search indexed documents you're allowed to see (source permissions are kept), plus Slack messages read live with your own Slack account and never stored | `knowledge:read` |

## Examples

### GET /v1/inbox/imports

Spreadsheets that arrived in an agent inbox and are ready to import (CSV), newest first, that you're allowed to see. Import one by posting its content to /v1/imports.

```bash
curl -s "https://api.closefinch.com/v1/inbox/imports" \
  -H "Authorization: Bearer $RA_API_KEY"
```

```js
const res = await fetch(`https://api.closefinch.com/v1/inbox/imports`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.RA_API_KEY}` },
});
const data = await res.json();
```

### GET /v1/inbox/imports/$ID/content

The CSV text of an inbox spreadsheet you're allowed to see, to post to /v1/imports

```bash
curl -s "https://api.closefinch.com/v1/inbox/imports/$ID/content" \
  -H "Authorization: Bearer $RA_API_KEY"
```

```js
const res = await fetch(`https://api.closefinch.com/v1/inbox/imports/${id}/content`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.RA_API_KEY}` },
});
const data = await res.json();
```

### PUT /v1/kb/$KEY/audience

Who a knowledge base section is for: internal (the team), public (the website agent may quote and cite it) or private_context (it may reason with it, never show it) (owners)

```bash
curl -s -X PUT "https://api.closefinch.com/v1/kb/$KEY/audience" \
  -H "Authorization: Bearer $RA_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.closefinch.com/v1/kb/${key}/audience`, {
  method: "PUT",
  headers: { authorization: `Bearer ${process.env.RA_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### GET /v1/knowledge/references

Customer references: which customers may (or may not) be named in outreach. The knowledge base's answer wins over an account's own field

```bash
curl -s "https://api.closefinch.com/v1/knowledge/references" \
  -H "Authorization: Bearer $RA_API_KEY"
```

```js
const res = await fetch(`https://api.closefinch.com/v1/knowledge/references`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.RA_API_KEY}` },
});
const data = await res.json();
```

### GET /v1/knowledge/search

Search indexed documents you're allowed to see (source permissions are kept), plus Slack messages read live with your own Slack account and never stored

```bash
curl -s "https://api.closefinch.com/v1/knowledge/search" \
  -H "Authorization: Bearer $RA_API_KEY"
```

```js
const res = await fetch(`https://api.closefinch.com/v1/knowledge/search`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.RA_API_KEY}` },
});
const data = await res.json();
```

Request and response schemas: [https://www.closefinch.com/openapi.json](https://www.closefinch.com/openapi.json). All resources: [API reference](https://www.closefinch.com/docs/api).
