# Stacks

## Create a stack

**post** `/api/v1/stacks`

Creates a stack: a model with tools and defaults you call by its `model_id` through POST /responses. It is active unless created `inactive`.

### Body Parameters

- `name: optional string`

  Display name. The stack is called through `model_id`, which is derived from the name, so renaming a stack changes its `model_id`. Defaults to the model name and a number.

- `model: string`

  The model the stack serves: a hosted model `id` from `GET /models?type=hosted`.

- `tools: optional array of string`

  Tools the stack runs on each request, by `server_label` from `GET /tools`, plus `web_search` and `code_execution`. Omitted: `web_search` and `code_execution`, the ones you can run now. Send `[]` for none.

- `agentic_memory: optional boolean`

  Whether requests to the stack use agentic memory unless they set it themselves. Teams with zero data retention cannot turn it on.

- `self_improvement: optional boolean`

  Whether requests to the stack use self-improvement unless they set it themselves.

- `status: optional "active" or "inactive"`

  Create the stack `inactive` to turn it on later.

  - `"active"`

  - `"inactive"`

- `idempotency_key: optional string`

  A key you choose for this create. Sending the same key again returns the stack it created instead of making a second one.

### Returns

- `Stack object { id, object, name, 8 more }`

  - `id: string`

  - `object: "stack"`

    - `"stack"`

  - `name: string`

    Display name. The stack is called through `model_id`, which is derived from the name, so renaming a stack changes its `model_id`.

  - `model_id: string`

    What to pass as `model` to POST /responses to call the stack. Use it as is.

  - `status: "draft" or "active" or "inactive"`

    `active` serves requests, `inactive` keeps its configuration but refuses them. `draft` is a stack started in the dashboard whose configuration is not finished.

    - `"draft"`

    - `"active"`

    - `"inactive"`

  - `model: string`

    The model the stack serves. Null only for a draft without one yet.

  - `tools: array of StackTool`

    - `server_label: string`

    - `status: "enabled" or "needs_connection" or "unavailable"`

      `enabled` runs on requests to the stack. `needs_connection` waits for you to connect the account the tool acts as. `unavailable` is not available to you, e.g. not on your plan.

      - `"enabled"`

      - `"needs_connection"`

      - `"unavailable"`

  - `agentic_memory: boolean`

    Whether requests to the stack use agentic memory unless they set it themselves. Teams with zero data retention cannot turn it on.

  - `self_improvement: boolean`

    Whether requests to the stack use self-improvement unless they set it themselves.

  - `created_at: string`

  - `updated_at: string`

### Example

```http
curl https://api.prod.adaptionlabs.ai/api/v1/stacks \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $ADAPTION_API_KEY" \
    -d '{
          "model": "glm-5.2",
          "tools": [
            "slack"
          ]
        }'
```

#### Response

```json
{
  "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "object": "stack",
  "name": "Support bot",
  "model_id": "stack/support-bot",
  "status": "draft",
  "model": "glm-5.2",
  "tools": [
    {
      "server_label": "slack",
      "status": "enabled"
    }
  ],
  "agentic_memory": true,
  "self_improvement": true,
  "created_at": "2019-12-27T18:11:19.117Z",
  "updated_at": "2019-12-27T18:11:19.117Z"
}
```

## List stacks

**get** `/api/v1/stacks`

Lists your stacks, newest first.

### Query Parameters

- `limit: optional number`

- `after: optional string`

  The `last_id` of the previous page. Stacks are listed newest first.

- `status: optional "draft" or "active" or "inactive"`

  - `"draft"`

  - `"active"`

  - `"inactive"`

### Returns

- `object: "list"`

  - `"list"`

- `data: array of Stack`

  - `id: string`

  - `object: "stack"`

    - `"stack"`

  - `name: string`

    Display name. The stack is called through `model_id`, which is derived from the name, so renaming a stack changes its `model_id`.

  - `model_id: string`

    What to pass as `model` to POST /responses to call the stack. Use it as is.

  - `status: "draft" or "active" or "inactive"`

    `active` serves requests, `inactive` keeps its configuration but refuses them. `draft` is a stack started in the dashboard whose configuration is not finished.

    - `"draft"`

    - `"active"`

    - `"inactive"`

  - `model: string`

    The model the stack serves. Null only for a draft without one yet.

  - `tools: array of StackTool`

    - `server_label: string`

    - `status: "enabled" or "needs_connection" or "unavailable"`

      `enabled` runs on requests to the stack. `needs_connection` waits for you to connect the account the tool acts as. `unavailable` is not available to you, e.g. not on your plan.

      - `"enabled"`

      - `"needs_connection"`

      - `"unavailable"`

  - `agentic_memory: boolean`

    Whether requests to the stack use agentic memory unless they set it themselves. Teams with zero data retention cannot turn it on.

  - `self_improvement: boolean`

    Whether requests to the stack use self-improvement unless they set it themselves.

  - `created_at: string`

  - `updated_at: string`

- `first_id: string`

- `last_id: string`

  Pass as `after` to read the next page.

- `has_more: boolean`

### Example

```http
curl https://api.prod.adaptionlabs.ai/api/v1/stacks \
    -H "Authorization: Bearer $ADAPTION_API_KEY"
```

#### Response

```json
{
  "object": "list",
  "data": [
    {
      "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "object": "stack",
      "name": "Support bot",
      "model_id": "stack/support-bot",
      "status": "draft",
      "model": "glm-5.2",
      "tools": [
        {
          "server_label": "slack",
          "status": "enabled"
        }
      ],
      "agentic_memory": true,
      "self_improvement": true,
      "created_at": "2019-12-27T18:11:19.117Z",
      "updated_at": "2019-12-27T18:11:19.117Z"
    }
  ],
  "first_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "last_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "has_more": true
}
```

## Retrieve a stack

**get** `/api/v1/stacks/{stack_id}`

Retrieve a stack

### Path Parameters

- `stack_id: string`

### Returns

- `Stack object { id, object, name, 8 more }`

  - `id: string`

  - `object: "stack"`

    - `"stack"`

  - `name: string`

    Display name. The stack is called through `model_id`, which is derived from the name, so renaming a stack changes its `model_id`.

  - `model_id: string`

    What to pass as `model` to POST /responses to call the stack. Use it as is.

  - `status: "draft" or "active" or "inactive"`

    `active` serves requests, `inactive` keeps its configuration but refuses them. `draft` is a stack started in the dashboard whose configuration is not finished.

    - `"draft"`

    - `"active"`

    - `"inactive"`

  - `model: string`

    The model the stack serves. Null only for a draft without one yet.

  - `tools: array of StackTool`

    - `server_label: string`

    - `status: "enabled" or "needs_connection" or "unavailable"`

      `enabled` runs on requests to the stack. `needs_connection` waits for you to connect the account the tool acts as. `unavailable` is not available to you, e.g. not on your plan.

      - `"enabled"`

      - `"needs_connection"`

      - `"unavailable"`

  - `agentic_memory: boolean`

    Whether requests to the stack use agentic memory unless they set it themselves. Teams with zero data retention cannot turn it on.

  - `self_improvement: boolean`

    Whether requests to the stack use self-improvement unless they set it themselves.

  - `created_at: string`

  - `updated_at: string`

### Example

```http
curl https://api.prod.adaptionlabs.ai/api/v1/stacks/$STACK_ID \
    -H "Authorization: Bearer $ADAPTION_API_KEY"
```

#### Response

```json
{
  "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "object": "stack",
  "name": "Support bot",
  "model_id": "stack/support-bot",
  "status": "draft",
  "model": "glm-5.2",
  "tools": [
    {
      "server_label": "slack",
      "status": "enabled"
    }
  ],
  "agentic_memory": true,
  "self_improvement": true,
  "created_at": "2019-12-27T18:11:19.117Z",
  "updated_at": "2019-12-27T18:11:19.117Z"
}
```

## Update a stack

**patch** `/api/v1/stacks/{stack_id}`

Changes the fields you send and leaves the rest as they are. Renaming a stack changes its `model_id`.

### Path Parameters

- `stack_id: string`

### Body Parameters

- `name: optional string`

  Display name. The stack is called through `model_id`, which is derived from the name, so renaming a stack changes its `model_id`.

- `model: optional string`

  The model the stack serves: a hosted model `id` from `GET /models?type=hosted`.

- `tools: optional array of string`

  Tools the stack runs on each request, by `server_label` from `GET /tools`, plus `web_search` and `code_execution`. Replaces the whole selection; send `[]` for none.

- `agentic_memory: optional boolean`

  Whether requests to the stack use agentic memory unless they set it themselves. Teams with zero data retention cannot turn it on.

- `self_improvement: optional boolean`

  Whether requests to the stack use self-improvement unless they set it themselves.

- `status: optional "active" or "inactive"`

  `active` puts the stack in service, `inactive` takes it out. A draft needs a model before it can be active, and stays a draft when turned off.

  - `"active"`

  - `"inactive"`

### Returns

- `Stack object { id, object, name, 8 more }`

  - `id: string`

  - `object: "stack"`

    - `"stack"`

  - `name: string`

    Display name. The stack is called through `model_id`, which is derived from the name, so renaming a stack changes its `model_id`.

  - `model_id: string`

    What to pass as `model` to POST /responses to call the stack. Use it as is.

  - `status: "draft" or "active" or "inactive"`

    `active` serves requests, `inactive` keeps its configuration but refuses them. `draft` is a stack started in the dashboard whose configuration is not finished.

    - `"draft"`

    - `"active"`

    - `"inactive"`

  - `model: string`

    The model the stack serves. Null only for a draft without one yet.

  - `tools: array of StackTool`

    - `server_label: string`

    - `status: "enabled" or "needs_connection" or "unavailable"`

      `enabled` runs on requests to the stack. `needs_connection` waits for you to connect the account the tool acts as. `unavailable` is not available to you, e.g. not on your plan.

      - `"enabled"`

      - `"needs_connection"`

      - `"unavailable"`

  - `agentic_memory: boolean`

    Whether requests to the stack use agentic memory unless they set it themselves. Teams with zero data retention cannot turn it on.

  - `self_improvement: boolean`

    Whether requests to the stack use self-improvement unless they set it themselves.

  - `created_at: string`

  - `updated_at: string`

### Example

```http
curl https://api.prod.adaptionlabs.ai/api/v1/stacks/$STACK_ID \
    -X PATCH \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $ADAPTION_API_KEY" \
    -d '{}'
```

#### Response

```json
{
  "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "object": "stack",
  "name": "Support bot",
  "model_id": "stack/support-bot",
  "status": "draft",
  "model": "glm-5.2",
  "tools": [
    {
      "server_label": "slack",
      "status": "enabled"
    }
  ],
  "agentic_memory": true,
  "self_improvement": true,
  "created_at": "2019-12-27T18:11:19.117Z",
  "updated_at": "2019-12-27T18:11:19.117Z"
}
```

## Delete a stack

**delete** `/api/v1/stacks/{stack_id}`

Deletes the stack for good; requests naming its `model_id` fail afterwards. To stop it serving and keep it, update its `status` to `inactive`.

### Path Parameters

- `stack_id: string`

### Returns

- `id: string`

- `object: "stack.deleted"`

  - `"stack.deleted"`

- `deleted: boolean`

  Always `true`.

### Example

```http
curl https://api.prod.adaptionlabs.ai/api/v1/stacks/$STACK_ID \
    -X DELETE \
    -H "Authorization: Bearer $ADAPTION_API_KEY"
```

#### Response

```json
{
  "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "object": "stack.deleted",
  "deleted": true
}
```

## Domain Types

### Stack

- `Stack object { id, object, name, 8 more }`

  - `id: string`

  - `object: "stack"`

    - `"stack"`

  - `name: string`

    Display name. The stack is called through `model_id`, which is derived from the name, so renaming a stack changes its `model_id`.

  - `model_id: string`

    What to pass as `model` to POST /responses to call the stack. Use it as is.

  - `status: "draft" or "active" or "inactive"`

    `active` serves requests, `inactive` keeps its configuration but refuses them. `draft` is a stack started in the dashboard whose configuration is not finished.

    - `"draft"`

    - `"active"`

    - `"inactive"`

  - `model: string`

    The model the stack serves. Null only for a draft without one yet.

  - `tools: array of StackTool`

    - `server_label: string`

    - `status: "enabled" or "needs_connection" or "unavailable"`

      `enabled` runs on requests to the stack. `needs_connection` waits for you to connect the account the tool acts as. `unavailable` is not available to you, e.g. not on your plan.

      - `"enabled"`

      - `"needs_connection"`

      - `"unavailable"`

  - `agentic_memory: boolean`

    Whether requests to the stack use agentic memory unless they set it themselves. Teams with zero data retention cannot turn it on.

  - `self_improvement: boolean`

    Whether requests to the stack use self-improvement unless they set it themselves.

  - `created_at: string`

  - `updated_at: string`

### Stack Tool

- `StackTool object { server_label, status }`

  - `server_label: string`

  - `status: "enabled" or "needs_connection" or "unavailable"`

    `enabled` runs on requests to the stack. `needs_connection` waits for you to connect the account the tool acts as. `unavailable` is not available to you, e.g. not on your plan.

    - `"enabled"`

    - `"needs_connection"`

    - `"unavailable"`

### Stack Delete Response

- `StackDeleteResponse object { id, object, deleted }`

  - `id: string`

  - `object: "stack.deleted"`

    - `"stack.deleted"`

  - `deleted: boolean`

    Always `true`.
