# Session Manipulation API

The **Session Manipulation API** provides runtime‑level control over **application session data** during CRUD operations within the ONEWEB platform.

In ONEWEB 4.0, applications often need to **modify, enrich, or adjust data in memory** before it is persisted to the database, or after data has been retrieved.\
Session Manipulation APIs enable this by allowing controlled interaction with **session‑scoped data** during request processing.

***

### Purpose and Scope

The Session Manipulation API is designed to support scenarios where:

* Data needs to be modified **before saving** to the database
* Data needs to be transformed or enriched **after reading** from the database
* Temporary, request‑scoped values are required during CRUD execution
* Business logic requires intermediate data storage during runtime

These APIs operate **within the application session context** and do not bypass standard authorization or validation rules.

***

### Relationship with CRUD Operations

Session Manipulation APIs are tightly integrated with **App Runtime CRUD operations**, acting as an extension point in the request lifecycle.

Typical interaction flow:

1. Client initiates a CRUD operation (create / update / read / delete)
2. Runtime processes the request
3. Session Manipulation APIs are invoked:
   * Before data persistence, or
   * After data retrieval
4. Modified session data is passed forward in the execution flow
5. Final response is returned to the client

This model allows developers to influence runtime behavior **without directly altering persisted data structures**.

***

### Session Context Behavior

Key characteristics of session manipulation:

* Session data exists only for the **lifetime of the request or user session**
* Changes made through these APIs do **not automatically persist** to the database
* Session data is isolated per user and per execution context
* Access to session data respects ONEWEB security and permission boundaries

This ensures predictable behavior while enabling flexible runtime logic.

***

### Common Use Cases

Session Manipulation APIs are commonly used for:

* Calculating derived or transient values
* Formatting or normalizing data before persistence
* Injecting additional attributes required for business rules
* Temporarily storing data across multiple runtime steps
* Supporting complex CRUD flows without schema changes

***

### Summary

The **Session Manipulation API** provides a controlled mechanism to interact with runtime session data during CRUD operations.

Key benefits include:

* Runtime flexibility without database impact
* Cleaner separation between persistent data and transient logic
* Safer manipulation of data within a secured session context
* Better support for complex business workflows

This API complements the **App Runtime API** and **Process Runtime API**, enabling advanced data handling scenarios within the ONEWEB platform.


---

# 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://docs.onewebstack.com/api-reference/session-manipulation-api.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.
