# Add Column

`POST /api/v1/tables/{tableId}/columns`

## Description
Add a new column to the table schema. Optionally specify a position to insert the column at a specific index.

## Parameters

- **tableId** (path) (required) — `string`: The unique identifier of the table.

## Request Body

```json
{
  "type": "object",
  "required": [
    "workspaceId",
    "column"
  ],
  "properties": {
    "workspaceId": {
      "type": "string",
      "description": "The workspace ID"
    },
    "column": {
      "type": "object",
      "required": [
        "name",
        "type"
      ],
      "properties": {
        "name": {
          "type": "string",
          "description": "Column name (alphanumeric and underscores, must start with letter or underscore)"
        },
        "type": {
          "type": "string",
          "enum": [
            "string",
            "number",
            "boolean",
            "date",
            "json"
          ],
          "description": "Column data type"
        },
        "required": {
          "type": "boolean",
          "description": "Whether the column requires a value"
        },
        "unique": {
          "type": "boolean",
          "description": "Whether column values must be unique"
        },
        "position": {
          "type": "integer",
          "minimum": 0,
          "description": "Position index to insert the column at (0-based). Appends if omitted."
        }
      }
    }
  }
}
```

## Responses

### 200 — Column added successfully

```json
{
  "type": "object",
  "properties": {
    "success": {
      "type": "boolean"
    },
    "data": {
      "type": "object",
      "properties": {
        "columns": {
          "type": "array",
          "items": {
            "type": "object",
            "description": "Definition of a table column including its type and constraints.",
            "required": [
              "name",
              "type"
            ],
            "properties": {
              "name": {
                "type": "string",
                "description": "Column name. Must start with a letter or underscore.",
                "example": "email",
                "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$"
              },
              "type": {
                "type": "string",
                "enum": [
                  "string",
                  "number",
                  "boolean",
                  "date",
                  "json"
                ],
                "description": "Data type of the column."
              },
              "required": {
                "type": "boolean",
                "description": "Whether the column requires a value on insert.",
                "default": false
              },
              "unique": {
                "type": "boolean",
                "description": "Whether values in this column must be unique across all rows.",
                "default": false
              }
            }
          }
        }
      }
    }
  }
}
```

### 400 — Invalid request parameters. Check the details array for specific validation errors.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message describing the validation failure."
    },
    "details": {
      "type": "array",
      "description": "List of specific validation errors with field-level details.",
      "items": {
        "type": "object"
      }
    }
  }
}
```

### 401 — Invalid or missing API key. Ensure the X-API-Key header is set with a valid key.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    }
  }
}
```

### 404 — The requested resource was not found. Verify the ID is correct and belongs to your workspace.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    }
  }
}
```

### 429 — Rate limit exceeded. Wait for the duration specified in the Retry-After header before retrying.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message with rate limit details."
    }
  }
}
```
