> ## 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.

# Collections and documents

> Scripts API routes: collections and documents.

| Method | Path | What it does |
| - | - | - |
| `GET` | `/scripts/{script_id}/collections` | Collections from supabase/collections.json and their rules. |
| `GET` | `/scripts/{script_id}/collections/{collection}/documents` | Lists documents (collections.json rules apply). |
| `POST` | `/scripts/{script_id}/collections/{collection}/documents` | Creates a document. |
| `GET` | `/scripts/{script_id}/collections/{collection}/documents/{doc_id}` | A single document. |
| `PATCH` | `/scripts/{script_id}/collections/{collection}/documents/{doc_id}` | Replaces the document's data. |
| `DELETE` | `/scripts/{script_id}/collections/{collection}/documents/{doc_id}` | Deletes the document. |

## GET /scripts/\{script\_id}/collections

Collections from supabase/collections.json and their rules.

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

**Path parameters:** `script_id`

**Response:** `{ name, read_rule, write_rule }[]`

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

## GET /scripts/\{script\_id}/collections/\{collection}/documents

Lists documents (collections.json rules apply).

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

**Path parameters:** `script_id`, `collection`

**URL parameters:** `limit?, offset?, order?`

**Response:** `Document[]`

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

## POST /scripts/\{script\_id}/collections/\{collection}/documents

Creates a document.

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

**Path parameters:** `script_id`, `collection`

**Body:** `{ data: object }`

**Response:** `Document`

```bash cURL theme={null}
curl -X POST "https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-scripts-api/scripts/{script_id}/collections/{collection}/documents" \
  -H "Authorization: Bearer dts_SEU_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"data":{"texto":"oi"}}'
```

## GET /scripts/\{script\_id}/collections/\{collection}/documents/\{doc\_id}

A single document.

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

**Path parameters:** `script_id`, `collection`, `doc_id`

**Response:** `Document`

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

## PATCH /scripts/\{script\_id}/collections/\{collection}/documents/\{doc\_id}

Replaces the document's data.

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

**Path parameters:** `script_id`, `collection`, `doc_id`

**Body:** `{ data: object }`

**Response:** `Document`

```bash cURL theme={null}
curl -X PATCH "https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-scripts-api/scripts/{script_id}/collections/{collection}/documents/{doc_id}" \
  -H "Authorization: Bearer dts_SEU_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"data":{"texto":"novo"}}'
```

## DELETE /scripts/\{script\_id}/collections/\{collection}/documents/\{doc\_id}

Deletes the document.

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

**Path parameters:** `script_id`, `collection`, `doc_id`

**Response:** `204`

```bash cURL theme={null}
curl -X DELETE "https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-scripts-api/scripts/{script_id}/collections/{collection}/documents/{doc_id}" \
  -H "Authorization: Bearer dts_SEU_TOKEN"
```


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