---
# @generated by sylphx-gen 0.1.0 from contracts@e145cc7cf1bc9605f2b27439e5e17ed76a1a2fd7e7021906a013f7565e4a0cd5. Do not edit.
title: "Hash set in KV"
description: "`data.kv.hash_set` (POST /v1/kv-hashes): Sets fields of a hash (HSET), creating it."
type: reference
product: kv
summary: "Sets fields of a hash (HSET), creating it."
updated: 2026-09-28
nav: false
---

Sets fields of a hash (HSET), creating it.

- **Path** `POST https://api.data.sylphx.com/v1/kv-hashes`
- **Scope** `data:write`
- **Effect** `write` — a successful call changes state.
- **Collection** [kv](/docs/api/kv)
- **Host** `https://api.data.sylphx.com`

## Request

| Field | Type | What it is |
| --- | --- | --- |
| `namespace_id` | `string` | The namespace's id. Required. |
| `key` | `string` | The hash's key. Required. |
| `fields` | `HashField[]` | The fields to set; at least one. Required. |

### HashField

| Field | Type | What it is |
| --- | --- | --- |
| `field` | `string` | The field's name. Required. |
| `value` | `bytes` | The bytes, base64; unset when the field is absent. |

## Response

| Field | Type | What it is |
| --- | --- | --- |
| `added` | `uint64` | How many fields were new. |
| `version` | `uint64` | The hash's version after the write. |

## Errors

- [`UNAUTHENTICATED`](/docs/api/errors/UNAUTHENTICATED) — No valid key or token was presented.
- [`PERMISSION_DENIED`](/docs/api/errors/PERMISSION_DENIED) — The key lacks the method's permission.
- [`INVALID_FIELD`](/docs/api/errors/INVALID_FIELD) — A field failed validation.
- [`RESOURCE_NOT_FOUND`](/docs/api/errors/RESOURCE_NOT_FOUND) — The named Resource does not exist or is not visible.

Every error arrives in the body [Errors](/docs/platform/errors) describes.

## Examples

**cURL**

```curl
curl -X POST "https://api.data.sylphx.com/v1/kv-hashes" \
  -H "Authorization: Bearer $SYLPHX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"fields":[{"field":"…"}],"key":"…","namespace_id":"…"}'
```

**TypeScript**

```ts
const response = await sylphx.data.kv.hashSet({ fields: [{ field: '…' }], key: '…', namespaceId: '…' })
```

**Rust**

```rust
let mut req = sylphx::data::HashSetValueRequest::default();
req.fields = vec![Default::default()];
req.key = "…".to_string();
req.namespace_id = "…".to_string();
let response = sx.data().kv().hash_set(req).await?;
```

**MCP**

```json
{ "method_id": "data.kv.hash_set", "args": {"fields":[{"field":"…"}],"key":"…","namespace_id":"…"} }
```
