---
title: "Create a new memory layer"
method: POST
path: "/v1/workspaces/{workspaceId}/memory_layers"
tags: ["MemoryService", "Memory Layers"]
---

# Create a new memory layer

`POST /v1/workspaces/{workspaceId}/memory_layers`

Creates a new memory layer in the workspace

## Path parameters

- `workspaceId` string, required

## Request body

- CreateMemoryLayerRequest
  - `workspaceId` string
  - `metadata` CreateResourceMetadata, required — CreateResourceMetadata contains the user-provided fields for creating a workspace-scoped resource. Read-only fields (id, account_id, workspace_id, profile_id, created_at) are excluded since they are set by the server.
    - `name` string, required — Human-readable name for the resource (e.g., "Customer Support Agent", "Email Tool")
    - `externalId` string — External ID for the resource (e.g., a workflow ID from an external system)
    - `labels` object — Key-value pairs for categorization and filtering. Values are 0-63 alphanumeric characters with "-", "_", or "." allowed between; keys follow the same shape and additionally accept an optional DNS-subdomain prefix (e.g. "cadenya.com/") of at most 253 characters. Examples: {"environment": "production", "team": "platform", "version": "v2"}
  - `spec` MemoryLayerSpec, required
    - `type` 'MEMORY_LAYER_TYPE_UNSPECIFIED' | 'MEMORY_LAYER_TYPE_EPISODIC' | 'MEMORY_LAYER_TYPE_SKILLS', enum, required
    - `description` string — Human-readable description of the layer's purpose. Encouraged for user-created layers; system-managed layers may have a generated description.
    - `systemManaged` boolean — Server-set. True for layers managed by the system (e.g., episodic layers created automatically when an objective uses an episodic_key). System-managed layers cannot be assigned to objective cascades via the API and cannot be mutated by clients — their lifecycle is controlled entirely by the runtime.
    - `expiresAt` string, date-time — For layers with a finite lifetime (e.g., episodic), the time at which the layer becomes eligible for cleanup. Set by the system; unset for persistent layers.
    - `agentId` string — Server-set on episodic layers: the agent this layer belongs to. Unset for non-episodic layers.
    - `episodicKey` string — Server-set on episodic layers: the caller-supplied episodic key the layer was created for. Unset for non-episodic layers.

## Response `200`

OK

- MemoryLayer — MemoryLayer is a named container of memory entries that can be composed into an objective's memory cascade. Layers are workspace-scoped resources. The layer type controls how its entries participate in the agent loop — see MemoryLayerType for details. See "Memory cascade composition" above for how layers compose at lookup time.
  - `metadata` ResourceMetadata, required — Standard metadata for persistent, named resources (e.g., agents, tools, prompts)
    - `id` string, required — Unique identifier for the resource (prefixed ULID, e.g., "agent_01HXK...")
    - `accountId` string, required — Account this resource belongs to for multi-tenant isolation (prefixed ULID)
    - `workspaceId` string, required — Workspace this resource belongs to for organizational grouping (prefixed ULID)
    - `name` string, required — Human-readable name for the resource (e.g., "Customer Support Agent", "Email Tool") Required for resources that users interact with directly
    - `externalId` string — External ID for the resource (e.g., a workflow ID from an external system)
    - `labels` object — Key-value pairs for categorization and filtering. Values are 0-63 alphanumeric characters with "-", "_", or "." allowed between; keys follow the same shape and additionally accept an optional DNS-subdomain prefix (e.g. "cadenya.com/") of at most 253 characters. Examples: {"environment": "production", "team": "platform", "version": "v2"}
    - `profileId` string, required — ID of the actor (user or service account) that created this resource
    - `createdAt` string, date-time, required — Timestamp when this resource was created
    - `updatedAt` string, date-time — Timestamp when this resource was last updated
  - `spec` MemoryLayerSpec, required
    - `type` 'MEMORY_LAYER_TYPE_UNSPECIFIED' | 'MEMORY_LAYER_TYPE_EPISODIC' | 'MEMORY_LAYER_TYPE_SKILLS', enum, required
    - `description` string — Human-readable description of the layer's purpose. Encouraged for user-created layers; system-managed layers may have a generated description.
    - `systemManaged` boolean — Server-set. True for layers managed by the system (e.g., episodic layers created automatically when an objective uses an episodic_key). System-managed layers cannot be assigned to objective cascades via the API and cannot be mutated by clients — their lifecycle is controlled entirely by the runtime.
    - `expiresAt` string, date-time — For layers with a finite lifetime (e.g., episodic), the time at which the layer becomes eligible for cleanup. Set by the system; unset for persistent layers.
    - `agentId` string — Server-set on episodic layers: the agent this layer belongs to. Unset for non-episodic layers.
    - `episodicKey` string — Server-set on episodic layers: the caller-supplied episodic key the layer was created for. Unset for non-episodic layers.
  - `info` MemoryLayerInfo
    - `entryCount` integer — Number of entries currently in this layer.
    - `createdBy` Profile — A profile identifies a user or non-human principal (such as an API key) at the account level. Profiles are account-scoped and can be granted access to multiple workspaces.
      - `metadata` AccountResourceMetadata, required — AccountResourceMetadata is used to represent a resource that is associated to an account but not to a workspace.
        - `id` string, required — Unique identifier for the resource (prefixed ULID, e.g., "apikey_01HXK...")
        - `accountId` string, required — Account this resource belongs to for multi-tenant isolation (prefixed ULID)
        - `name` string, required — Human-readable name for the resource (e.g., "Customer Support Agent", "Email Tool") Required for resources that users interact with directly
        - `externalId` string — External ID for the resource (e.g., a workflow ID from an external system)
        - `labels` object — Key-value pairs for categorization and filtering. Values are 0-63 alphanumeric characters with "-", "_", or "." allowed between; keys follow the same shape and additionally accept an optional DNS-subdomain prefix (e.g. "cadenya.com/") of at most 253 characters. Examples: {"environment": "production", "team": "platform", "version": "v2"}
        - `profileId` string, required
        - `createdAt` string, date-time
      - `spec` ProfileSpec, required — Configuration for a profile.
        - `email` string — Email address of the profile. Required and unique within an account for user profiles.
        - `name` string — Display name (e.g., "Bobby Tables").
        - `type` 'PROFILE_TYPE_UNSPECIFIED' | 'PROFILE_TYPE_USER' | 'PROFILE_TYPE_API_KEY' | 'PROFILE_TYPE_SYSTEM', enum, required — Whether this profile represents a human user, an API key, or a system principal.
    - `lastUsedAt` string, date-time — Timestamp of the most recent objective that resolved against this layer. Useful for surfacing unused layers in the dashboard.
    - `agent` ResourceMetadata — Standard metadata for persistent, named resources (e.g., agents, tools, prompts)
      - `id` string, required — Unique identifier for the resource (prefixed ULID, e.g., "agent_01HXK...")
      - `accountId` string, required — Account this resource belongs to for multi-tenant isolation (prefixed ULID)
      - `workspaceId` string, required — Workspace this resource belongs to for organizational grouping (prefixed ULID)
      - `name` string, required — Human-readable name for the resource (e.g., "Customer Support Agent", "Email Tool") Required for resources that users interact with directly
      - `externalId` string — External ID for the resource (e.g., a workflow ID from an external system)
      - `labels` object — Key-value pairs for categorization and filtering. Values are 0-63 alphanumeric characters with "-", "_", or "." allowed between; keys follow the same shape and additionally accept an optional DNS-subdomain prefix (e.g. "cadenya.com/") of at most 253 characters. Examples: {"environment": "production", "team": "platform", "version": "v2"}
      - `profileId` string, required — ID of the actor (user or service account) that created this resource
      - `createdAt` string, date-time, required — Timestamp when this resource was created
      - `updatedAt` string, date-time — Timestamp when this resource was last updated

## Other responses

- `default` — Default error response

## Changes

- **2026-07-02** `06e0e37c1499` — 3 warning, 1 info
  - removed the request property `metadata/bundleKey`
  - removed the optional property `info/agent/allOf[#/components/schemas/ResourceMetadata]/bundleKey` from the response with the `200` status
  - removed the optional property `metadata/bundleKey` from the response with the `200` status
  - added the optional property `info/createdBy/metadata/createdAt` to the response with the `200` status
- **2026-06-11** `6ef1884395e2` — 1 info
  - added the optional property `info/agent` to the response with the `200` status
- **2026-06-11** `08fde3ae3e37` — 2 info
  - added the optional property `spec/agentId` to the response with the `200` status
  - added the optional property `spec/episodicKey` to the response with the `200` status
- **2026-06-09** `13d98d37dd96` — 1 info
  - added the optional property `metadata/updatedAt` to the response with the `200` status
- **2026-06-05** `0702cb021b66` — 1 warning
  - added the new `PROFILE_TYPE_UNSPECIFIED` enum value to the `info/createdBy/spec/type` response property for the response status `200`

[Change history](https://skmtc.dev/cadenya/apis/cadenya-api/changes/v1/workspaces/:workspaceId/memory_layers/post.md)

---

[API](https://skmtc.dev/cadenya/apis/cadenya-api.md) · [All operations](https://skmtc.dev/cadenya/apis/cadenya-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/cadenya/cadenya-api/revisions/ac1a7f084068/schema)
