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

# Spaces API

> Browse, search and edit documentation spaces page by page, like files, through the Public API v1 and MCP

A space is a knowledge source written in AGO whose pages are addressed by path. AI assistants and scripts work on it the way coding assistants work on files: list the tree, search for exact text, read a few lines, then replace a string. Every change is saved as a version that records who made it.

## Before you start

* **Docs must be enabled for your workspace.** AGO enables Docs per workspace: ask AGO support to turn it on. Until then, every `/spaces` endpoint answers `403` with the code `docs_disabled`, the MCP server does not list the space tools, and calling one fails with the same code. Turning Docs off keeps your spaces, their pages and their access, but agents stop answering from them until it is on again.
* **Scopes**: `knowledge:read` to list, read and search spaces. `knowledge:write` to create spaces and to change pages. `knowledge:write` includes `knowledge:read`. Create the key in **Studio** > **API Keys**. See [API Key Authentication](https://ago.mintlify.site/security/api-key-authentication.md).
* **A scope is not enough.** Each space decides who can use it, and at which level: see [Access](#access). A space you have no access to does not appear at all.
* **Spaces are written in AGO.** A source synced from another system (Zendesk, Confluence, SharePoint...) cannot become a space: its original stays the source of truth. Keep using the document endpoints and tools for those sources.
* **A new space is internal** and is not attached to any agent.
* **Changes are attributed.** Each version records the API key (its name and prefix) or the OAuth application that made it, and the user behind it: the key's creator, or the user who granted OAuth access.

## Access

Every space is closed by default: only the people and keys it was opened to can see it. Each one has a level:

| Level | What it allows |
| - | - |
| `read` | List the space, read its pages, search them and read their history. |
| `propose` | Everything `read` allows, plus suggesting changes. An edit or a page replacement is saved as a proposal for review; the page itself is not changed. |
| `write` | Everything, including creating, moving, renaming and deleting pages, and accepting or rejecting proposals. |

* **Who has access.** A space can be opened to everyone who uses Docs (admins and Docs members), to a permission group, or to a specific API key. The space's owner has `write` access for as long as they are an admin or a Docs admin. When several of these apply to you, you get the highest level.
* **API keys only get what was granted to the key.** A key does not inherit the access of the person who created it.
* **OAuth applications act with the access of the user who connected them.**
* **The scope caps the level.** With `knowledge:read` only, you read, whatever your level on the space.
* **Creating a space opens it to its creator.** A space created with an API key gives that key `write` access; the key's creator owns the space. Turning a source into a space works the same way. Nobody else sees the space until its access is changed.
* **Who creates spaces.** Admins and Docs admins create spaces and turn sources into spaces. An API key with the `knowledge:write` scope can do the same, and is given `write` access to the space it creates. A Docs member who is neither an admin nor a Docs admin works only in the spaces opened to them.
* **Changing access happens in AGO, never through the API or MCP**, so a key can never widen its own access. A space is managed by its owner and by Docs admins (super admins are always Docs admins): they open it, change levels, choose the agents that answer from it, rename it, hand it to another owner and delete it. Managing a space does not let you read it: a Docs admin reads a space only when it is opened to them. The owner must be an admin or a Docs admin. See [Docs roles](https://ago.mintlify.site/features/admin-user-management.md#roles).
* **Agents.** An agent answers from a space only when the space's manager has attached it to that agent, in the space's settings. Attaching a space shares its content with everyone who can talk to the agent. Attaching needs a manager who can also configure agents, that is an admin; any manager can detach a space. The agent's answers use the space's pages without citing them or linking to them, and the agent's settings show which spaces it answers from.
* **Rotating an API key.** The new key keeps the old key's access to the spaces that the person rotating it manages. Access to other spaces is not carried over: ask their owner or a Docs admin to open them to the new key. The old key keeps its access until it stops working. AGO tells you how many space accesses were carried over and how many were not.

Every space in `GET /spaces` and `list_spaces` carries your `level` on it. A call that needs a higher level fails with `403` `insufficient_space_access`; the error gives the `required_level` and your `level`.

## Addresses

A page is addressed as `<space>/<path>`, for example `handbook/onboarding/first-week`. The space name alone (`handbook`) is the space root.

* A space name is lowercase letters and digits separated by single `-` or `_`, such as `engineering-handbook`.
* Each path segment comes from the page title: `First Week!` becomes `first-week`. A page whose title gives the same segment as a sibling's gets a suffix (`first-week-2`). The response of every write gives the page's actual address.
* Renaming a page, or moving it to another parent, changes its address and the address of every page below it.

## Operations

| Operation | REST (`/api/v1`) | MCP tool | Scope |
| - | - | - | - |
| List spaces | `GET /spaces` | `list_spaces` | read |
| Create a space | `POST /spaces` | `create_space` | write |
| Turn a source written in AGO into a space | `POST /spaces/convert` | `convert_source_to_space` | write |
| List pages under a space or a page | `GET /spaces/tree` | `get_space_tree` | read |
| Read a page | `GET /spaces/pages` | `read_space_page` | read |
| Find exact text | `POST /spaces/grep` | `grep_space_pages` | read |
| Find pages by meaning | `POST /spaces/search` | `search_space_pages` | read |
| Replace a string in a page | `POST /spaces/pages/edit` | `edit_space_page` | write |
| Replace a whole page | `PUT /spaces/pages` | `write_space_page` with `address` | write |
| Create a page | `POST /spaces/pages` | `write_space_page` with `parent` and `title` | write |
| Move, reorder or rename a page | `POST /spaces/pages/move` | `move_space_page` | write |
| Delete a page and the pages below it | `DELETE /spaces/pages?address=...` | `delete_space_page` | write |
| List a page's versions | `GET /spaces/pages/versions` | `list_space_page_versions` | read |
| Read one version | `GET /spaces/pages/versions/{version_number}` | `get_space_page_version` | read |
| List proposals | `GET /spaces/proposals` | `list_space_proposals` | read |
| Read a proposal with its content | `GET /spaces/proposals/{proposal_id}` | `get_space_proposal` | read |
| Accept a proposal | `POST /spaces/proposals/{proposal_id}/accept` | `accept_space_proposal` | write |
| Reject a proposal | `POST /spaces/proposals/{proposal_id}/reject` | `reject_space_proposal` | write |
| File material into a space | `POST /spaces/ingestions` | `ingest_into_space` | write |
| List ingestions | `GET /spaces/ingestions` | `list_space_ingestions` | read |
| Read an ingestion and what each choice would write | `GET /spaces/ingestions/{ingestion_id}` | `get_space_ingestion` | read |
| Decide what waits in an ingestion | `POST /spaces/ingestions/{ingestion_id}/decisions` | `decide_space_ingestion` | write |

The **Scope** column is the API scope. The space level each operation needs is in [Access](#access).

`GET` and `DELETE` endpoints take the `address` as a query parameter; `POST` and `PUT` endpoints take it in the JSON body. MCP tools take the same parameter names. The **Endpoints** section of the sidebar lists every parameter.

## Edit a page safely

Every read returns the page's `content_hash`. Editing or replacing a page's content must send it back as `base_hash`, so a change never overwrites an edit made since you read the page.

```bash theme={null}
# 1. Find the line
curl -X POST "https://your-workspace.api.useago.com/api/v1/spaces/grep" \
  -H "X-API-Key: ago_v1_sk_your_key_here" -H "Content-Type: application/json" \
  -d '{"pattern": "30 days", "address": "handbook"}'

# 2. Read the lines around it, and its content_hash
curl -G "https://your-workspace.api.useago.com/api/v1/spaces/pages" \
  -H "X-API-Key: ago_v1_sk_your_key_here" \
  --data-urlencode "address=handbook/refunds" -d start_line=4 -d end_line=8

# 3. Replace the exact text
curl -X POST "https://your-workspace.api.useago.com/api/v1/spaces/pages/edit" \
  -H "X-API-Key: ago_v1_sk_your_key_here" -H "Content-Type: application/json" \
  -d '{"address": "handbook/refunds", "old_string": "Refunds take 30 days.",
       "new_string": "Refunds take 14 days.", "base_hash": "<content_hash from step 2>",
       "summary": "Shorter refund delay"}'
```

* `old_string` must occur exactly once in the page, including whitespace and line breaks. If it occurs several times, add surrounding text or pass `replace_all: true`.
* If the page changed since your read, the call fails with `409` `content_conflict` and the page's `current_hash`. Read the page again and reapply your change.
* The response gives the new `content_hash` and `version_number`, so you can chain several edits without reading again.
* `summary` is optional; it is recorded in the page history.

## Read a page

`GET /spaces/pages` returns the page's `id`, `address`, `title`, `content_hash` and `total_lines`, plus one of:

* the whole content (default);
* `outline=true`: the headings, each with its level, line and the last line of its section;
* `section=<heading>`: one section, from its heading down to the next heading of the same or a higher level;
* `start_line` / `end_line`: a range of lines (numbered from 1, inclusive).

A read returns at most 2,000 lines or 60,000 characters, cut at a whole line. When it is cut, `truncated` is `true` and `next_start_line` says where to continue. Search and read number lines the same way, so a line found by `grep` can be read and edited directly.

## Find text

`POST /spaces/grep` returns the matching lines of the pages you can read, with their address and line number.

* The `pattern` is literal by default. Set `ignore_case` for a case-insensitive search.
* With `regex: true`, the pattern is a POSIX advanced regular expression, matched against each line: `\d`, `\s` and `\w` classes work, and a word boundary is written `\y` (`\m` for the start of a word, `\M` for its end).
* `address` limits the search to a space or to a page and the pages below it.
* `context` adds up to 10 lines before and after each match.
* `paths_only: true` returns the matching pages with their number of matching lines instead of the lines.
* At most 50 results come back (`limit`); `has_more` tells whether there were more. Lines longer than 300 characters are cut, with `text_truncated: true`; read the line to get all of it.
* A search running longer than 5 seconds is stopped with `search_timeout`. Narrow it with an `address` or a simpler pattern.

`POST /spaces/search` finds pages by meaning when you don't know the exact words. It may take a moment before a page you just changed is found by meaning; `grep` sees changes immediately.

## List pages

`GET /spaces/tree` lists the pages under a space or a page, in reading order, down to `depth` levels (default 2, at most 10). Each page comes with its address, title, `position` among its siblings, `children_count`, last update and a one-line `summary`: the `description` of the page's frontmatter when it has one, otherwise its first line of text. At most 500 pages are listed (`truncated`).

## Create, move and delete pages

* **Create**: `POST /spaces/pages` with `parent` (an existing page, or the space name for a top-level page), `title` and `content`.
* **Replace**: `PUT /spaces/pages` with `address`, the whole new `content` and `base_hash`.
* **Move**: `POST /spaces/pages/move` with `parent` (a page of the same space, or the space name), `position` among the new siblings (`0` is first) and/or a new `title`. A page cannot move to another space: create it there and delete the original.
* **Delete**: `DELETE /spaces/pages` removes the page and every page below it; `descendants_deleted` gives how many pages were below it.

## Proposals

With `propose` access, `POST /spaces/pages/edit` and `PUT /spaces/pages` do not change the page. They answer `202 Accepted` with a proposal (`object: "space_change_proposal"`, `status: "pending"`, `applied: false`) and a message saying the page is unchanged. MCP tools return the same object.

Someone with `write` access reviews it:

* `GET /spaces/proposals` lists the proposals on your spaces, newest first. Filter with `address` (a space or a page) and `status` (`pending` by default, or `accepted`, `rejected`).
* `GET /spaces/proposals/{proposal_id}` adds the page content the proposal was made on (`original_content`) and the `proposed_content`.
* `POST /spaces/proposals/{proposal_id}/accept` applies it. Pass `content` to apply an edited version instead, and `notes` for the record. The new version is credited to the reviewer, and its summary names who proposed it.
* `POST /spaces/proposals/{proposal_id}/reject` closes it without changing the page.

A proposal applies only to the page as it was when it was made. If the page changed since, accepting it fails with `409` `content_conflict` and the proposal stays pending: read the page, apply the change to its current content, then reject the proposal.

## File material into a space

Hand AGO a memo, meeting notes or a document and it files the content into the right pages: it adds new information to the page about that topic, creates a page when none is, and leaves pages that already say it alone. When the material contradicts a page, AGO does not pick a side: the contradiction waits for your decision.

```bash theme={null}
curl -X POST "https://your-workspace.api.useago.com/api/v1/spaces/ingestions" \
  -H "X-API-Key: ago_v1_sk_your_key_here" -H "Content-Type: application/json" \
  -d '{"address": "handbook", "source_name": "Q4 support memo",
       "content": "## Refunds\nRefunds are accepted within 14 days.\n\n## Support hours\nSupport answers from 9:00 to 18:00.",
       "wait_seconds": 20}'
```

* **What to send.** `address` is a space or a page: the material is only filed in that space, or under that page. `source_name` names the material in the page history. Send the text in `content`, or a file in `file_base64` with its `file_name` (PDF, Word, PowerPoint, Excel, images, Markdown or plain text, up to 10 MB). The text, or the text read from the file, can be up to 60,000 characters and 25 separate topics: split longer material into several ingestions. `instructions` (optional) guides placement, for example "one page per product".
* **The author's words are meant to be kept.** AGO is instructed to file each passage as written, without summarizing or rewording it, adding only the headings or list formatting the page needs. This is not guaranteed for every passage: the page history shows exactly what was written, and `review: all` lets you approve each change first. Resolving a contradiction with `keep_both` adds a dated note saying that the sources disagree. Lines that carry nothing to keep, such as a greeting or a signature, are not filed and are listed in `unfiled_excerpts`.
* **Only what you can reach.** The pages compared with the material are the ones you can read in that space. The changes are made with your access and credited to you, like your own edits.
* **It takes a moment.** The call answers `202` with `status: "planning"`. Pass `wait_seconds` (up to 25) to wait for the result in the same call, or read it later with `GET /spaces/ingestions/{ingestion_id}`. Planning does not change any page: changes are made once the whole material is planned.

### Review

`review` decides what waits for a decision:

| `review` | What happens |
| - | - |
| `conflicts` (default) | New pages and additions are made right away. Only contradictions wait. |
| `all` | Nothing changes until someone with `write` access decides each change. |

With `propose` access, `review` is always `all` and `message` says so: someone with `write` access decides.

When nothing waits, the ingestion is `completed`. Otherwise its `status` is `awaiting_decisions`. `counts` gives the number of pages created, updated and unchanged, and of changes waiting, skipped or failed.

### Decide

`GET /spaces/ingestions/{ingestion_id}` lists the `operations`, one per page. Each one has its `kind` (`create`, `update`, `unchanged` or `conflict`), its `status` (`applied`, `awaiting_decision`, `skipped` or `failed`), the `page`, a one-line `summary` and the `source_excerpt` it comes from. A conflict also gives the page's contradicted text in `existing_excerpt`.

For an operation waiting for a decision, `current_content` is the page now and `proposed_content` the page after the change. A conflict adds `option_contents`, the page as each choice would leave it. `options` lists the choices:

| Choice | Effect |
| - | - |
| `keep_existing` | Keep the page's statement. What the material adds without contradicting it is still added. |
| `use_new` | Replace the page's statement with the material's. |
| `keep_both` | Keep the page's statement and add, right after it, a quote saying which source states otherwise and since when. |
| `apply` | Make the new page or the addition (changes held by `review: all`). |
| `skip` | Change nothing. |
| `custom` | Write `content` as the whole page. |

```bash theme={null}
curl -X POST "https://your-workspace.api.useago.com/api/v1/spaces/ingestions/<ingestion_id>/decisions" \
  -H "X-API-Key: ago_v1_sk_your_key_here" -H "Content-Type: application/json" \
  -d '{"decisions": [{"operation_id": "<operation_id>", "choice": "use_new"}]}'
```

* Deciding needs `write` access. You can send up to 50 decisions at once, and decide some now and the rest later. Each decision is applied or refused on its own: the refused ones are in `decision_errors`, with a code and what to do.
* Each change is a new page version credited to whoever decided, with a summary naming the material. The page's previous content stays in its [history](#history).
* If the page changed since it was planned, the decision is refused with `page_changed`. The operation keeps waiting, its contents and choices now show the page as it is: look again and decide.
* `GET /spaces/ingestions` lists ingestions, newest first, without their operations. Filter with `address` and `status` (`planning`, `awaiting_decisions`, `completed` or `failed`).

### When an ingestion fails

A `failed` ingestion has an `error` with a `code` and a `message`, and changed no page. When `internal` is `true`, the failure is on AGO's side: submit the material again later. Otherwise the message says what to change, for example `too_many_passages` (split the material), `nothing_to_file` (nothing in it to keep), `extraction_failed` (the file could not be read) or `access_revoked` (the key or person that submitted it lost access to the space before the material was filed).

## History

`GET /spaces/pages/versions` lists a page's versions, newest first, with `version_number`, date, `change_summary`, `actor_type` (`user`, `api_key` or `agent` for an OAuth application), `actor_label` (the key's name and prefix, or the application's name) and `user`. Versions saved before this attribution existed have no `actor_type`.

`GET /spaces/pages/versions/{version_number}` returns that version's content. To restore it, send that content to `PUT /spaces/pages` with the page's current `content_hash`.

## Errors

Errors use the [standard error format](https://ago.mintlify.site/api/errors.md). Some carry extra fields that tell you how to recover. MCP tools return the same message, ending with the code in brackets, as a tool result with `isError: true`.

| Code | Status | Meaning and next step |
| - | - | - |
| `docs_disabled` | 403 | Docs is not enabled for your workspace, so retrying will not help: ask AGO support to enable it. An ingestion submitted before Docs was turned off fails with this code in its `error`. |
| `space_not_found` | 404 | No space with this name is available to you. `available_spaces` lists the ones that are. |
| `page_not_found` | 404 | No page at this address. `nearest_address` is the deepest existing page above it: list it with the tree. |
| `content_conflict` | 409 | The page changed since your read. `current_hash` is its hash now: read it again and reapply your change. |
| `ambiguous_match` | 422 | `old_string` occurs several times. `match_count` and `lines` say where. |
| `no_match` | 422 | `old_string` does not occur in the page. Copy it again from a fresh read. |
| `section_not_found` | 404 | No heading with this text. `headings` lists the page's headings. |
| `ambiguous_section` | 422 | Several headings have this text. Read by line range instead. |
| `version_not_found` | 404 | The page has no version with this number. |
| `invalid_regex` | 422 | The regular expression is invalid; the message says why. |
| `search_timeout` | 422 | The search took longer than 5 seconds. Narrow it. |
| `invalid_move` | 422 | A page cannot move below itself. |
| `cross_space_move` | 422 | A page cannot move to another space. |
| `invalid_space_name` | 422 | The space name is not lowercase letters and digits separated by `-` or `_`, or is already taken. |
| `cannot_convert_source` | 422 | The source is synced from another system or groups other sources, or its name cannot address a space. |
| `source_not_found` | 404 | No knowledge source has this ID. |
| `invalid_arguments` | 422 | A parameter is empty, out of range or combined with another one it excludes. `param` names it. A required field left out of a REST request body is reported by the standard validation error instead. |
| `insufficient_space_access` | 403 | Your level on the space is too low for this call. `required_level` and `level` say which level it needs and which one you have. |
| `proposal_not_found` | 404 | No proposal with this ID on a space available to you. |
| `proposal_not_pending` | 422 | The proposal was already accepted or rejected. |
| `material_too_large` | 422 | The material is longer than 60,000 characters. Submit it in several parts. |
| `file_too_large` | 422 | The file is larger than 10 MB. |
| `unsupported_file_type` | 422 | This type of file cannot be read. Submit its text in `content`. |
| `ingestion_not_found` | 404 | No ingestion with this ID in a space available to you. |
| `ingestion_planning` | 409 | The ingestion is still being planned. Read it with `wait_seconds`, then decide. |
| `ingestion_failed` | 422 | The ingestion failed, so there is nothing to decide. Its `error` says why. |

## Related

* [Public API Overview](https://ago.mintlify.site/api/public-api-v1.md)
* [MCP Server](https://ago.mintlify.site/api/mcp-tool-api.md)
* [API Errors](https://ago.mintlify.site/api/errors.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.