# Transactions

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

Source: https://docs.minds.sh/docs/api/instance/transactions



This reference covers **3 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/tx/begin`  | [Tx begin](#post-v1-tx-begin)   |
| `POST` | `/v1/tx/commit` | [Tx commit](#post-v1-tx-commit) |
| `POST` | `/v1/tx/abort`  | [Tx abort](#post-v1-tx-abort)   |

<a id="post-v1-tx-begin" />

## POST `/v1/tx/begin` [#post-v1txbegin]

Tx begin

| Availability         | Source contract                                                  |
| -------------------- | ---------------------------------------------------------------- |
| Registration         | `config.enable_kv`                                               |
| 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** — `TxBeginReq`

| Field       | Rust type | Required on input | Notes |
| ----------- | --------- | ----------------- | ----- |
| `actor`     | `String`  | Yes               |       |
| `isolation` | `String`  | Yes               |       |

```rust
struct TxBeginReq {
    actor: String,
    isolation: String,
}
```

### 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!({"tx_id": tx_id.to_string()})
```

### 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 tx_begin(
        State(state): State<AppState>,
        Extension(db): Extension<Arc<AkashaDB>>,
        Json(req): Json<TxBeginReq>,
    ) -> Result<impl IntoResponse, DaemonError> {
        state.record_http_request();
        let iso = match req.isolation.as_str() {
            "read_uncommitted" => akasha::CoreIsolationLevel::ReadUncommitted,
            "read_committed" => akasha::CoreIsolationLevel::ReadCommitted,
            "repeatable_read" => akasha::CoreIsolationLevel::RepeatableRead,
            _ => akasha::CoreIsolationLevel::Serializable,
        };
        let tx = db.core_tx_begin(&req.actor, iso);
        let tx_id = tx.id;
        {
            let mut map = state.tx_map.write().await;
            map.insert(tx_id, tx);
        }
        Ok(Json(serde_json::json!({"tx_id": tx_id.to_string()})))
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:3398`. Registration: `akasha-daemon/src/main.rs:4581`.

<a id="post-v1-tx-commit" />

## POST `/v1/tx/commit` [#post-v1txcommit]

Tx commit

| Availability         | Source contract                                                  |
| -------------------- | ---------------------------------------------------------------- |
| Registration         | `config.enable_kv`                                               |
| 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]

**Json** — `TxIdReq`

| Field | Rust type | Required on input | Notes |
| ----- | --------- | ----------------- | ----- |
| `id`  | `String`  | Yes               |       |

```rust
struct TxIdReq {
    id: String,
}
```

### 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!({"ok": true})
```

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

Directly referenced error variants: `InvalidRequest`. 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 tx_commit(
        State(state): State<AppState>,
        Extension(db): Extension<Arc<AkashaDB>>,
        Json(req): Json<TxIdReq>,
    ) -> Result<impl IntoResponse, DaemonError> {
        state.record_http_request();
        let id = uuid::Uuid::parse_str(&req.id)
            .map_err(|_| DaemonError::InvalidRequest("invalid id".into()))?;
        let tx = {
            let mut map = state.tx_map.write().await;
            map.remove(&id)
                .ok_or_else(|| DaemonError::InvalidRequest("unknown tx".into()))?
        };
        db.core_tx_commit(&tx)
            .map_err(|e| DaemonError::InvalidRequest(e.to_string()))?;
        Ok(Json(serde_json::json!({"ok": true})))
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:3424`. Registration: `akasha-daemon/src/main.rs:4582`.

<a id="post-v1-tx-abort" />

## POST `/v1/tx/abort` [#post-v1txabort]

Tx abort

| Availability         | Source contract                                                  |
| -------------------- | ---------------------------------------------------------------- |
| Registration         | `config.enable_kv`                                               |
| 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-2]

**Json** — `TxIdReq`

| Field | Rust type | Required on input | Notes |
| ----- | --------- | ----------------- | ----- |
| `id`  | `String`  | Yes               |       |

```rust
struct TxIdReq {
    id: String,
}
```

### Response [#response-2]

**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!({"ok": true})
```

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

Directly referenced error variants: `InvalidRequest`. 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 tx_abort(
        State(state): State<AppState>,
        Extension(db): Extension<Arc<AkashaDB>>,
        Json(req): Json<TxIdReq>,
    ) -> Result<impl IntoResponse, DaemonError> {
        state.record_http_request();
        let id = uuid::Uuid::parse_str(&req.id)
            .map_err(|_| DaemonError::InvalidRequest("invalid id".into()))?;
        let tx = {
            let mut map = state.tx_map.write().await;
            map.remove(&id)
                .ok_or_else(|| DaemonError::InvalidRequest("unknown tx".into()))?
        };
        db.core_tx_abort(&tx)
            .map_err(|e| DaemonError::InvalidRequest(e.to_string()))?;
        Ok(Json(serde_json::json!({"ok": true})))
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:3442`. Registration: `akasha-daemon/src/main.rs:4583`.
