# write\_document\_type

Create a document type, or rewrite the one `id` names, passing the version last read.

writes · not idempotent · destructive · CLI only · [Agent](https://komrad.dev/latest/api/agent.md)

## Calling it

```bash
curl -X POST http://127.0.0.1:8787/komrad.agent.v1.AgentService/WriteDocumentType \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "<name>",
  "context": "<context>"
}'
```

```bash
komrad rpc write-document-type \
  --name '<string>' \
  --context '<string>'
```

## Request

### WriteDocumentTypeRequest

| Field | Type | Description |
| --- | --- | --- |
| [`id`](https://komrad.dev/latest/api/agent/write-document-type.md#komrad-agent-v1-WriteDocumentTypeRequest-id) | uuid | The document type to rewrite, by id. Unset creates a document type. |
| [`name`](https://komrad.dev/latest/api/agent/write-document-type.md#komrad-agent-v1-WriteDocumentTypeRequest-name) | string\* at most 100 characters must not contain control characters | The document type's name. Renaming a type renames it on its documents too. |
| [`context`](https://komrad.dev/latest/api/agent/write-document-type.md#komrad-agent-v1-WriteDocumentTypeRequest-context) | string\* at most 1048576 bytes | The markdown an agent reads before writing a document of this type. |
| [`version`](https://komrad.dev/latest/api/agent/write-document-type.md#komrad-agent-v1-WriteDocumentTypeRequest-version) | int32 more than 0 | The document type's [`version`](https://komrad.dev/latest/api/agent/write-document-type.md#komrad-agent-v1-WriteDocumentTypeRequest-version) when last read. Required on a rewrite. |

## Response

### WriteDocumentTypeResponse

| Field | Type | Description |
| --- | --- | --- |
| [`document_type`](https://komrad.dev/latest/api/agent/write-document-type.md#komrad-agent-v1-WriteDocumentTypeResponse-document_type) | [DocumentType](https://komrad.dev/latest/api/agent/write-document-type.md#komrad-agent-v1-DocumentType) | The document type as written. |

## Types

### DocumentType

DocumentType is one kind of document, with the context an agent reads before writing one.

| Field | Type | Description |
| --- | --- | --- |
| [`id`](https://komrad.dev/latest/api/agent/write-document-type.md#komrad-agent-v1-DocumentType-id) | uuid\* | The document type's id. |
| [`name`](https://komrad.dev/latest/api/agent/write-document-type.md#komrad-agent-v1-DocumentType-name) | string | The document type's name, which each document of the type carries as `type`. |
| [`context`](https://komrad.dev/latest/api/agent/write-document-type.md#komrad-agent-v1-DocumentType-context) | string | The markdown an agent reads before writing a document of this type. |
| [`version`](https://komrad.dev/latest/api/agent/write-document-type.md#komrad-agent-v1-DocumentType-version) | int32 | How many times the document type has been written. |
| [`updated_at`](https://komrad.dev/latest/api/agent/write-document-type.md#komrad-agent-v1-DocumentType-updated_at) | timestamp | When the document type was last written. |
