> ## Documentation Index
> Fetch the complete documentation index at: https://docs.toolrouter.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Stack

> Modify an existing stack in your ToolRouter account

## Overview

Updates the properties of an existing stack. You can modify the stack name and/or configuration. This endpoint supports partial updates - you only need to include the fields you want to change.

## Endpoint

```
PUT https://api.toolrouter.ai/v1/stacks/{stack_id}
```

## Authentication

This endpoint requires an API key. Include it in the Authorization header:

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

## Path Parameters

<ParamField path="stack_id" type="string" required>
  The unique identifier of the stack to update
</ParamField>

## Request Body

<ParamField body="stack_name" type="string">
  New name for the stack (optional)
</ParamField>

<ParamField body="configuration" type="object">
  Stack configuration settings to update (optional)

  <Expandable title="Configuration Object">
    <ParamField body="analytics_enabled" type="boolean">
      Whether to enable analytics for this stack
    </ParamField>
  </Expandable>
</ParamField>

<Note>
  All request body fields are optional. Include only the fields you want to update.
</Note>

## Response

<ResponseField name="stack_id" type="string">
  Unique identifier for the updated stack
</ResponseField>

<ResponseField name="stack_name" type="string">
  Name of the updated stack
</ResponseField>

<ResponseField name="configuration" type="object">
  Updated stack configuration settings

  <Expandable title="Configuration Object">
    <ResponseField name="analytics_enabled" type="boolean">
      Whether analytics are enabled for this stack
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="servers" type="array">
  Array of servers (not populated in update response)
</ResponseField>

<ResponseField name="created_at" type="string">
  ISO timestamp when the stack was originally created
</ResponseField>

<ResponseField name="updated_at" type="string">
  ISO timestamp when the stack was last updated
</ResponseField>

## Example Request

### Update Stack Name

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT "https://api.toolrouter.ai/v1/stacks/stack_123e4567-e89b-12d3-a456-426614174000" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "stack_name": "Updated Stack Name"
    }'
  ```

  ```python Python theme={null}
  import requests

  headers = {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json"
  }

  data = {
      "stack_name": "Updated Stack Name"
  }

  response = requests.put(
      "https://api.toolrouter.ai/v1/stacks/stack_123e4567-e89b-12d3-a456-426614174000",
      headers=headers,
      json=data
  )

  stack = response.json()
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.toolrouter.ai/v1/stacks/stack_123e4567-e89b-12d3-a456-426614174000', {
    method: 'PUT',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      stack_name: "Updated Stack Name"
    })
  });

  const stack = await response.json();
  ```
</CodeGroup>

### Update Configuration Only

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT "https://api.toolrouter.ai/v1/stacks/stack_123e4567-e89b-12d3-a456-426614174000" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "configuration": {
        "analytics_enabled": false
      }
    }'
  ```

  ```python Python theme={null}
  import requests

  headers = {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json"
  }

  data = {
      "configuration": {
          "analytics_enabled": False
      }
  }

  response = requests.put(
      "https://api.toolrouter.ai/v1/stacks/stack_123e4567-e89b-12d3-a456-426614174000",
      headers=headers,
      json=data
  )

  stack = response.json()
  ```
</CodeGroup>

### Update Both Name and Configuration

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT "https://api.toolrouter.ai/v1/stacks/stack_123e4567-e89b-12d3-a456-426614174000" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "stack_name": "Production Environment",
      "configuration": {
        "analytics_enabled": true
      }
    }'
  ```

  ```python Python theme={null}
  import requests

  headers = {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json"
  }

  data = {
      "stack_name": "Production Environment",
      "configuration": {
          "analytics_enabled": True
      }
  }

  response = requests.put(
      "https://api.toolrouter.ai/v1/stacks/stack_123e4567-e89b-12d3-a456-426614174000",
      headers=headers,
      json=data
  )

  stack = response.json()
  ```
</CodeGroup>

## Example Response

```json theme={null}
{
  "stack_id": "stack_123e4567-e89b-12d3-a456-426614174000",
  "stack_name": "Production Environment",
  "configuration": {
    "analytics_enabled": true
  },
  "servers": [],
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-01-25T15:45:00Z"
}
```

## Error Responses

<ResponseField name="400 Bad Request">
  Invalid request data

  ```json theme={null}
  {
    "detail": "Invalid configuration parameters"
  }
  ```
</ResponseField>

<ResponseField name="401 Unauthorized">
  Invalid or missing API key

  ```json theme={null}
  {
    "detail": "Unauthorized"
  }
  ```
</ResponseField>

<ResponseField name="404 Not Found">
  Stack not found

  ```json theme={null}
  {
    "detail": "Stack not found"
  }
  ```
</ResponseField>

<ResponseField name="429 Too Many Requests">
  Rate limit exceeded

  ```json theme={null}
  {
    "detail": "Too many requests"
  }
  ```
</ResponseField>

<ResponseField name="500 Internal Server Error">
  Server error occurred

  ```json theme={null}
  {
    "detail": "Failed to update stack"
  }
  ```
</ResponseField>
