> For the complete documentation index, see [llms.txt](https://docs.conanjs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.conanjs.io/data/flows/flows-as-state.md).

# Serialising Flows

## Introduction

Before introducing flow serialising,  is important to remind that Conan Flows are [2 dimensional data structures](/data/general-concepts.md#two-dimensions-conan-flow).

We believe that for most use cases, when you would like to access a flow you would like to serialise it.

Let's illustrate this graphically. Let's use again the authentication example:

| Status               | State 1                                                                                                      | State 2                                                                                                  | State 3                                                                                                   | State 4                                                                                                     | State 5                                                                                           |
| -------------------- | ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **notAuthenticated** | <p><span data-gb-custom-inline data-tag="emoji" data-code="1f4a1">💡</span><br>''                       </p> |                                                                                                          | <p><span data-gb-custom-inline data-tag="emoji" data-code="1f4a1">💡</span> </p><p>'invalid password'</p> |                                                                                                             |                                                                                                   |
| **authenticating**   |                                                                                                              | <p><span data-gb-custom-inline data-tag="emoji" data-code="1f4a1">💡</span> </p><p>\[username/TACOS]</p> |                                                                                                           | <p><span data-gb-custom-inline data-tag="emoji" data-code="1f4a1">💡</span> </p><p>\[username/password]</p> |                                                                                                   |
| **authenticated**    |                                                                                                              |                                                                                                          |                                                                                                           |                                                                                                             | <p><span data-gb-custom-inline data-tag="emoji" data-code="1f4a1">💡</span></p><p>credentials</p> |

We provide you with two serialisation mechanisms, one to serialise everything, the other one to serialise a single status.

Both of them leverage Conan State to provide you the final serialised result.

### toStateAll() - Serialising everything

```typescript
authentication$F.toStateAll()
```

By serialising all, you will create a [ConanState](/api/main-classes/conan-state.md) of [Status](/api/main-classes/conanflow/status.md)

From the example above, this would be the visual equivalent of the generate ConanState.

|              | State 1                                                                                                                    | State 2                                                                                          | State 3                                                                                          | State 4                                                                                             | State 5                                                                                  |
| ------------ | -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| **nextData** | <p><strong>name</strong><br>notAuthenticated</p><p><strong>data</strong><br><strong>''</strong>                       </p> | <p><strong>name</strong><br>authenticating</p><p><strong>data</strong><br>username/<br>TACOS</p> | <p><strong>name</strong><br>notAuthenticated</p><p><strong>data</strong><br>'invalid pass..'</p> | <p><strong>name</strong><br>authenticating</p><p><strong>data</strong><br>username/<br>password</p> | <p><strong>name</strong><br>authenticated</p><p><strong>data</strong><br>credentials</p> |

### �toState(statusName) - Serialising a single status

Similar to toStateAll, toState statusName), will generate a ConanState of the data type associated to the status being serialised.

Let's have a look at a couple of examples

```typescript
authentication$F.toState('notAuhtenticated')
```

Will generate a ConanState which will provide the following states

|              | State 1 | State 2            |
| ------------ | ------- | ------------------ |
| **nextData** | **''**  | 'invalid password' |

```typescript
authentication$F.toState('authenticating')
```

Will generate a ConanState which will provide the following states

|              | State 1           | State 2              |
| ------------ | ----------------- | -------------------- |
| **nextData** | \[username/TACOS] | \[username/password] |

{% hint style="info" %}
To see some example for serialisation, check our [Testing State](/data/conan-state/testing.md), in that example, we leverage the serialisation of flows to show what the underlying [meta flow](/data/conan-state/life-cycle.md#the-meta-flow) is doing
{% endhint %}

## Using Conan Flows

You might be familiar with the [TACOS](/data/general-concepts.md#attributes-tacos) acronym that describe the attributes for Conan Data.

[Conan State](/data/conan-state.md) documents these in detail in its different document sections.

By being able to transform Conan Flows into Conan State, you should be able to leverage these attributes for Conan Flows too.

Note that for convenience we also provide with some shortcuts for [observing flows](/data/flows/testing-flows.md), but we think the best way to leverage flows is to convert them into Conan State.


---

# 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 dynamically by asking a question.

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

```
GET https://docs.conanjs.io/data/flows/flows-as-state.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
