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

# Repository

> Scripts API routes: repository.

| Method | Path | What it does |
| - | - | - |
| `GET` | `/scripts/{script_id}/repo/branches` | Repository branches. |
| `POST` | `/scripts/{script_id}/repo/branches` | Creates a branch from a commit (default: main's head). |
| `GET` | `/scripts/{script_id}/repo/tree` | File list for a ref. |
| `GET` | `/scripts/{script_id}/repo/files/{path*}` | File contents. ?raw=1 returns plain text. |
| `GET` | `/scripts/{script_id}/repo/commits` | History (first parent), optionally filtered by file. |
| `GET` | `/scripts/{script_id}/repo/commits/{sha}` | A commit with the list of changed files. |
| `POST` | `/scripts/{script_id}/repo/commits` | Writes files in a commit. content:null deletes. expected\_head prevents overwriting others' work (409 HEAD\_MOVED). On the default branch, publishes the backend; changing supabase/ requires functions.deploy. |

## GET /scripts/\{script\_id}/repo/branches

Repository branches.

**Authentication:** Scope: `scripts.read`

**Path parameters:** `script_id`

**Response:** `{ name, head_sha, is_default, created_by, updated_at }[]`

```bash cURL theme={null}
curl -X GET "https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-scripts-api/scripts/{script_id}/repo/branches" \
  -H "Authorization: Bearer dts_SEU_TOKEN"
```

## POST /scripts/\{script\_id}/repo/branches

Creates a branch from a commit (default: main's head).

**Authentication:** Scope: `scripts.write`

**Path parameters:** `script_id`

**Body:** `{ name, from? }`

**Response:** `{ name, head_sha }`

```bash cURL theme={null}
curl -X POST "https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-scripts-api/scripts/{script_id}/repo/branches" \
  -H "Authorization: Bearer dts_SEU_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"nova-tela"}'
```

## GET /scripts/\{script\_id}/repo/tree

File list for a ref.

**Authentication:** Scope: `scripts.read`

**Path parameters:** `script_id`

**URL parameters:** `ref? (branch or sha)`

**Response:** `{ ref, sha, files: { path, hash, size }[] }`

```bash cURL theme={null}
curl -X GET "https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-scripts-api/scripts/{script_id}/repo/tree" \
  -H "Authorization: Bearer dts_SEU_TOKEN"
```

## GET /scripts/\{script\_id}/repo/files/\{path\*}

File contents. ?raw=1 returns plain text.

**Authentication:** Scope: `scripts.read`

**Path parameters:** `script_id`, `path*`

**URL parameters:** `ref?, raw?`

**Response:** `{ ref, sha, path, hash, content }`

```bash cURL theme={null}
curl -X GET "https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-scripts-api/scripts/{script_id}/repo/files/src/script.js" \
  -H "Authorization: Bearer dts_SEU_TOKEN"
```

## GET /scripts/\{script\_id}/repo/commits

History (first parent), optionally filtered by file.

**Authentication:** Scope: `scripts.read`

**Path parameters:** `script_id`

**URL parameters:** `ref?, path?, limit? (1-100, default 30)`

**Response:** `Commit[]`

```bash cURL theme={null}
curl -X GET "https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-scripts-api/scripts/{script_id}/repo/commits" \
  -H "Authorization: Bearer dts_SEU_TOKEN"
```

## GET /scripts/\{script\_id}/repo/commits/\{sha}

A commit with the list of changed files.

**Authentication:** Scope: `scripts.read`

**Path parameters:** `script_id`, `sha`

**Response:** `Commit & { files: { path, status }[] }`

```bash cURL theme={null}
curl -X GET "https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-scripts-api/scripts/{script_id}/repo/commits/{sha}" \
  -H "Authorization: Bearer dts_SEU_TOKEN"
```

## POST /scripts/\{script\_id}/repo/commits

Writes files in a commit. content:null deletes. expected\_head prevents overwriting others' work (409 HEAD\_MOVED). On the default branch, publishes the backend; changing supabase/ requires functions.deploy.

**Authentication:** Scope: `scripts.write`

> [!NOTE]
>
> Use `expected_head` with the `head_sha` read from `GET /repo/branches`. If the branch has changed in the meantime, the server responds with `409 HEAD_MOVED` and nothing is written. On the main branch, changing `supabase/` also requires `functions.deploy`, and the backend is published immediately (the summary is in `deploy`). Limit: 30 commits per minute per person and script; up to 100 files per commit.

**Path parameters:** `script_id`

**Body:** `{ branch?, expected_head, message, description?, changes: { path, content|null }[] }`

**Response:** `{ commit, branch, deploy? }`

```bash cURL theme={null}
curl -X POST "https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-scripts-api/scripts/{script_id}/repo/commits" \
  -H "Authorization: Bearer dts_SEU_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"expected_head":"<head_sha>","message":"Atualiza script","changes":[{"path":"src/script.js","content":"console.log(1)"}]}'
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.