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

# Connections and actions

> How a Dev panel function connects to the script: configuration, server function or collection, and what each button sends.

The `connect` field in `funcao.json` says where the screen gets its data and where it goes.

| `type` | Reads | Saves | `@call` actions |
| - | - | - | - |
| `config` | The fields in `keys` | The fields in `keys` | No |
| `function` | Whatever the function returns | Whatever the function decides | Yes |
| `collection` | Up to 100 records | No (read-only) | No |

## config — remote configuration

```json theme={null}
{ "connect": { "type": "config", "keys": ["aviso_ativo", "aviso_texto", "aviso_cor"] } }
```

* 1 to 40 fields.
* On open and on `@reload`: shows only those fields.
* On `@save`: saves only those fields; the rest of the configuration stays as it is.
* The script reads the values in `window.DoglyScript.config`, without publishing a new version.

## function — server function

```json theme={null}
{ "connect": { "type": "function", "name": "cupons" } }
```

`name` is the name of one of the script's server functions (letters, numbers, `_` and `-`, up to 64). It receives in `request.body.panel`:

| Field | Value |
| - | - |
| `function` | The panel function id, e.g. `"cupons"` |
| `op` | `"load"` (on open and on `@reload`), `"save"` (on `@save`) or `"call"` (on `@call:name`) |
| `action` | The `name` from `@call:name`, or `null` |
| `values` | The current values on the screen |

And replies with:

| Field | What it does |
| - | - |
| `values` | Updates the fields on the screen (object) |
| `rows` | List for `dt-table` (up to 200) |
| `message` | Short notice shown after the action (up to 200 characters) |

```js theme={null}
function handler(request) {
  const p = request.body.panel;

  if (p.op === "load") {
    return doglytdc.respond(200, {
      values: { ativos: 2, usos: 31, tipo: "pct", lista: [
        { codigo: "WELCOME10", tipo: "pct", desconto: 10, usos: 25 },
        { codigo: "VIP", tipo: "valor", desconto: 5, usos: 6 },
      ] },
    });
  }

  if (p.op === "call" && p.action === "criar") {
    if (!p.values.codigo) return doglytdc.respond(400, { error: "Enter the code." });
    return doglytdc.respond(200, { message: "Coupon created." });
  }

  return doglytdc.respond(200, { values: p.values, message: "Saved." });
}
```

* A reply with status 400 or higher shows `error` on the screen.
* Never return passwords, keys or tokens: everything sent back appears on screen.

> [!NOTE]
>
> The script's server folder will get its own documentation. This page only covers what a Dev panel function receives and returns.

## collection — collection (read-only)

```json theme={null}
{ "connect": { "type": "collection", "name": "acessos" } }
```

* Shows up to **100** records in `dt-table` (and numbers in `dt-stat`).
* Input fields and `@save` are refused during validation.
* `@reload` works.

## Who can use it

Every action is checked on the server: only the script owner calls functions created from code. A collaborator gets `OWNER_ONLY`, even when calling the API directly.


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