---
title: Dreams
url: https://platform.claude.com/docs/en/api/php/beta/dreams
---

# Dreams

## Create a Dream

`$client->beta->dreams->create(list<BetaDreamInput> inputs, Model model, ?string instructions, ?BetaOutputBehavior outputBehavior, ?list<AnthropicBeta> betas, ?string workspaceID): BetaDream`

**POST** `/v1/dreams`

Start an asynchronous job that uses past sessions to produce a reorganized version of a memory store and get back the dream to poll for the result.

By default the dream writes its result to a new memory store and doesn't change the input memory store. The response has `status` set to `pending` and an empty `outputs` array. Poll the dream until `status` is `completed`, `failed`, or `canceled`.

See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#create-a-dream) to learn more about creating dreams.

### Parameters

- `inputs: list<BetaDreamInput>`

  The memory store and sessions for the dream to read, as exactly one `memory_store` entry and exactly one `sessions` entry.

- `model: Model`

  The model that runs a dream, given as a model ID or as an object with `id` and `speed`.

  In the object form, `speed` can only be `standard`.

  The [Availability section of the Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#feature-availability) lists the supported models.

- `instructions?: optional string`

  Guidance that steers how the dream reads the sessions and organizes the output memory store, from 1 to 4,096 characters.

  See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#steer-with-instructions) for what kinds of instructions work well.

- `outputBehavior?: optional BetaOutputBehavior`

  Which memory store a dream writes its result to. Defaults to `create_new` when left out of a create request.

- `betas?: optional list<AnthropicBeta>` (header parameter)

  This endpoint is in beta: requests must send `dreaming-2026-04-21` in this header.

- `workspaceID?: optional string` (header parameter)

  Optional header to select the Workspace for this request. The value is a Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).

  Only needed for credentials that can act on more than one Workspace. A credential that belongs to a specific Workspace may omit it; if sent, it must match that Workspace.

### Returns

- `class BetaDream`

  - `"dream" type`

  - `string id`

    The unique ID of the dream (`drm_...`).

  - `?\Datetime archivedAt`

    When the dream was archived, in RFC 3339, or `null` if it hasn't been archived.

  - `\Datetime createdAt`

    When the dream was created, in RFC 3339.

    Lists of dreams are sorted by this time, newest first.

  - `?\Datetime endedAt`

    When the dream reached `completed`, `failed`, or `canceled`, in RFC 3339, or `null` if it is still `pending` or `running`.

  - `?BetaDreamError error`

    Why the dream failed, or `null` if `status` isn't `failed`.

  - `list<BetaDreamInput> inputs`

    The sources that the dream reads, from the request that created it.

  - `?string instructions`

    The guidance given when the dream was created, or `null` if none was given.

  - `BetaDreamModelConfig model`

    The model that runs a dream, from the request that created it.

    The dream uses this model for all of its work. The response always gives the model as an object, even if the request gave only a model ID.

  - `BetaOutputBehavior outputBehavior`

    Where the dream writes its result, as set in the request that created the dream. If that request left out `output_behavior`, the dream used the `create_new` behavior.

  - `list<BetaDreamOutput> outputs`

    The memory store that holds the dream's result, as a one-item array, or an empty array until the dream records that memory store.

    The array is empty while the dream is `pending` and for a short time after it starts `running`. It can stay empty if the dream fails or is canceled before then. The memory store holds the complete result only once `status` is `completed`.

    See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#use-the-output) for how to review and use the result.

  - `?string sessionID`

    The ID of the session that runs the dream (`sesn_...`), or `null` if that session hasn't started.

    Stream that session's events to follow what the dream reads and writes.

    See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#watch-the-pipeline-run) for how to watch a running dream.

  - `BetaDreamStatus status`

    Where a dream is in its lifecycle.

    `completed`, `failed`, and `canceled` are final: once a dream has one of these statuses, its status doesn't change again.

    See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#lifecycle) for what each status means.

  - `BetaDreamUsage usage`

    The dream's token counts, which stop changing once its `status` is `completed` or `failed`. After a cancel, they can keep changing.

### Example

```php
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Anthropic\Client;
use Anthropic\Beta\AnthropicBeta;

$client = new Client(apiKey: 'my-anthropic-api-key');

$betaDream = $client->beta->dreams->create(
  inputs: [['memoryStoreID' => 'x', 'type' => 'memory_store']],
  model: 'string',
  instructions: 'x',
  outputBehavior: ['type' => 'create_new'],
  betas: [AnthropicBeta::MESSAGE_BATCHES_2024_09_24],
  workspaceID: 'wrkspc_011CZkZaBF1tNoB5wlCeusgy',
);

var_dump($betaDream);
```

#### Response (200)

```json
{
  "id": "id",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "created_at": "2019-12-27T18:11:19.117Z",
  "ended_at": "2019-12-27T18:11:19.117Z",
  "error": {
    "message": "message",
    "type": "type"
  },
  "inputs": [
    {
      "memory_store_id": "x",
      "type": "memory_store"
    }
  ],
  "instructions": "instructions",
  "model": {
    "id": "x",
    "speed": "standard"
  },
  "output_behavior": {
    "type": "create_new"
  },
  "outputs": [
    {
      "memory_store_id": "memory_store_id",
      "type": "memory_store"
    }
  ],
  "session_id": "session_id",
  "status": "pending",
  "type": "dream",
  "usage": {
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "input_tokens": 0,
    "output_tokens": 0
  }
}
```

## List Dreams

`$client->beta->dreams->list(?\Datetime createdAtGt, ?\Datetime createdAtLt, ?bool includeArchived, ?int limit, ?string page, ?list<BetaDreamStatus> statuses, ?list<AnthropicBeta> betas, ?string workspaceID): PageCursor<BetaDream>`

**GET** `/v1/dreams`

List the dreams in the workspace, newest first.

Archived dreams are left out unless `include_archived` is `true`.

See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#list-dreams) for how to page through dreams.

### Parameters

- `createdAtGt?: optional \Datetime` (query parameter)

  Return only dreams created after this time (exclusive), in RFC 3339.

- `createdAtLt?: optional \Datetime` (query parameter)

  Return only dreams created before this time (exclusive), in RFC 3339.

- `includeArchived?: optional bool` (query parameter)

  Whether to include archived dreams. Defaults to `false`.

- `limit?: optional int` (query parameter)

  The maximum number of dreams to return, from 1 to 100. Defaults to 20.

- `page?: optional string` (query parameter)

  The cursor for the page to return, taken from `next_page` in a previous response.

  Leave it out to get the first page.

- `statuses?: optional list<BetaDreamStatus>` (query parameter)

  Return only dreams that have one of these statuses.

  Repeat the parameter to give more than one status. Leave it out to return dreams of every status.

- `betas?: optional list<AnthropicBeta>` (header parameter)

  This endpoint is in beta: requests must send `dreaming-2026-04-21` in this header.

- `workspaceID?: optional string` (header parameter)

  Optional header to select the Workspace for this request. The value is a Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).

  Only needed for credentials that can act on more than one Workspace. A credential that belongs to a specific Workspace may omit it; if sent, it must match that Workspace.

### Returns

- `class BetaDream`

  - `"dream" type`

  - `string id`

    The unique ID of the dream (`drm_...`).

  - `?\Datetime archivedAt`

    When the dream was archived, in RFC 3339, or `null` if it hasn't been archived.

  - `\Datetime createdAt`

    When the dream was created, in RFC 3339.

    Lists of dreams are sorted by this time, newest first.

  - `?\Datetime endedAt`

    When the dream reached `completed`, `failed`, or `canceled`, in RFC 3339, or `null` if it is still `pending` or `running`.

  - `?BetaDreamError error`

    Why the dream failed, or `null` if `status` isn't `failed`.

  - `list<BetaDreamInput> inputs`

    The sources that the dream reads, from the request that created it.

  - `?string instructions`

    The guidance given when the dream was created, or `null` if none was given.

  - `BetaDreamModelConfig model`

    The model that runs a dream, from the request that created it.

    The dream uses this model for all of its work. The response always gives the model as an object, even if the request gave only a model ID.

  - `BetaOutputBehavior outputBehavior`

    Where the dream writes its result, as set in the request that created the dream. If that request left out `output_behavior`, the dream used the `create_new` behavior.

  - `list<BetaDreamOutput> outputs`

    The memory store that holds the dream's result, as a one-item array, or an empty array until the dream records that memory store.

    The array is empty while the dream is `pending` and for a short time after it starts `running`. It can stay empty if the dream fails or is canceled before then. The memory store holds the complete result only once `status` is `completed`.

    See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#use-the-output) for how to review and use the result.

  - `?string sessionID`

    The ID of the session that runs the dream (`sesn_...`), or `null` if that session hasn't started.

    Stream that session's events to follow what the dream reads and writes.

    See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#watch-the-pipeline-run) for how to watch a running dream.

  - `BetaDreamStatus status`

    Where a dream is in its lifecycle.

    `completed`, `failed`, and `canceled` are final: once a dream has one of these statuses, its status doesn't change again.

    See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#lifecycle) for what each status means.

  - `BetaDreamUsage usage`

    The dream's token counts, which stop changing once its `status` is `completed` or `failed`. After a cancel, they can keep changing.

### Example

```php
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Anthropic\Client;
use Anthropic\Beta\AnthropicBeta;
use Anthropic\Beta\Dreams\BetaDreamStatus;

$client = new Client(apiKey: 'my-anthropic-api-key');

$page = $client->beta->dreams->list(
  createdAtGt: new \DateTimeImmutable('2019-12-27T18:11:19.117Z'),
  createdAtLt: new \DateTimeImmutable('2019-12-27T18:11:19.117Z'),
  includeArchived: true,
  limit: 0,
  page: 'page',
  statuses: [BetaDreamStatus::PENDING],
  betas: [AnthropicBeta::MESSAGE_BATCHES_2024_09_24],
  workspaceID: 'wrkspc_011CZkZaBF1tNoB5wlCeusgy',
);

var_dump($page);
```

#### Response (200)

```json
{
  "data": [
    {
      "id": "id",
      "archived_at": "2019-12-27T18:11:19.117Z",
      "created_at": "2019-12-27T18:11:19.117Z",
      "ended_at": "2019-12-27T18:11:19.117Z",
      "error": {
        "message": "message",
        "type": "type"
      },
      "inputs": [
        {
          "memory_store_id": "x",
          "type": "memory_store"
        }
      ],
      "instructions": "instructions",
      "model": {
        "id": "x",
        "speed": "standard"
      },
      "output_behavior": {
        "type": "create_new"
      },
      "outputs": [
        {
          "memory_store_id": "memory_store_id",
          "type": "memory_store"
        }
      ],
      "session_id": "session_id",
      "status": "pending",
      "type": "dream",
      "usage": {
        "cache_creation_input_tokens": 0,
        "cache_read_input_tokens": 0,
        "input_tokens": 0,
        "output_tokens": 0
      }
    }
  ],
  "next_page": "next_page"
}
```

## Get a Dream

`$client->beta->dreams->retrieve(string dreamID, ?list<AnthropicBeta> betas, ?string workspaceID): BetaDream`

**GET** `/v1/dreams/{dream_id}`

Get a dream by ID to check its status, output memory store, and token usage.

Archived dreams are returned too.

See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#track-progress) for how to poll a dream and what each status means.

### Parameters

- `dreamID: string` (path parameter)

  The ID of the dream to get (`drm_...`).

- `betas?: optional list<AnthropicBeta>` (header parameter)

  This endpoint is in beta: requests must send `dreaming-2026-04-21` in this header.

- `workspaceID?: optional string` (header parameter)

  Optional header to select the Workspace for this request. The value is a Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).

  Only needed for credentials that can act on more than one Workspace. A credential that belongs to a specific Workspace may omit it; if sent, it must match that Workspace.

### Returns

- `class BetaDream`

  - `"dream" type`

  - `string id`

    The unique ID of the dream (`drm_...`).

  - `?\Datetime archivedAt`

    When the dream was archived, in RFC 3339, or `null` if it hasn't been archived.

  - `\Datetime createdAt`

    When the dream was created, in RFC 3339.

    Lists of dreams are sorted by this time, newest first.

  - `?\Datetime endedAt`

    When the dream reached `completed`, `failed`, or `canceled`, in RFC 3339, or `null` if it is still `pending` or `running`.

  - `?BetaDreamError error`

    Why the dream failed, or `null` if `status` isn't `failed`.

  - `list<BetaDreamInput> inputs`

    The sources that the dream reads, from the request that created it.

  - `?string instructions`

    The guidance given when the dream was created, or `null` if none was given.

  - `BetaDreamModelConfig model`

    The model that runs a dream, from the request that created it.

    The dream uses this model for all of its work. The response always gives the model as an object, even if the request gave only a model ID.

  - `BetaOutputBehavior outputBehavior`

    Where the dream writes its result, as set in the request that created the dream. If that request left out `output_behavior`, the dream used the `create_new` behavior.

  - `list<BetaDreamOutput> outputs`

    The memory store that holds the dream's result, as a one-item array, or an empty array until the dream records that memory store.

    The array is empty while the dream is `pending` and for a short time after it starts `running`. It can stay empty if the dream fails or is canceled before then. The memory store holds the complete result only once `status` is `completed`.

    See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#use-the-output) for how to review and use the result.

  - `?string sessionID`

    The ID of the session that runs the dream (`sesn_...`), or `null` if that session hasn't started.

    Stream that session's events to follow what the dream reads and writes.

    See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#watch-the-pipeline-run) for how to watch a running dream.

  - `BetaDreamStatus status`

    Where a dream is in its lifecycle.

    `completed`, `failed`, and `canceled` are final: once a dream has one of these statuses, its status doesn't change again.

    See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#lifecycle) for what each status means.

  - `BetaDreamUsage usage`

    The dream's token counts, which stop changing once its `status` is `completed` or `failed`. After a cancel, they can keep changing.

### Example

```php
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Anthropic\Client;
use Anthropic\Beta\AnthropicBeta;

$client = new Client(apiKey: 'my-anthropic-api-key');

$betaDream = $client->beta->dreams->retrieve(
  'dream_id',
  betas: [AnthropicBeta::MESSAGE_BATCHES_2024_09_24],
  workspaceID: 'wrkspc_011CZkZaBF1tNoB5wlCeusgy',
);

var_dump($betaDream);
```

#### Response (200)

```json
{
  "id": "id",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "created_at": "2019-12-27T18:11:19.117Z",
  "ended_at": "2019-12-27T18:11:19.117Z",
  "error": {
    "message": "message",
    "type": "type"
  },
  "inputs": [
    {
      "memory_store_id": "x",
      "type": "memory_store"
    }
  ],
  "instructions": "instructions",
  "model": {
    "id": "x",
    "speed": "standard"
  },
  "output_behavior": {
    "type": "create_new"
  },
  "outputs": [
    {
      "memory_store_id": "memory_store_id",
      "type": "memory_store"
    }
  ],
  "session_id": "session_id",
  "status": "pending",
  "type": "dream",
  "usage": {
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "input_tokens": 0,
    "output_tokens": 0
  }
}
```

## Cancel a Dream

`$client->beta->dreams->cancel(string dreamID, ?list<AnthropicBeta> betas, ?string workspaceID): BetaDream`

**POST** `/v1/dreams/{dream_id}/cancel`

Stop a `pending` or `running` dream.

The response shows `status` as `canceled`, unless the dream reached `completed` or `failed` first. `usage` can keep changing after the response. Canceling a `canceled` dream returns it unchanged. Canceling a `completed` or `failed` dream returns a 400 error.

See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#cancel-a-dream) to learn more about canceling dreams.

### Parameters

- `dreamID: string` (path parameter)

  The ID of the dream to cancel (`drm_...`).

- `betas?: optional list<AnthropicBeta>` (header parameter)

  This endpoint is in beta: requests must send `dreaming-2026-04-21` in this header.

- `workspaceID?: optional string` (header parameter)

  Optional header to select the Workspace for this request. The value is a Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).

  Only needed for credentials that can act on more than one Workspace. A credential that belongs to a specific Workspace may omit it; if sent, it must match that Workspace.

### Returns

- `class BetaDream`

  - `"dream" type`

  - `string id`

    The unique ID of the dream (`drm_...`).

  - `?\Datetime archivedAt`

    When the dream was archived, in RFC 3339, or `null` if it hasn't been archived.

  - `\Datetime createdAt`

    When the dream was created, in RFC 3339.

    Lists of dreams are sorted by this time, newest first.

  - `?\Datetime endedAt`

    When the dream reached `completed`, `failed`, or `canceled`, in RFC 3339, or `null` if it is still `pending` or `running`.

  - `?BetaDreamError error`

    Why the dream failed, or `null` if `status` isn't `failed`.

  - `list<BetaDreamInput> inputs`

    The sources that the dream reads, from the request that created it.

  - `?string instructions`

    The guidance given when the dream was created, or `null` if none was given.

  - `BetaDreamModelConfig model`

    The model that runs a dream, from the request that created it.

    The dream uses this model for all of its work. The response always gives the model as an object, even if the request gave only a model ID.

  - `BetaOutputBehavior outputBehavior`

    Where the dream writes its result, as set in the request that created the dream. If that request left out `output_behavior`, the dream used the `create_new` behavior.

  - `list<BetaDreamOutput> outputs`

    The memory store that holds the dream's result, as a one-item array, or an empty array until the dream records that memory store.

    The array is empty while the dream is `pending` and for a short time after it starts `running`. It can stay empty if the dream fails or is canceled before then. The memory store holds the complete result only once `status` is `completed`.

    See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#use-the-output) for how to review and use the result.

  - `?string sessionID`

    The ID of the session that runs the dream (`sesn_...`), or `null` if that session hasn't started.

    Stream that session's events to follow what the dream reads and writes.

    See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#watch-the-pipeline-run) for how to watch a running dream.

  - `BetaDreamStatus status`

    Where a dream is in its lifecycle.

    `completed`, `failed`, and `canceled` are final: once a dream has one of these statuses, its status doesn't change again.

    See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#lifecycle) for what each status means.

  - `BetaDreamUsage usage`

    The dream's token counts, which stop changing once its `status` is `completed` or `failed`. After a cancel, they can keep changing.

### Example

```php
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Anthropic\Client;
use Anthropic\Beta\AnthropicBeta;

$client = new Client(apiKey: 'my-anthropic-api-key');

$betaDream = $client->beta->dreams->cancel(
  'dream_id',
  betas: [AnthropicBeta::MESSAGE_BATCHES_2024_09_24],
  workspaceID: 'wrkspc_011CZkZaBF1tNoB5wlCeusgy',
);

var_dump($betaDream);
```

#### Response (200)

```json
{
  "id": "id",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "created_at": "2019-12-27T18:11:19.117Z",
  "ended_at": "2019-12-27T18:11:19.117Z",
  "error": {
    "message": "message",
    "type": "type"
  },
  "inputs": [
    {
      "memory_store_id": "x",
      "type": "memory_store"
    }
  ],
  "instructions": "instructions",
  "model": {
    "id": "x",
    "speed": "standard"
  },
  "output_behavior": {
    "type": "create_new"
  },
  "outputs": [
    {
      "memory_store_id": "memory_store_id",
      "type": "memory_store"
    }
  ],
  "session_id": "session_id",
  "status": "pending",
  "type": "dream",
  "usage": {
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "input_tokens": 0,
    "output_tokens": 0
  }
}
```

## Archive a Dream

`$client->beta->dreams->archive(string dreamID, ?list<AnthropicBeta> betas, ?string workspaceID): BetaDream`

**POST** `/v1/dreams/{dream_id}/archive`

Hide a `completed`, `failed`, or `canceled` dream from the default list of dreams.

Archiving a `pending` or `running` dream returns a 400 error, so cancel it first. Archiving an archived dream returns it unchanged. An archived dream can still be fetched by ID. Archiving can't be undone.

See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#archive-a-dream) to learn more about archiving dreams.

### Parameters

- `dreamID: string` (path parameter)

  The ID of the dream to archive (`drm_...`).

- `betas?: optional list<AnthropicBeta>` (header parameter)

  This endpoint is in beta: requests must send `dreaming-2026-04-21` in this header.

- `workspaceID?: optional string` (header parameter)

  Optional header to select the Workspace for this request. The value is a Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).

  Only needed for credentials that can act on more than one Workspace. A credential that belongs to a specific Workspace may omit it; if sent, it must match that Workspace.

### Returns

- `class BetaDream`

  - `"dream" type`

  - `string id`

    The unique ID of the dream (`drm_...`).

  - `?\Datetime archivedAt`

    When the dream was archived, in RFC 3339, or `null` if it hasn't been archived.

  - `\Datetime createdAt`

    When the dream was created, in RFC 3339.

    Lists of dreams are sorted by this time, newest first.

  - `?\Datetime endedAt`

    When the dream reached `completed`, `failed`, or `canceled`, in RFC 3339, or `null` if it is still `pending` or `running`.

  - `?BetaDreamError error`

    Why the dream failed, or `null` if `status` isn't `failed`.

  - `list<BetaDreamInput> inputs`

    The sources that the dream reads, from the request that created it.

  - `?string instructions`

    The guidance given when the dream was created, or `null` if none was given.

  - `BetaDreamModelConfig model`

    The model that runs a dream, from the request that created it.

    The dream uses this model for all of its work. The response always gives the model as an object, even if the request gave only a model ID.

  - `BetaOutputBehavior outputBehavior`

    Where the dream writes its result, as set in the request that created the dream. If that request left out `output_behavior`, the dream used the `create_new` behavior.

  - `list<BetaDreamOutput> outputs`

    The memory store that holds the dream's result, as a one-item array, or an empty array until the dream records that memory store.

    The array is empty while the dream is `pending` and for a short time after it starts `running`. It can stay empty if the dream fails or is canceled before then. The memory store holds the complete result only once `status` is `completed`.

    See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#use-the-output) for how to review and use the result.

  - `?string sessionID`

    The ID of the session that runs the dream (`sesn_...`), or `null` if that session hasn't started.

    Stream that session's events to follow what the dream reads and writes.

    See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#watch-the-pipeline-run) for how to watch a running dream.

  - `BetaDreamStatus status`

    Where a dream is in its lifecycle.

    `completed`, `failed`, and `canceled` are final: once a dream has one of these statuses, its status doesn't change again.

    See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#lifecycle) for what each status means.

  - `BetaDreamUsage usage`

    The dream's token counts, which stop changing once its `status` is `completed` or `failed`. After a cancel, they can keep changing.

### Example

```php
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Anthropic\Client;
use Anthropic\Beta\AnthropicBeta;

$client = new Client(apiKey: 'my-anthropic-api-key');

$betaDream = $client->beta->dreams->archive(
  'dream_id',
  betas: [AnthropicBeta::MESSAGE_BATCHES_2024_09_24],
  workspaceID: 'wrkspc_011CZkZaBF1tNoB5wlCeusgy',
);

var_dump($betaDream);
```

#### Response (200)

```json
{
  "id": "id",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "created_at": "2019-12-27T18:11:19.117Z",
  "ended_at": "2019-12-27T18:11:19.117Z",
  "error": {
    "message": "message",
    "type": "type"
  },
  "inputs": [
    {
      "memory_store_id": "x",
      "type": "memory_store"
    }
  ],
  "instructions": "instructions",
  "model": {
    "id": "x",
    "speed": "standard"
  },
  "output_behavior": {
    "type": "create_new"
  },
  "outputs": [
    {
      "memory_store_id": "memory_store_id",
      "type": "memory_store"
    }
  ],
  "session_id": "session_id",
  "status": "pending",
  "type": "dream",
  "usage": {
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "input_tokens": 0,
    "output_tokens": 0
  }
}
```

## Domain types

### Beta Dream

- `class BetaDream`

  - `"dream" type`

  - `string id`

    The unique ID of the dream (`drm_...`).

  - `?\Datetime archivedAt`

    When the dream was archived, in RFC 3339, or `null` if it hasn't been archived.

  - `\Datetime createdAt`

    When the dream was created, in RFC 3339.

    Lists of dreams are sorted by this time, newest first.

  - `?\Datetime endedAt`

    When the dream reached `completed`, `failed`, or `canceled`, in RFC 3339, or `null` if it is still `pending` or `running`.

  - `?BetaDreamError error`

    Why the dream failed, or `null` if `status` isn't `failed`.

  - `list<BetaDreamInput> inputs`

    The sources that the dream reads, from the request that created it.

  - `?string instructions`

    The guidance given when the dream was created, or `null` if none was given.

  - `BetaDreamModelConfig model`

    The model that runs a dream, from the request that created it.

    The dream uses this model for all of its work. The response always gives the model as an object, even if the request gave only a model ID.

  - `BetaOutputBehavior outputBehavior`

    Where the dream writes its result, as set in the request that created the dream. If that request left out `output_behavior`, the dream used the `create_new` behavior.

  - `list<BetaDreamOutput> outputs`

    The memory store that holds the dream's result, as a one-item array, or an empty array until the dream records that memory store.

    The array is empty while the dream is `pending` and for a short time after it starts `running`. It can stay empty if the dream fails or is canceled before then. The memory store holds the complete result only once `status` is `completed`.

    See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#use-the-output) for how to review and use the result.

  - `?string sessionID`

    The ID of the session that runs the dream (`sesn_...`), or `null` if that session hasn't started.

    Stream that session's events to follow what the dream reads and writes.

    See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#watch-the-pipeline-run) for how to watch a running dream.

  - `BetaDreamStatus status`

    Where a dream is in its lifecycle.

    `completed`, `failed`, and `canceled` are final: once a dream has one of these statuses, its status doesn't change again.

    See the [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#lifecycle) for what each status means.

  - `BetaDreamUsage usage`

    The dream's token counts, which stop changing once its `status` is `completed` or `failed`. After a cancel, they can keep changing.

### Beta Dream Error

- `class BetaDreamError`

  - `string type`

    A code for why the dream failed, such as `timeout` or `internal_error`.

    The [Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#errors) lists common error codes and when they occur.

  - `string message`

    A human-readable explanation of why the dream failed.

### Beta Dream Input

- `class BetaDreamInput`

  - `class BetaDreamMemoryStoreInput`

    - `"memory_store" type`

    - `string memoryStoreID`

      The ID of the memory store for the dream to read (`memstore_...`).

      The memory store must be in the same workspace as the dream and must not be archived.

  - `class BetaDreamSessionsInput`

    - `"sessions" type`

    - `list<string> sessionIDs`

      The IDs of the sessions whose transcripts the dream reads (`sesn_...`).

      Give 1 to 100 IDs, with no duplicates. Each session must be in the same workspace as the dream. Responses list the IDs in sorted order.

### Beta Dream Memory Store Input

- `class BetaDreamMemoryStoreInput`

  - `"memory_store" type`

  - `string memoryStoreID`

    The ID of the memory store for the dream to read (`memstore_...`).

    The memory store must be in the same workspace as the dream and must not be archived.

### Beta Dream Memory Store Output

- `class BetaDreamMemoryStoreOutput`

  - `"memory_store" type`

  - `string memoryStoreID`

    The ID of the memory store that the dream writes its result to (`memstore_...`).

    With `output_behavior` set to `create_new`, this is a new memory store. With `update_existing`, it is the input memory store.

### Beta Dream Model Config

- `class BetaDreamModelConfig`

  - `string id`

    The ID of the model that runs the dream, as given in the request that created it.

  - `?Speed speed`

    How fast the model generates output for the dream. Always `standard`.

### Beta Dream Model Config Param

- `class BetaDreamModelConfigParam`

  - `string id`

    The ID of the model to run the dream with.

    The ID can be 1 to 256 characters long.

    The [Availability section of the Dreams guide](https://platform.claude.com/docs/en/managed-agents/dreams?sdk_languages=php#feature-availability) lists the supported models.

  - `?Speed speed`

    How fast the model generates output for the dream. Defaults to `standard`.

    Dreams accept only `standard`.

### Beta Dream Output

- `class BetaDreamOutput`

  - `"memory_store" type`

  - `string memoryStoreID`

    The ID of the memory store that the dream writes its result to (`memstore_...`).

    With `output_behavior` set to `create_new`, this is a new memory store. With `update_existing`, it is the input memory store.

### Beta Dream Sessions Input

- `class BetaDreamSessionsInput`

  - `"sessions" type`

  - `list<string> sessionIDs`

    The IDs of the sessions whose transcripts the dream reads (`sesn_...`).

    Give 1 to 100 IDs, with no duplicates. Each session must be in the same workspace as the dream. Responses list the IDs in sorted order.

### Beta Dream Status

- `enum BetaDreamStatus`

  - `"pending"`

    The dream is waiting to start and hasn't read its inputs yet.

    `outputs` is empty and every `usage` count is zero.

  - `"running"`

    The dream is reading its inputs and writing its result.

    `usage` updates while the dream has this status.

  - `"completed"`

    The dream finished and its output memory store holds the complete result.

  - `"failed"`

    The dream stopped with an error, which `error` describes.

    If `outputs` references a memory store, that memory store keeps what the dream wrote before it stopped.

  - `"canceled"`

    A cancel request stopped the dream before it reached `completed` or `failed`.

    If `outputs` references a memory store, that memory store keeps what the dream wrote. `usage` can keep changing after the cancel.

### Beta Dream Usage

- `class BetaDreamUsage`

  - `int cacheCreationInputTokens`

    The dream's input tokens that were written to the prompt cache, for both the 5-minute and 1-hour cache durations.

  - `int cacheReadInputTokens`

    The dream's input tokens that were read from the prompt cache.

  - `int inputTokens`

    The dream's input tokens that weren't read from or written to the prompt cache.

  - `int outputTokens`

    The tokens that the model generated for the dream.

### Beta Dreaming Error

- `class BetaDreamingError`

  - `class BetaInvalidRequestError`

    - `"invalid_request_error" type`

    - `string message`

  - `class BetaAuthenticationError`

    - `"authentication_error" type`

    - `string message`

  - `class BetaBillingError`

    - `"billing_error" type`

    - `string message`

  - `class BetaPermissionError`

    - `"permission_error" type`

    - `string message`

  - `class BetaNotFoundError`

    - `"not_found_error" type`

    - `string message`

  - `class BetaRateLimitError`

    - `"rate_limit_error" type`

    - `string message`

  - `class BetaGatewayTimeoutError`

    - `"timeout_error" type`

    - `string message`

  - `class BetaAPIError`

    - `"api_error" type`

    - `string message`

  - `class BetaOverloadedError`

    - `"overloaded_error" type`

    - `string message`

  - `class BetaTargetStoreHeldError`

    - `"conflict_error" type`

    - `?string message`

      A human-readable explanation of why the memory store can't be used yet, with the ID of the dream that is using it when the server can identify it.

### Beta Output Behavior

- `class BetaOutputBehavior`

  - `class BetaOutputBehaviorCreateNew`

    - `"create_new" type`

  - `class BetaOutputBehaviorUpdateExisting`

    - `"update_existing" type`

    - `string memoryStoreID`

      The ID of the memory store for the dream to write its result to (`memstore_...`). It must be the memory store in the `memory_store` entry of `inputs`.

### Beta Output Behavior Create New

- `class BetaOutputBehaviorCreateNew`

  - `"create_new" type`

### Beta Output Behavior Update Existing

- `class BetaOutputBehaviorUpdateExisting`

  - `"update_existing" type`

  - `string memoryStoreID`

    The ID of the memory store for the dream to write its result to (`memstore_...`). It must be the memory store in the `memory_store` entry of `inputs`.

### Beta Target Store Held Error

- `class BetaTargetStoreHeldError`

  - `"conflict_error" type`

  - `?string message`

    A human-readable explanation of why the memory store can't be used yet, with the ID of the dream that is using it when the server can identify it.
