---
title: "Create And Bind"
method: POST
path: "/datamate-project-bindings/"
tags: ["DatamateProjectBindings"]
---

# Create And Bind

`POST /datamate-project-bindings/`

Atomically create a new workspace and bind this project to it.

Single handler-owned transaction: the Datamate row and the binding row
either both commit or both roll back. A partial-unique-index conflict on
the binding (the identifier is already bound to another workspace for
this tenant) 409s with the winning workspace's ``{id, name}`` so the
CLI can prompt "re-link?" — no orphan Datamate is left behind.

``cache.clear()`` fires post-commit so the caller's ``GET /datamates/``
sees the new workspace within one request instead of waiting up to five
minutes for the TTL cache to expire.

## Request body

- CreateAndBindRequest — Body for POST /datamate-project-bindings/ (atomic create-workspace + bind). A new workspace is created with empty-slate defaults and the current project is bound to it in a single handler-owned transaction. Provide ``repo_remote`` when the project has a git remote, ``project_path`` as the fallback identifier when it does not. At least one is required; both is fine and permits path-then-remote upgrades. Identifier normalization runs on the mixin — see :class:`_BindingIdentifierMixin`.
  - `name` string, required
  - `repo_remote` string, nullable
  - `project_path` string, nullable
  - `description` string, nullable

## Response `201`

Successful Response

- CreateAndBindResponse
  - `datamate` DatamateRef, required — Minimal datamate reference embedded in binding responses.
    - `id` integer, required
    - `name` string, required
  - `binding` BindingModel, required — Wire shape returned to the CLI for a single binding row. Either ``repo_remote`` or ``project_path`` is present (at least one; the row's CHECK constraint enforces this). Projects with a git remote use ``repo_remote``; projects without one (materialized sample scaffolds, fresh scratch dirs) use ``project_path`` as the fallback identifier.
    - `id` integer, required
    - `datamate_id` integer, required
    - `datamate_name` string, required
    - `repo_remote` string, nullable
    - `project_path` string, nullable
    - `created_at` string, date-time, nullable
  - `manage_url` string, required

## Other responses

- `400` — Invalid request
- `403` — Forbidden
- `409` — This project is already linked to another workspace
- `422` — Validation Error

---

[API](https://skmtc.net/myaltimate/apis/fastapi.md) · [All operations](https://skmtc.net/myaltimate/apis/fastapi/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/myaltimate/fastapi/revisions/b9cc757ca795/schema)
