Scripts
The Scripts section is your own programs in JavaScript that Qubix runs on a schedule or with a button. A script gets access to ad data through a built-in set of commands (the QubixApp SDK), can pause ads, turn them back on, run read-only queries against the Qubix database (the sql command), reach out to external services and keep its own state between runs.
Scripts are a good fit when the standard Britva auto-rules are no longer enough: you need non-standard logic, a call to an external API, or calculations that are hard to express as a condition.
How scripts differ from Britva
Both Britva and Scripts automate working with ads, but they solve different tasks.
| Britva (auto-rules) | Scripts | |
|---|---|---|
| How the logic is described | A JavaScript condition over one ad (checkAd) → an action (pause/return) | Free-form JavaScript code |
| Who it suits | Auto-pause/return of ads by a metric condition | Non-standard scenarios, your own logic |
| Database queries | Yes, read-only SQL (the sql command, when enabled in system settings) | Yes, read-only SQL against the Qubix database (the sql command) |
| External services | No | Yes, a request to an external API |
| Memory between runs | No | Yes, its own state |
| Entry barrier | Lower: only a condition (the AI assistant can write it) | Higher: a whole program (the AI assistant can help) |
If the task can be expressed as a simple condition "if ROAS is below the threshold — pause it", start with Britva auto-rules — it is faster and clearer. Use scripts where you need logic that a rule cannot express.
List of scripts
The main screen of the section is a table of all your scripts with the columns:
- Name — the script name (if not set, a short identifier is shown).
- Schedule — when the script runs automatically, as a readable phrase (for example, "Every 5 minutes"). A dash means no schedule is set, the script only runs manually.
- Status — a check mark if the script is active; a dash if it is off.
- Last run — the time and result of the last execution.
The + Create script button in the top-right corner opens the editor for a new script. Clicking a table row opens an existing script for editing.