# Text Chunking

Every registered text chunking instance operation, with source-derived inputs, outputs, access policy, and errors.

Source: https://docs.minds.sh/docs/api/instance/text-chunking



This reference covers **2 HTTP operations** registered by the Akasha daemon. Call these paths on your instance base URL. See [authentication](/docs/api/instance/authentication), [errors](/docs/api/instance/errors), and [coverage](/docs/api/instance/coverage) before integrating.

| Method | Path                    | Operation                                 |
| ------ | ----------------------- | ----------------------------------------- |
| `POST` | `/v1/text/chunk`        | [Chunk text](#post-v1-text-chunk)         |
| `GET`  | `/v1/text/chunk/config` | [Chunk config](#get-v1-text-chunk-config) |

<a id="post-v1-text-chunk" />

## POST `/v1/text/chunk` [#post-v1textchunk]

Chunk text

| Availability         | Source contract                                                  |
| -------------------- | ---------------------------------------------------------------- |
| Registration         | `always registered`                                              |
| Runtime service      | No prefix-level service check; handler dependencies still apply. |
| Handler dependencies | See handler source and return expressions.                       |

**Access:** Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

### Request [#request]

**Json** — `ChunkTextRequest`

| Field    | Rust type                          | Required on input         | Notes                                                 |
| -------- | ---------------------------------- | ------------------------- | ----------------------------------------------------- |
| `text`   | `String`                           | Yes                       |                                                       |
| `config` | `Option<chunking::ChunkingConfig>` | No; optional or defaulted | Optional per-request chunking configuration override. |

```rust
struct ChunkTextRequest {
    text: String,
    /// Optional per-request chunking configuration override.
    config: Option<chunking::ChunkingConfig>,
}
```

### Response [#response]

**Declared return:** `Result<impl IntoResponse, DaemonError>`

The following are the exact JSON construction expressions in the handler. Values such as `rows`, `result`, and delegated types are runtime values, not literal example payloads.

```rust
serde_json::json!({
        "chunks": chunks,
        "total": chunks.len(),
        "config": chunker.config(),
    })
```

### Errors and validation [#errors-and-validation]

Directly referenced error variants: none in the handler body. Middleware and delegated services can return additional errors described in the shared error reference.

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn chunk_text(
        State(state): State<AppState>,
        Json(req): Json<ChunkTextRequest>,
    ) -> Result<impl IntoResponse, DaemonError> {
        state.record_http_request();

        let chunker = match req.config {
            Some(cfg) => chunking::TextChunker::new(cfg),
            None => (*state.chunker).clone(),
        };
        let chunks = chunker.chunk(&req.text);
        Ok(Json(serde_json::json!({
            "chunks": chunks,
            "total": chunks.len(),
            "config": chunker.config(),
        })))
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:2796`. Registration: `akasha-daemon/src/main.rs:4401`.

<a id="get-v1-text-chunk-config" />

## GET `/v1/text/chunk/config` [#get-v1textchunkconfig]

Chunk config

| Availability         | Source contract                                                  |
| -------------------- | ---------------------------------------------------------------- |
| Registration         | `always registered`                                              |
| Runtime service      | No prefix-level service check; handler dependencies still apply. |
| Handler dependencies | See handler source and return expressions.                       |

**Access:** Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

### Request [#request-1]

No typed JSON, query, or path extractor is declared in the handler signature. Headers or request objects may still be consumed; the signature below is authoritative.

### Response [#response-1]

**Declared return:** `Result<impl IntoResponse, DaemonError>`

The following are the exact JSON construction expressions in the handler. Values such as `rows`, `result`, and delegated types are runtime values, not literal example payloads.

```rust
serde_json::json!({
        "config": state.chunker.config(),
    })
```

### Errors and validation [#errors-and-validation-1]

Directly referenced error variants: none in the handler body. Middleware and delegated services can return additional errors described in the shared error reference.

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn chunk_config(State(state): State<AppState>) -> Result<impl IntoResponse, DaemonError> {
        state.record_http_request();
        Ok(Json(serde_json::json!({
            "config": state.chunker.config(),
        })))
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:2814`. Registration: `akasha-daemon/src/main.rs:4402`.
