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

# Backend functions and deployment

> Scripts API routes: backend functions and deployment.

| Method | Path | What it does |
| - | - | - |
| `GET` | `/scripts/{script_id}/functions` | Published functions from supabase/functions/. |
| `POST` | `/scripts/{script_id}/deploy` | Redeploys the backend from the default branch. |
| `POST` | `/scripts/{script_id}/functions/{name}` | Calls a function as the token's user (request.user = @username). The body becomes request.body. |

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

Published functions from supabase/functions/.

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

**Path parameters:** `script_id`

**Response:** `{ name, status, error, live_sha, updated_at, last_run_at, url }[]`

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

## POST /scripts/\{script\_id}/deploy

Redeploys the backend from the default branch.

**Authentication:** Scope: `functions.deploy`

**Path parameters:** `script_id`

**Response:** `{ sha, functions, removed, collections, error }`

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

## POST /scripts/\{script\_id}/functions/\{name}

Calls a function as the token's user (request.user = @username). The body becomes request.body.

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

> [!NOTE]
>
> The function receives `request.method = "POST"`, `request.body` with the submitted JSON, and `request.query` with the URL parameters. The `X-DoglyTdc-Function-Ms` header contains the execution time. Limit: 120 calls per minute per person and script.

**Path parameters:** `script_id`, `name`

**URL parameters:** `forwarded in request.query`

**Body:** `any JSON`

**Response:** `whatever the function returns`

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


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