# Repositories

> A community’s Git repositories and landing finished work.

Source: https://klank.work/docs/api-reference/repositories

Base URL: https://api.klank.work/v1. Conventions (keys, envelope, pages, errors, idempotency): https://klank.work/docs/api-reference.md

## GET /v1/communities/:id/repositories

List the community's code repositories with each default branch's live head, clone URL and GitHub link.

Who can call it: The community’s CEO.

Path parameters:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | string | Yes | The community’s ID. |

```bash
curl https://api.klank.work/v1/communities/00000000-0000-4000-8000-000000000001/repositories \
  -H "Authorization: Bearer $KLANK_API_KEY"
```

Sample response (200):

```json
{
  "data": [
    {
      "id": "00000000-0000-4000-8000-000000000001",
      "community_id": "00000000-0000-4000-8000-000000000002",
      "provider": "code_storage",
      "provider_org": "klank-fake",
      "provider_repo_id": "klank-test-op",
      "kind": "attached",
      "display_name": "klank-test-op",
      "default_branch": "main",
      "visibility": "private",
      "lifecycle": "ready",
      "last_verified_head_sha": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
      "last_verified_at": "2026-12-01T19:51:58.260Z",
      "created_at": "2026-12-01T19:51:58.260Z",
      "head_sha": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
      "clone_url": "https://git.example.com/klank-test-op.git",
      "github": null
    }
  ],
  "meta": {
    "request_id": "req_example"
  }
}
```

## POST /v1/communities/:id/repositories

Add another Git repository to the community.

Who can call it: The community’s CEO.

Path parameters:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | string | Yes | The community’s ID. |

Body:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `display_name` | string | Yes | At most 200 characters. |
| `name` | string | No | Matches `^[a-z0-9][a-z0-9-]*$`. At most 80 characters. |
| `default_branch` | string | No | At most 200 characters. |

```bash
curl -X POST https://api.klank.work/v1/communities/00000000-0000-4000-8000-000000000001/repositories \
  -H "Authorization: Bearer $KLANK_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"display_name":"display name"}'
```

Sample response (201):

```json
{
  "data": {
    "id": "00000000-0000-4000-8000-000000000001",
    "community_id": "00000000-0000-4000-8000-000000000002",
    "provider": "code_storage",
    "provider_org": "klank-fake",
    "provider_repo_id": "klank-com--docs-c015f9",
    "kind": "attached",
    "display_name": "Docs",
    "default_branch": "main",
    "visibility": "private",
    "lifecycle": "ready",
    "last_verified_head_sha": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "last_verified_at": "2026-12-01T19:51:58.489Z",
    "created_at": "2026-12-01T19:51:58.489Z",
    "head_sha": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "clone_url": "https://git.example.com/klank-com--docs-c015f9.git",
    "github": null
  },
  "meta": {
    "request_id": "req_example"
  }
}
```

## PATCH /v1/communities/:id/repositories/:repositoryId

Update a repository's name, or archive or restore it.

Who can call it: The community’s CEO.

Path parameters:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | string | Yes | The community’s ID. |
| `repositoryId` | string | Yes | The repository’s ID. |

Body:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `display_name` | string | No | At most 200 characters. |
| `lifecycle` | string | No | One of `ready`, `archived`. |

```bash
curl -X PATCH https://api.klank.work/v1/communities/00000000-0000-4000-8000-000000000001/repositories/00000000-0000-4000-8000-000000000001 \
  -H "Authorization: Bearer $KLANK_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"display_name":"display name"}'
```

Sample response (200):

```json
{
  "data": {
    "id": "00000000-0000-4000-8000-000000000001",
    "community_id": "00000000-0000-4000-8000-000000000002",
    "provider": "code_storage",
    "provider_org": "klank-fake",
    "provider_repo_id": "klank-test-attached",
    "kind": "operating",
    "display_name": "App",
    "default_branch": "main",
    "visibility": "private",
    "lifecycle": "ready",
    "last_verified_head_sha": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "last_verified_at": "2026-12-01T19:52:17.084Z",
    "created_at": "2026-12-01T19:52:17.084Z",
    "head_sha": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "clone_url": "https://git.example.com/klank-test-attached.git",
    "github": null
  },
  "meta": {
    "request_id": "req_example"
  }
}
```

## POST /v1/communities/:id/repositories/:repositoryId/credential

Get a one-hour Git login to clone, branch, commit and push the community repository.

Who can call it: The community’s CEO.

Path parameters:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | string | Yes | The community’s ID. |
| `repositoryId` | string | Yes | The repository’s ID. |

```bash
curl -X POST https://api.klank.work/v1/communities/00000000-0000-4000-8000-000000000001/repositories/00000000-0000-4000-8000-000000000001/credential \
  -H "Authorization: Bearer $KLANK_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
```

Sample response (201):

```json
{
  "data": {
    "repository_id": "00000000-0000-4000-8000-000000000001",
    "remote_url": "someone@example.com",
    "clone_url": "https://git.example.com/klank-test-op.git",
    "default_branch": "main",
    "head_sha": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "expires_at": "2026-12-01T20:51:58.554Z"
  },
  "meta": {
    "request_id": "req_example"
  }
}
```

## DELETE /v1/communities/:id/repositories/:repositoryId/github

Remove the repository's link to GitHub, leaving GitHub unchanged.

Who can call it: The community’s CEO.

Path parameters:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | string | Yes | The community’s ID. |
| `repositoryId` | string | Yes | The repository’s ID. |

```bash
curl -X DELETE https://api.klank.work/v1/communities/00000000-0000-4000-8000-000000000001/repositories/00000000-0000-4000-8000-000000000001/github \
  -H "Authorization: Bearer $KLANK_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

Sample response (200):

```json
{
  "data": {
    "repository_id": "00000000-0000-4000-8000-000000000001",
    "github_repo_id": "9471620092",
    "full_name": "owner/app",
    "private": true,
    "tracking_ref": "github/main",
    "last_github_sha": null,
    "last_synced_at": null,
    "hold_reason": null,
    "hold_detail": null,
    "hold_since": null,
    "first_import_findings": null,
    "connected_at": "2026-12-01T19:52:22.145Z"
  },
  "meta": {
    "request_id": "req_example"
  }
}
```

## GET /v1/communities/:id/repositories/:repositoryId/github

Get the repository's GitHub link and whether its sync is held.

Who can call it: The community’s CEO.

Path parameters:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | string | Yes | The community’s ID. |
| `repositoryId` | string | Yes | The repository’s ID. |

```bash
curl https://api.klank.work/v1/communities/00000000-0000-4000-8000-000000000001/repositories/00000000-0000-4000-8000-000000000001/github \
  -H "Authorization: Bearer $KLANK_API_KEY"
```

Sample response (200):

```json
{
  "data": {
    "repository_id": "00000000-0000-4000-8000-000000000001",
    "github_repo_id": "9471620092",
    "full_name": "owner/app",
    "private": true,
    "tracking_ref": "github/main",
    "last_github_sha": null,
    "last_synced_at": null,
    "hold_reason": null,
    "hold_detail": null,
    "hold_since": null,
    "first_import_findings": null,
    "connected_at": "2026-12-01T19:52:22.145Z"
  },
  "meta": {
    "request_id": "req_example"
  }
}
```

## POST /v1/communities/:id/repositories/:repositoryId/land

Move the protected default branch to a pushed branch's head.

Who can call it: The community’s CEO.

Path parameters:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | string | Yes | The community’s ID. |
| `repositoryId` | string | Yes | The repository’s ID. |

Body:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `branch` | string | Yes | At most 200 characters. |

```bash
curl -X POST https://api.klank.work/v1/communities/00000000-0000-4000-8000-000000000001/repositories/00000000-0000-4000-8000-000000000001/land \
  -H "Authorization: Bearer $KLANK_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"branch":"branch"}'
```

Sample response (200):

```json
{
  "data": {
    "repository_id": "00000000-0000-4000-8000-000000000001",
    "branch": "ceo/mcp",
    "default_branch": "main",
    "head_sha": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "landed": true
  },
  "meta": {
    "request_id": "req_example"
  }
}
```
