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

# Bind Existing

`POST /datamate-project-bindings/bind`

Attach this project to an existing workspace the caller owns.

Non-visibility is a 404, not 403 — a caller walking the integer id-space
should get the same response for "no such workspace" and "someone else's
workspace". Upgrade semantics: if the request supplies both a remote and
a path, either one resolving to this workspace is idempotent success,
either one resolving to a DIFFERENT workspace is 409, both unresolved
falls through to a fresh INSERT (and a row that carries both identifiers
so future lookups by either succeed).

The target Datamate is locked ``FOR UPDATE`` before the binding write
(M5) so a concurrent ``soft_delete_datamate`` can't tombstone the parent
between visibility check and INSERT.

## Request body

- BindExistingRequest — Body for POST /datamate-project-bindings/bind (attach to existing workspace). Caller must own ``datamate_id``. Idempotent: re-binding the same project to the same workspace returns the existing binding. 409 when the project is already bound to a DIFFERENT workspace for this tenant. Provide ``repo_remote`` OR ``project_path`` (or both). At least one is required. Identifier normalization runs on the mixin.
  - `datamate_id` integer, required
  - `repo_remote` string, nullable
  - `project_path` string, nullable

## Response `200`

Successful Response

- BindingResponse — Response for the bind-existing and rebind endpoints.
  - `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

## Other responses

- `400` — Invalid request
- `404` — Workspace not found
- `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)
