---
title: "Set Dna Data By Key"
method: POST
path: "/api/dna/data"
tags: ["8DNA API"]
---

# Set Dna Data By Key

`POST /api/dna/data`

## Request

- Base URL: `https://api.agentstack.tech` (the document declares no server; this is the origin it was published from)
- URL: `https://api.agentstack.tech/api/dna/data`
- Auth: one of:
  - API key in header `X-API-Key`
  - HTTP bearer

Set value at key (project.data.* or user.data.*). For built apps using sdk.db.set(key, value).

This endpoint is an **immediate leaf write** (jsonb_set), same grammar as
``PATCH /api/projects/{id}/data``. Query ``commit_mode=dirty`` is accepted for
compatibility but does **not** make KV write-behind — use the protein command
bus for dirty journals. Prefer MCP ``projects.patch_data`` when the client
speaks MCP.

## Query parameters

- `commit_mode` string, nullable: Optional: dirty only if domain allowlisted; DNA KV still defaults to immediate SoT

## Headers

- `Idempotency-Key` string

## Request body

- DnaKvSetBody: KV write for POST /dna/data — leaf grammar parity with ``ProjectDataPatchBody``.
  - `key` string: project.data.* or user.data.* dotted suffix
  - `project_id` integer, nullable
  - `commit_mode` string, nullable: Compatibility hint only; KV writes stay immediate leaf SoT
  - `value` unknown
  - `write_mode` string, nullable
  - `allow_shrink` boolean
  - `replacements` object[], nullable
  - `unified_diff` string, nullable
  - `strict_diff` boolean, nullable
  - `ops` object[], nullable
  - `dry_run` boolean
  - `expected_sha256` string, nullable
  - `missing` string, nullable

## Response `200`

Successful Response

- unknown

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `403`: Forbidden
- `404`: Not Found
- `409`: Conflict
- `422`: Validation Error
- `429`: Too Many Requests
- `500`: Internal Server Error

---

[API](https://skmtc.dev/agentstack/apis/agentstack-core-api.md) · [All operations](https://skmtc.dev/agentstack/apis/agentstack-core-api/llms.txt) · [OpenAPI document](https://skmtc.dev/agentstack/apis/agentstack-core-api/revisions/8ecf3406e74a?raw)
