# Contents

## Overview

Each content source in Seclai produces **content versions** — individual indexed items such as articles, uploaded files, or custom documents. The Contents API lets you inspect, replace, and delete these items, as well as view the embedding chunks generated for semantic search.

Key concepts:

- **Content Version** — A single indexed document tied to a source connection.
- **Embeddings** — Chunked vector representations used for knowledge base retrieval. Each content version may have many embedding chunks.
- **Inline Text** — Small text payloads (up to 8 KB) that can replace an existing content version without a file upload.

## API Access

Content items can be managed via the Public API using your API key. All endpoints are scoped to your account.

### Get Content Details

Retrieve the extracted text and metadata for a content version. Use `start` and `end` to page through large documents.

```bash
CONTENT_VERSION_ID=...

curl "https://api.seclai.com/contents/$CONTENT_VERSION_ID?start=0&end=5000" \
  -H "X-API-Key: $SECLAI_API_KEY"
```

### Delete Content

Permanently remove a content version and its embeddings.

```bash
CONTENT_VERSION_ID=...

curl -X DELETE "https://api.seclai.com/contents/$CONTENT_VERSION_ID" \
  -H "X-API-Key: $SECLAI_API_KEY"
```

### List Content Embeddings

View the embedding chunks for a content version. Useful for debugging chunking and indexing.

```bash
CONTENT_VERSION_ID=...

curl "https://api.seclai.com/contents/$CONTENT_VERSION_ID/embeddings?page=1&limit=20" \
  -H "X-API-Key: $SECLAI_API_KEY"
```

### Replace Content with Inline Text

Replace the text backing an existing content version with a small inline payload (max 8 KB UTF-8).

```bash
CONTENT_VERSION_ID=...

curl -X PUT "https://api.seclai.com/contents/$CONTENT_VERSION_ID" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Updated article text...",
    "content_type": "text/plain",
    "title": "Updated Article",
    "metadata": {"category": "docs"}
  }'
```

### Replace Content with File Upload

Upload a new file to replace the content for an existing content version.

```bash
CONTENT_VERSION_ID=...

curl -X POST "https://api.seclai.com/contents/$CONTENT_VERSION_ID/upload" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -F "file=@updated-doc.pdf" \
  -F "title=Updated Document" \
  -F 'metadata={"category":"reports"}'
```

## Next Steps

- [Content Sources](https://seclai.com/docs/content-sources) — Learn about content source types and configuration
- [Knowledge Bases](https://seclai.com/docs/knowledge-bases) — Organize sources into searchable collections
- [API Examples](https://seclai.com/docs/api-examples) — More API code samples
- [API Reference](https://seclai.com/docs/api) — Complete endpoint documentation
