> For the complete documentation index, see [llms.txt](https://docs.pyck.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pyck.cloud/graphql-api/types/keyvalue.md).

# KeyValue

KeyValue Type

Represents a flexible key-value store for configuration settings, user preferences, and custom data. KeyValue entities allow storing structured data with optional schema validation through DataTypes.

## Fields

| Field          | Type      | Description                                            |
| -------------- | --------- | ------------------------------------------------------ |
| `id`           | `ID!`     | Unique identifier of the key-value pair                |
| `tenantID`     | `UUID!`   | Tenant identifier                                      |
| `userID`       | `UUID`    | User identifier (optional, for user-specific settings) |
| `dataTypeID`   | `UUID`    | DataType identifier for schema validation              |
| `dataTypeSlug` | `String`  | DataType slug for easier reference                     |
| `data`         | `Map`     | The actual key-value data stored as JSON               |
| `createdAt`    | `Time!`   | Creation timestamp                                     |
| `createdBy`    | `UUID!`   | User identifier who created the entry                  |
| `updatedAt`    | `Time`    | Last update timestamp                                  |
| `updatedBy`    | `UUID`    | User identifier who last updated the entry             |
| `deletedAt`    | `Time`    | Deletion timestamp                                     |
| `deletedBy`    | `UUID`    | User identifier who deleted the entry                  |
| `name`         | `String!` | Name/key identifier for the value                      |

## Interfaces

* `Node`

## Usage Example

```graphql
query {
  keyValues(first: 10) {
    edges {
      node {
        id
        name
        data
        userID
        dataTypeSlug
        createdAt
        updatedAt
      }
    }
  }
}
```

## Mutation Examples

### Set a Key-Value Pair

```graphql
mutation {
  setKeyValue(input: {
    name: "user_preferences"
    dataTypeSlug: "user_settings"
    data: {
      theme: "dark"
      language: "en"
      timezone: "UTC"
    }
  }) {
    id
    name
    data
  }
}
```

### Delete a Key-Value Pair

```graphql
mutation {
  deleteKeyValue(id: "uuid-here") {
    deletedID
  }
}
```

## Common Use Cases

* **User Preferences**: Store user-specific settings like theme, language, and dashboard configurations
* **System Configuration**: Store application-wide settings and feature flags
* **Custom Metadata**: Attach flexible data to entities without schema changes
* **Temporary Storage**: Store session data or temporary workflow state
* **Integration Settings**: Store third-party API configurations and credentials

## Data Validation

KeyValue entries can optionally reference a DataType for schema validation:

* Use `dataTypeID` to reference a specific DataType entity
* Use `dataTypeSlug` for easier reference to common schema types
* The `data` field will be validated against the DataType's JSON schema
* Validation ensures data integrity and consistency across the application


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.pyck.cloud/graphql-api/types/keyvalue.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
