# Schemas

A *schema* describes data structures that do not need to be persisted in the global data model. A schema can represent simple values, nested objects, and lists, making it usable in data bindings, action params, and flows without first being modelled as an object class.

Schemas are useful when working with data that lives outside Appfarm - the response of a web request, a payload from an external system, or any structured data that a solution needs to use once but not store.

### Defining a schema

A schema is defined inline, as a data type on an [action variable](https://docs.appfarm.io/reference/actions/action-variables) or [action param](https://docs.appfarm.io/reference/actions/action-params). When you set the data type to schema, the **Edit schema** dialog opens where you define the properties directly.

<figure><img src="https://29237295-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MiLU-xcHu0eLZiTxcmZ%2Fuploads%2F5lLewNC5dHoxrVnOphpJ%2Fimage.png?alt=media&#x26;token=bcf1e5c6-f48d-4dec-8d0b-790ddb4960ef" alt=""><figcaption><p>Schema editor</p></figcaption></figure>

Each property has a key and a data type. The supported data types are:

* **String** (with **Timestamp**, **Secret** and **Internet URL** sub types)
* **Number** (with **Integer** and **Float** sub types)
* **Boolean**
* **Object**
* **Array** (can be of any of the four other data types)

Nesting works the same way at any depth, so a schema can describe arbitrarily structured data. The top level of a schema is itself either an object or an array, which means a single schema can describe one record or a collection of them.

Schemas can also be created automatically when generating a flow from an OpenAPI specification. The OpenAPI import sets up schemas as action variables on the flow, matching the structure declared in the spec.

### Using schemas

Schemas can be used wherever the platform needs to know the shape of data.

**As action params.** An action param can have a schema as its data type, allowing structured data to be passed into an action. The same mechanism is available for actions in apps.&#x20;

**As the output of a flow.** An action variable on a flow can have a schema as its data type, and the calling action receives the structured data in that schema shape as part of the flow's output.

**Mapping schema data to the database.** When schema data should be persisted, it can be mapped into an object class using regular databindings on the [Create Object](https://docs.appfarm.io/library/action-nodes/create-object) or [Update Object](https://docs.appfarm.io/library/action-nodes/update-object) action nodes.&#x20;

### Schemas in action nodes

Schema data is consumed and produced by the standard action nodes — Create Object, Update Object, [Delete Object](https://docs.appfarm.io/library/action-nodes/delete-objects), and [Foreach](https://docs.appfarm.io/library/action-nodes/foreach) all accept schema-typed inputs and targets. Full behavior and examples live on each node's reference page. A few patterns are specific to schemas and worth naming here:

* On Create Object, **Replace existing object** defaults to false for array-typed schema properties, so new objects are appended rather than overwriting the array.
* On a cardinality-one schema, running Create Object a second time raises an error rather than silently replacing the existing object.
* A single Foreach node descends through one array level only — to iterate a nested array, nest a second Foreach inside the first.


---

# 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.appfarm.io/reference/platform-concepts/schemas.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.
