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

# POST /bootstrap

> Creates a project with tables, indexes, seed records, and optional Project API Tokens in one request.

Creates a project and loads its starting schema/data in one request.

Use this when your backend wants to spin up a new ZangTable project from a template instead of making separate calls for project creation, table creation, indexes, seed records, and token creation.

## Endpoint details

<ParamField header="Authorization" type="string" required>
  Bearer `pat_...` (Project API Token). The new project is created on the same ZangTable account as the Project API Token. Keep this token on your backend/server.
</ParamField>

<ResponseField name="ok" type="boolean" required>
  `true` for a successful response and `false` for an error response.
</ResponseField>

<ResponseField name="data" type="object | null">
  Endpoint-specific response data when `ok` is `true`; `null` on errors.
</ResponseField>

<ResponseField name="error" type="object | null">
  Error code and message when `ok` is `false`; `null` on success.
</ResponseField>

<ResponseField name="request_id" type="string" required>
  Request identifier you can use when troubleshooting a specific API call.
</ResponseField>

## Authentication

Project API Token.

## Parameters

Body fields:

* `project_slug` (string, required): New project slug. Use lowercase letters, numbers, hyphens, or underscores.
* `project_name` (string, required): Human-readable project name.
* `initial_project_user` (object, required): Initial project user with `username` and `password`.
* `tables` (array, optional): Tables to create. Each table may include `table_name`, `display_name`, `columns`, `seed`, and table-level `indexes`.
* `indexes` (array, optional): Additional project-level indexes. Each index includes `table_name`, `columns`, optional `index_name`, and optional `unique`.
* `project_api_tokens` (array, optional): Project API Tokens to mint for the new project. Each item includes `account_user_id`, optional `token_name`, and optional `project_username`.

Column fields:

* `column_name` or `name` (string, required)
* `column_type` or `type` (string, optional): `INTEGER`, `REAL`, `TEXT`, `BLOB`, or `ANY`. Defaults to `TEXT`.
* `is_primary` or `primary` (boolean, optional)
* `is_unique` or `unique` (boolean, optional)
* `is_nullable` or `nullable` (boolean, optional)
* `default_value` or `default` (scalar or null, optional)

## Notes

* The request creates one project on the same account as the Project API Token you use.
* `project_slug` must be unique and cannot already have project storage.
* Account plan project limits still apply.
* Seed values must be scalar values or `null`.
* Seed records may only reference columns declared for their table.
* `project_api_tokens.account_user_id` must be an active user on the same ZangTable account.
* The bootstrap endpoint currently creates tokens only for the `initial_project_user`.
* Raw Project API Tokens are only returned in the creation response. Store them securely.

## Request examples

Basic request:

```bash theme={null}
curl -X POST "$BASE_URL/bootstrap" \
  -H 'Authorization: Bearer pat_PROJECT_TOKEN' \
  -H 'Content-Type: application/json' \
  --data '{"project_slug":"customer_portal","project_name":"Customer Portal","initial_project_user":{"username":"server","password":"replace-with-a-long-password"}}'
```

Full request:

```bash theme={null}
curl -X POST "$BASE_URL/bootstrap" \
  -H 'Authorization: Bearer pat_PROJECT_TOKEN' \
  -H 'Content-Type: application/json' \
  -H 'X-Operation-Key: bootstrap-customer-portal' \
  -H 'X-Operation-Run-Id: oprun_client_20260617_001' \
  --data '{
    "project_slug": "customer_portal",
    "project_name": "Customer Portal",
    "initial_project_user": {
      "username": "server",
      "password": "replace-with-a-long-password"
    },
    "tables": [
      {
        "table_name": "customers",
        "display_name": "Customers",
        "columns": [
          {"column_name": "id", "column_type": "INTEGER", "is_primary": true, "is_nullable": false},
          {"column_name": "email", "column_type": "TEXT", "is_nullable": false, "is_unique": true},
          {"column_name": "name", "column_type": "TEXT"},
          {"column_name": "created_at", "column_type": "TEXT"}
        ],
        "seed": [
          {"email": "hello@example.com", "name": "Example Customer", "created_at": "2026-06-17T04:00:00Z"}
        ],
        "indexes": [
          {"columns": ["created_at"]}
        ]
      }
    ],
    "project_api_tokens": [
      {
        "account_user_id": 123,
        "token_name": "customer-portal-server"
      }
    ]
  }'
```

## Response examples

Success:

```json theme={null}
{
  "ok": true,
  "data": {
    "project": {
      "id": 1,
      "project_slug": "customer_portal",
      "project_name": "Customer Portal",
      "created_at": "2026-06-17T04:00:00Z",
      "updated_at": "2026-06-17T04:00:00Z"
    },
    "registry": {
      "id": 44,
      "account_id": 12,
      "project_slug": "customer_portal",
      "project_name": "Customer Portal",
      "status": "active",
      "created_at": "2026-06-17T04:00:00Z",
      "updated_at": "2026-06-17T04:00:00Z"
    },
    "initial_project_user": {
      "id": 1,
      "username": "server",
      "is_owner": 1,
      "is_active": 1,
      "created_at": "2026-06-17T04:00:00Z",
      "updated_at": "2026-06-17T04:00:00Z",
      "last_login_at": null
    },
    "created": {
      "tables": 1,
      "seed_records": 1,
      "indexes": 1,
      "project_api_tokens": 1
    },
    "project_api_tokens": [
      {
        "token": "pat_NEW_PROJECT_TOKEN",
        "token_id": 1,
        "token_type": "project_api_token",
        "token_name": "customer-portal-server",
        "account_user_id": 123,
        "project_user_id": 1,
        "project_username": "server",
        "expires_at": null
      }
    ]
  },
  "error": null,
  "request_id": "req_20260617T040000_123456Z_abc123def456",
  "operation_key": "bootstrap-customer-portal",
  "operation_run_id": "oprun_client_20260617_001",
  "operation_grouping_status": "accepted_provided_run",
  "meta": {
    "generated_at": "2026-06-17T04:00:01Z"
  }
}
```

Error or alternate response:

```json theme={null}
{
  "ok": false,
  "data": null,
  "error": {
    "code": "project_exists",
    "message": "A project with that slug already exists."
  },
  "request_id": "req_20260617T040000_123456Z_abc123def456",
  "meta": {
    "generated_at": "2026-06-17T04:00:01Z"
  }
}
```
