> For the complete documentation index, see [llms.txt](https://developer.celigo.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.celigo.com/cli/commands/state.md).

# state

Manage state key-value stores — durable JSON values keyed by name. Commands target global (account-wide) state by default; pass `--resource-type` and `--resource-id` together to target a specific resource's state instead.

**REST API**: [State](https://developer.celigo.com/api/api-reference/data-stores/state)

```
celigo state <subcommand> [args] [flags]
```

Supports all [global flags](https://developer.celigo.com/cli/getting-started/global-flags.md).

## Subcommands

| Subcommand     | Purpose                                                |
| -------------- | ------------------------------------------------------ |
| `list`         | List state keys — global, or a resource's.             |
| `get <key>`    | Get a state value — global, or a resource's.           |
| `set <key>`    | Set a state key from a JSON body (stdin, or `--file`). |
| `delete <key>` | Delete one state key — global, or a resource's.        |
| `purge`        | Delete all state keys — global, or a resource's.       |

The `--resource-type <type>` and `--resource-id <id>` flags switch any subcommand from global state to a resource's state. They must be passed together, and `--resource-type` takes `exports`, `imports`, or `integrations` — the resource types the API keeps state for.

Since celigo-cli 2026.10.1, the scope flags are checked before any request. Any other resource type is refused — `--resource-type 'flows' has no resource-scoped state: the API keeps state for exports, imports or integrations only.` — where it used to come back from the API as a `403` that read like a permissions problem. A blank value (an unset shell variable) is refused instead of falling back to global state, and so is a value holding `/`, `?`, `#`, `\`, or whitespace, which would change the request path.

Any other type's state route answers `403` `invalid_ref` "State not available for the given model.", whatever the id — reached, for example, with `celigo platform get v1/flows/<id>/state` (see [platform](https://developer.celigo.com/cli/commands/platform.md#celigo-platform-get-less-than-path-greater-than)). Since celigo-cli 2026.10.2 the hint printed with that error says that only exports, imports and integrations keep resource-scoped state, and points at `celigo state`; it used to say that an id in the request didn't exist.

***

## `celigo state list`

List state keys. Global by default; pass `--resource-type`/`--resource-id` to list a resource's keys instead.

The API returns key names only, never values — read a value with `get`. JSON output is the API's envelope, `{"keys": [...]}`. Since celigo-cli 2026.10.1, `--format table` lists one key per row (it printed one blank row), and an empty store prints `{"keys": []}` (it printed `null`).

**Signature**

```bash
celigo state list [flags]
```

**Flags**

| Flag                     | Type   | Default | Description                                                                                                            |
| ------------------------ | ------ | ------- | ---------------------------------------------------------------------------------------------------------------------- |
| `--resource-type <type>` | string | —       | Target a resource's state (`exports`, `imports`, or `integrations`) instead of global state. Requires `--resource-id`. |
| `--resource-id <id>`     | string | —       | Resource id whose state to target. Requires `--resource-type`.                                                         |

**Example**

```bash
celigo state list --format table
celigo state list --resource-type exports --resource-id 5f83a9b2c7d3e8f1a2b3c4d5
```

**Corresponds to**: `GET /v1/state` (global) or `GET /v1/{resourceType}/{resourceId}/state` (resource-scoped).

***

## `celigo state get`

Get the value stored under one state key.

**Signature**

```bash
celigo state get <key> [flags]
```

**Arguments**

| Argument | Type   | Required | Description     |
| -------- | ------ | -------- | --------------- |
| `<key>`  | string | Yes      | State key name. |

**Flags**

| Flag                     | Type   | Default | Description                                                                                                            |
| ------------------------ | ------ | ------- | ---------------------------------------------------------------------------------------------------------------------- |
| `--resource-type <type>` | string | —       | Target a resource's state (`exports`, `imports`, or `integrations`) instead of global state. Requires `--resource-id`. |
| `--resource-id <id>`     | string | —       | Resource id whose state to target. Requires `--resource-type`.                                                         |

**Example**

```bash
celigo state get lastRunCheckpoint --format json
celigo state get cursor --resource-type exports --resource-id 5f83a9b2c7d3e8f1a2b3c4d5
```

**Corresponds to**: `GET /v1/state/{key}` (global) or `GET /v1/{resourceType}/{resourceId}/state/{key}` (resource-scoped).

***

## `celigo state set`

Set a state key from a JSON body read from stdin or `--file`. Full replace of the value stored under the key.

**Signature**

```bash
celigo state set <key> [flags]
```

**Arguments**

| Argument | Type   | Required | Description     |
| -------- | ------ | -------- | --------------- |
| `<key>`  | string | Yes      | State key name. |

**Flags**

| Flag                     | Type   | Default | Description                                                                                                            |
| ------------------------ | ------ | ------- | ---------------------------------------------------------------------------------------------------------------------- |
| `-f, --file <path>`      | string | stdin   | Read the JSON body from a file instead of stdin (`-` also means stdin).                                                |
| `--resource-type <type>` | string | —       | Target a resource's state (`exports`, `imports`, or `integrations`) instead of global state. Requires `--resource-id`. |
| `--resource-id <id>`     | string | —       | Resource id whose state to target. Requires `--resource-type`.                                                         |

**Request body**

Reads JSON on stdin (or from `--file`). The body is stored verbatim as the value for the key.

**Example**

```bash
echo '{"cursor":"2026-06-13T00:00:00Z"}' | celigo state set lastRunCheckpoint
celigo state set lastRunCheckpoint --file checkpoint.json
celigo state set cursor --resource-type exports --resource-id 5f83a9b2c7d3e8f1a2b3c4d5 --file cursor.json
```

**Corresponds to**: `PUT /v1/state/{key}` (global) or `PUT /v1/{resourceType}/{resourceId}/state/{key}` (resource-scoped).

***

## `celigo state delete`

Delete one state key. Prompts for confirmation unless `-y` is passed.

> ⚠️ **Deleting a state key is permanent.** The value stored under the key is removed and cannot be recovered.

**Signature**

```bash
celigo state delete <key> [flags]
```

**Arguments**

| Argument | Type   | Required | Description     |
| -------- | ------ | -------- | --------------- |
| `<key>`  | string | Yes      | State key name. |

**Flags**

| Flag                     | Type    | Default | Description                                                                                                            |
| ------------------------ | ------- | ------- | ---------------------------------------------------------------------------------------------------------------------- |
| `-y, --yes`              | boolean | `false` | Skip confirmation.                                                                                                     |
| `--resource-type <type>` | string  | —       | Target a resource's state (`exports`, `imports`, or `integrations`) instead of global state. Requires `--resource-id`. |
| `--resource-id <id>`     | string  | —       | Resource id whose state to target. Requires `--resource-type`.                                                         |

**Example**

```bash
celigo state delete lastRunCheckpoint -y
celigo state delete cursor --resource-type exports --resource-id 5f83a9b2c7d3e8f1a2b3c4d5 -y
```

**Corresponds to**: `DELETE /v1/state/{key}` (global) or `DELETE /v1/{resourceType}/{resourceId}/state/{key}` (resource-scoped).

***

## `celigo state purge`

Delete all state keys in scope. Global by default; pass `--resource-type`/`--resource-id` to purge a resource's keys instead. Prompts for confirmation unless `-y` is passed.

> ⚠️ **`purge` deletes every key in scope.** All state values for the target — global, or the specified resource — are removed and cannot be recovered.

**Signature**

```bash
celigo state purge [flags]
```

**Flags**

| Flag                     | Type    | Default | Description                                                                                                            |
| ------------------------ | ------- | ------- | ---------------------------------------------------------------------------------------------------------------------- |
| `-y, --yes`              | boolean | `false` | Skip confirmation.                                                                                                     |
| `--resource-type <type>` | string  | —       | Target a resource's state (`exports`, `imports`, or `integrations`) instead of global state. Requires `--resource-id`. |
| `--resource-id <id>`     | string  | —       | Resource id whose state to target. Requires `--resource-type`.                                                         |

**Example**

```bash
celigo state purge -y
celigo state purge --resource-type exports --resource-id 5f83a9b2c7d3e8f1a2b3c4d5 -y
```

**Corresponds to**: `DELETE /v1/state` (global) or `DELETE /v1/{resourceType}/{resourceId}/state` (resource-scoped).

***

## Gotchas

* **`set` is a full replace.** The JSON body you pipe in replaces the entire value stored under the key — there is no partial merge.
* **`--resource-type` and `--resource-id` go together.** Pass both to target a resource's state; pass neither for global state. One without the other is an error, and the type must be `exports`, `imports`, or `integrations`.
* **`purge` is destructive.** It drops every key in its scope (global, or the targeted resource); it prompts for confirmation unless you pass `-y`.
* **Global vs. resource scope are separate stores.** A key set globally is not visible when you target a resource, and vice versa.
* **Keys are sent whole.** Since celigo-cli 2026.10.1, `get`, `set`, and `delete` URL-encode the key into the request path, so a `?`, `#`, or `/` in a key stays part of the key instead of changing the path.
* **Permission modes.** `list` and `get` work in `read` mode. `set` is refused in `read` mode and runs in `operate` mode. `delete` and `purge` need `full` mode. See [Profiles & regions](https://developer.celigo.com/cli/getting-started/profiles.md#permission-modes).


---

# 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://developer.celigo.com/cli/commands/state.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.
