# Use the Library API

## When to use the API

The REST API is suitable for applications and scripts that need direct,
versioned requests. MCP is usually a better fit for conversational AI clients.
Both paths apply the same ownership, review, and publication rules.

Base URL:

```text
https://api.memside.com
```

## Create an API key

1. Open **Settings > Developer & API**.
2. Select the API-key creation action.
3. Choose **Read-only** for retrieval or **Read-write** for creator changes.
4. Create the key and store the displayed value securely.

The full value is displayed once. API keys must not be placed in source files,
public repositories, screenshots, query strings, or Template content.

Send the key in the authorization header:

```text
Authorization: Bearer mem_sk_example_key
```

## Library route groups

| Method | Path | Use |
| --- | --- | --- |
| `GET` | `/library/templates` | Search public Templates. |
| `GET` | `/library/creator/status` | List owned Templates and workflow results. |
| `POST` | `/library/templates/{template_id}/read` | Read selected content from an owned draft. |
| `PUT` | `/library/templates/{template_id}/draft` | Replace an owned private draft. |
| `POST` | `/library/templates/workflow` | Create, review, publish, unpublish, or republish an owned Template. |

Read-only keys can use retrieval operations. Draft changes and workflow actions
require a read-write key.

## Search example

The following request searches the public catalog without exposing private
drafts:

```bash
curl "https://api.memside.com/library/templates?query=weekly%20planning&limit=5" \
  -H "Authorization: Bearer mem_sk_example_key"
```

Use category or tag filters when a broad term returns unrelated results. Search
responses provide public listing information suitable for presenting a result
list before any later action.

## Creator status example

```bash
curl "https://api.memside.com/library/creator/status" \
  -H "Authorization: Bearer mem_sk_example_key"
```

Check creator status before a write or publication request. It provides the
owned Template state needed to avoid acting on an outdated draft.

## Safe draft workflow

Draft replacement is designed for complete, intentional updates rather than an
unverified partial overwrite. A reliable sequence is:

1. read the owned draft and its current revision;
2. prepare the complete replacement file set;
3. validate file names, content limits, and the required root README;
4. send the draft update with the current revision information;
5. read the draft again and verify the saved result;
6. submit for review in a separate workflow request.

The public API contract documents the required request fields. Avoid copying a
response or draft revision from an older run into a later update.

## Publication workflow

Creation, review submission, retry, publication, unpublication, and
republication are explicit workflow actions. Do not combine draft editing and
publication into an assumed single step.

Before publication, confirm:

- the current review state is **Ready to publish**;
- the selected license is correct;
- all files are intended for public visibility;
- release notes describe meaningful file changes;
- the current draft is the same draft that completed review.

## Errors and retries

Common responses include:

| Status | Meaning |
| --- | --- |
| `400` | The request or Template state is invalid. |
| `401` | The API key is missing or invalid. |
| `403` | The key mode or account does not allow the action. |
| `404` | The Template or route was not found. |
| `409` | The draft or workflow state changed and must be refreshed. |
| `429` | The request limit was reached. Retry after the indicated delay. |

For a conflict, read current creator status and the latest draft before making
another write. Do not retry a state-changing request blindly.

## Key activity and revocation

Open **Settings > Developer & API** and select **Activity** beside a key to view
recent request actions, results, times, and request references. Memory content
is not shown in this activity list.

Revoke a key that is no longer needed or might have been exposed, then update
the relevant application with a new key.

## Related pages

- [REST API reference](/developers/api-reference/)
- [API keys](/developers/api-keys/)
- [Use Library with MCP](/library/use-with-mcp/)
- [Review and publish a Template](/library/review-and-publish/)
