> For the complete documentation index, see [llms.txt](https://docs.eximee.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/logika-biznesowa/scriptcode/skrypty-scriptservice/api-skryptow/podstawy-pracy-ze-skryptami/zapis-danych-tymczasowych.md).

# Saving temporary data

It is possible to save certain data between service calls. This is what the object is for `registry` called from the local context (`context.registry()`).

The object requires a running application **EximeeRegistry**.

{% hint style="danger" %}
**Important:** Saving data using EximeeRegistry **is not intended** for saving anything permanently!
{% endhint %}

## Available methods

Object `registry` provides the following methods for managing stored data:

| Method                                      | Description                                                                                                                                                                                                                                          |
| ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `save(namespace, id, data)`                 | Saves the provided data under the specified identifier.                                                                                                                                                                                              |
| `saveVersion(namespace, id, data, version)` | Saves data with version verification. If the `version` field is unset or empty, the save occurs without verification. If the value of the field `version` does not match the current version of the stored data, the request will end with an error. |
| `get(namespace, id)`                        | Retrieves the saved data (returns only the content).                                                                                                                                                                                                 |
| `getVersion(namespace, id)`                 | Retrieves the saved data along with its current version. Returns an object with the structure: `{ data: 'saved data', version: 'current data version' }`.                                                                                            |
| `delete(namespace, id)`                     | Deletes the saved data from the specified namespace.                                                                                                                                                                                                 |

## Namespace and data lifecycle

* **Namespaces (namespace):** Data is stored in separate namespaces defined by administrators.
* **Lifetime (TTL):** Each namespace can be assigned an individual data lifetime. **By default, it is 90 days.**
* **Update:** Providing the same `id` across several save calls updates the data associated with that identifier.
* **Versioning:** The data version is a unique identifier automatically generated with each data save (or update). Each save creates a new version of the entry. With `saveVersion` it is possible to provide a version for verification — if it does not match the current one, the save will be rejected. `null` means a forced save, without checking the version.

## Usage examples

The script below presents the lifecycle of temporary data from saving, through reading, safe update with version verification, to deletion:

```javascript
function callService(context) {
    // 1. Save temporary data under key '123123' in the 'test' namespace
    context.registry().save('test', '123123', 'temporary data');
    
    // 2. Simple data retrieval (will return the value: 'temporary data')
    const simpleData = context.registry().get('test', '123123'); 
    
    // 3. Retrieve data along with its version
    const item = context.registry().getVersion('test', '123123'); 
    
    // 4. Safe data update (the save will succeed because the version from the 'item' object is current)
    context.registry().saveVersion('test', '123123', 'new data', item.version);
    
    // 5. Attempt to update with the wrong version (the save will NOT succeed, the platform will throw an error)
    // context.registry().saveVersion('test', '123123', 'more data', 'some other version');
    
    // 6. Delete data from the registry
    context.registry().delete('test', '123123');

    return [{}];
}
```


---

# 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.eximee.com/documentation/documentation-en/budowanie-aplikacji/logika-biznesowa/scriptcode/skrypty-scriptservice/api-skryptow/podstawy-pracy-ze-skryptami/zapis-danych-tymczasowych.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.
