# Set Data

### Endpoint

```
POST /api/v1/data/set
```

***

### Request Body

| Field    | Type   | Required   | Description                 |
| -------- | ------ | ---------- | --------------------------- |
| `userId` | string | <h3>✓</h3> | The player's Roblox user ID |
| `key`    | string | <h3>✓</h3> | The key to set              |
| `value`  | any    | <h3>✓</h3> | The value to store          |

***

### Example Request

```lua
Auxvyn.set(player.UserId, "coins", 500)
```

***

### Example Response

```json
{
  "success": true
}
```

***

### Value Types

You can store any of the following value types:

| Type    | Example               |
| ------- | --------------------- |
| Number  | `500`                 |
| String  | `"warrior"`           |
| Boolean | `true`                |
| Table   | `{"sword", "shield"}` |

{% hint style="warning" %}
Roblox-specific types like `Vector3`, `CFrame`, or `Color3` cannot be stored directly. Convert them to a table or string first.
{% endhint %}

***

### Overwriting Values

Calling `Auxvyn.set()` on a key that already exists overwrites the previous value completely. There is no merge behavior, if you want to update part of a table you need to read it first, modify it, then write it back.

```lua
-- Read existing inventory
local inventory = Auxvyn.get(player.UserId, "inventory") or {}

-- Add an item
table.insert(inventory, "sword")

-- Write it back
Auxvyn.set(player.UserId, "inventory", inventory)
```

***

### Error Responses

| Code  | Reason                              |
| ----- | ----------------------------------- |
| `400` | Missing `userId`, `key`, or `value` |
| `401` | Missing or invalid API key          |
| `500` | Failed to save — try again          |

***

### What's Next


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://auxvyn.gitbook.io/auxvyn-docs/api-reference/set-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
