> ## 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.

# Create Stack

> Create a new stack in your ToolRouter account

## Overview

Creates a new stack with the specified name and configuration. A stack is a collection of servers and tools that work together for your specific use case.

## Endpoint

```
POST https://api.toolrouter.ai/v1/stacks
```

## Authentication

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

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

## Request Body

<ParamField body="stack_name" type="string" required>
  Name of the new stack. Must be unique within your account.
</ParamField>

<ParamField body="configuration" type="object">
  Stack configuration settings

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

## Response

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

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

<ResponseField name="configuration" type="object">
  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 (empty for newly created stacks)
</ResponseField>

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

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

## Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.toolrouter.ai/v1/stacks" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "stack_name": "My New Stack",
      "configuration": {
        "analytics_enabled": true
      }
    }'
  ```

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

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

  data = {
      "stack_name": "My New Stack",
      "configuration": {
          "analytics_enabled": True
      }
  }

  response = requests.post(
      "https://api.toolrouter.ai/v1/stacks",
      headers=headers,
      json=data
  )

  stack = response.json()
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.toolrouter.ai/v1/stacks', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      stack_name: "My New Stack",
      configuration: {
        analytics_enabled: true
      }
    })
  });

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

## Example Response

```json theme={null}
{
  "stack_id": "stack_456a7890-b12c-34d5-e678-426614174002",
  "stack_name": "My New Stack",
  "configuration": {
    "analytics_enabled": true
  },
  "servers": [],
  "created_at": "2024-01-25T12:30:00Z",
  "updated_at": "2024-01-25T12:30:00Z"
}
```

## Minimal Request Example

You can create a stack with just a name, and default configuration will be applied:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.toolrouter.ai/v1/stacks" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "stack_name": "Simple Stack"
    }'
  ```

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

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

  data = {
      "stack_name": "Simple Stack"
  }

  response = requests.post(
      "https://api.toolrouter.ai/v1/stacks",
      headers=headers,
      json=data
  )

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

## Error Responses

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

  ```json theme={null}
  {
    "detail": "Stack name is required"
  }
  ```
</ResponseField>

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

  ```json theme={null}
  {
    "detail": "Unauthorized"
  }
  ```
</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 create stack"
  }
  ```
</ResponseField>
