# Data sources

> Connect a database, a webhook or a form, explore its data and save the queries you use often.

A data source is where your monitors read from. Pulso supports three types:

- **SQL database**: a PostgreSQL, MySQL or MariaDB database that monitors query on a schedule.
- **Webhook**: an endpoint that receives events from your systems. Monitors on it run on every event.
- **Form**: a public page with the fields you choose. Monitors on it run on every submission.

Only admins can add, edit or delete data sources. See [Members and roles](https://pulso.run/docs/concepts/members-and-roles.md).

![The data sources page](https://pulso.run/assets/website/datasources-dashboard-ab0972a2.png)

## Connect a database

1. Go to **Build → Data sources** and click **Add data source**.
2. Enter a **Name** and choose **SQL database**.
3. Choose the **Engine**: **PostgreSQL**, or **MySQL or MariaDB** (MySQL 5.7 and later, MariaDB 10.3 and later).
4. Fill in **Host**, **Port**, **Database**, **Username**, **Password** and, optionally, **SSL mode**:
   - PostgreSQL: port 5432 by default; `disable`, `allow`, `prefer`, `require`, `verify-ca` or `verify-full`, `prefer` when left blank.
   - MySQL and MariaDB: port 3306 by default; `disabled`, `preferred`, `required`, `verify_ca` or `verify_identity`, `preferred` when left blank.

   To paste a single string instead, click **Use a connection URL instead** and fill in **Connection URL**, for example `postgres://user:password@host:5432/database` or `mysql://user:password@host:3306/database?ssl_mode=required`. **Enter the connection details separately** takes you back.
5. Save.

When you edit the data source later, leave **Password** empty to keep the current one.

Pulso runs every query in a read-only transaction, one statement at a time. Even so, connect with a user that can only read what you want to monitor: on MySQL, `GRANT SELECT ON shop.* TO 'pulso'@'%'`.

On MySQL and MariaDB a query runs wrapped as a derived table, so two result columns can't share a name: write `SELECT o.id, c.id AS customer_id …` rather than `SELECT *` over a join. Each database the user can read is a schema in the **Tables** panel, the data source's own first.

> **Note**
>
> Pulso checks the connection of data sources that have active monitors and no recent activity. If it fails, admins and operators get an email saying "Issue with *data source name* detected".

## Webhook

1. Go to **Build → Data sources** and click **Add data source**.
2. Enter a **Name**, choose **Webhook** and save.

The data source page shows:

- **Webhook endpoint**: the **Endpoint URL** to send events to, and a **cURL example** you can copy. The URL contains a secret token, so treat it like a password.
- **Recent events**: the last events received, updated live.
- **Queries API**: how to list the fields its monitors read. See [Data source queries](https://pulso.run/docs/api/data-source-queries.md).

Send events as JSON, form fields or multipart. Nested objects are flattened with dots, so `{"customer": {"email": "…"}}` becomes a `customer.email` column for monitors. See [Data source webhooks](https://pulso.run/docs/api/data-source-webhooks.md) for the full reference.

## Form

1. Go to **Build → Data sources** and click **Add data source**.
2. Enter a **Name**, choose **Form** and save. The form editor opens.

In the form editor:

![The form editor, with a question selected](https://pulso.run/assets/website/form-editor-cab34b15.png)

- Click the title and the description at the top of the form to edit them. The title is the data source's name when left blank.
- **Add** a question of a type: Short text, Long text, Number, Email, Phone, Web address, Date, Choice, Checkboxes, Yes/no, Rating or Hidden. A **Section** adds a heading with some text between questions. New ones go after the selected question.
- Click a question to edit it on the right: its **Question**, **Key**, **Help text**, **Placeholder** and whether it is **Required**. A Number can have a **Minimum** and a **Maximum**, and a text a **Min. length** and a **Max. length**. A Short text can have a **Pattern**, a regular expression the whole answer must match, such as `BC-[0-9]+`, with the message people see when it doesn't. A Choice or Checkboxes has its **Options** (Enter adds the next one, and pasting several lines adds one per line) and shows them as a **Dropdown** or as **Buttons**. A Rating is **1–5 stars** or **0–10 (NPS)**, and its answer is a number. Checkboxes take several options: monitors get them in one column, joined with commas (`Billing, Shipping`), and a condition that it **is** an option holds when that one is picked.
- Move a question by dragging it, with its arrows, or with Alt+↑/↓. Its buttons also duplicate or remove it.
- Tick **Start a new page** on a section to split the form there: people see one page at a time, with a progress bar, **Next** and **Back**. Pages whose questions are all hidden are skipped.
- With no question selected, **Form settings** sets the **Language** of the page's own texts (buttons, errors, the email and the unsubscribe page), the **Button** text and the **Message after sending**. Write the questions in that language too.
- The account's **Logo** and **Colour**, in **Settings → Account**, show on its public forms and in form emails.
- A new form can start from a template: **Refund request**, **Incident report** or **Contact**.
- **Preview** shows the form as people will see it, on a computer or a phone, and in dark mode. **Open form** opens the saved one.
- **Undo** (⌘Z) and **Redo** (⇧⌘Z) step through your changes.
- **Save** (⌘S) checks the questions first and points at what to fix. Until then your changes are kept in this browser: reopening the editor restores them, or offers to if the form was saved elsewhere since.

![The public form](https://pulso.run/assets/website/form-public-ee93c541.png)

### Explore the answers

**All submissions**, on the form's data source page, lists every answer with a column per question and links to the signals each one opened or joined. Search the text of any answer, pick a date range, or filter a Choice, Yes/no or Rating question by its answer. **Export CSV** downloads what the filters show. Admins and operators can see it.

Admins can delete a submission with its trash icon, or all of them with **Delete all submissions** under **Keep answers**, for example when someone asks to erase their data. The signals they opened stay. **Delete answers older than** sets how long the form keeps them, from 30 days to 2 years: older ones are deleted every night. The account's audit log records how many were deleted and by whom, not the answers.

### Show a question only in some cases

**Show only if** makes a question depend on one above it: it shows only when that answer **is** or **is not** a value, or **is answered** or **is not answered** (for a Yes/no, **is checked** or **is not checked**). For example, ask "Tell us what happened" only when the reason is "Other". The question appears as soon as the earlier answer matches, and in **Preview** too.

A hidden question isn't required and its answer isn't kept, even if a link filled it in. Text is compared ignoring case, and numbers by value. Renaming the key of the earlier question updates the conditions on it.

### Who can answer

Under **Who can answer** on the form's data source page:

- **Anyone with the link**, the default.
- **Anyone with the link and a password**: the page asks for it once per browser. Setting a new one asks everyone again.
- **Members of the account, signed in**: others are sent to sign in, and people outside the account can't answer.
- **Only personal links from email sends**: the public link no longer takes answers.

Personal links always work, whatever is chosen.

### Embed a form in another site

List the sites that may show the form under **Embed on another site**, for example `https://www.example.com`, and paste the snippet it gives into a page of one of them. Other sites can't put the form in a frame.

The frame grows to the form's height, has no background of its own and keeps the form's colour. Its light or dark look follows the visitor's; add `&theme=light` or `&theme=dark` to the link in the snippet to fix it. When the form is sent, the frame posts a `pulso:form-submitted` message the page can listen to. Forms with a password or for members only can't be answered in a frame, since browsers don't share the sign-in with it.

### Send a form by email

To ask a list of people, click **Send by email** on the form's data source page:

1. Upload a CSV with an `email` column, one row per person. Columns named like a question's key fill it in for that person, for example `email,order_number`. Commas or semicolons both work. Or **Pick contacts** from the account's verified email contacts in the [Address book](https://pulso.run/docs/concepts/variables-and-address-book.md#address-book); a question with the key `name` or `email` gets theirs.
2. Add a message (plain text, without links; the email adds the button to the form). Optionally set **Answer by**, a deadline the email states, and a **Reminder**: one more email, 2 to 7 days after sending, to those who haven't answered yet.
3. Review who gets it and who is left out: addresses that aren't valid, repeated, unsubscribed, or that got this form in the last 7 days.
4. **Send**. Each person gets their own link: it fills in their answers and shows on the send's page as sent, opened and answered. Opening it again after answering shows their answer to change; the submission is updated and monitors check it again. After the deadline, the link says the form no longer takes answers.

![A send's page, with who answered and who was left out](https://pulso.run/assets/website/form-send-ad58aba9.png)

Monitors get who answered from a personal link as `{{signal.recipient_email}}`, and the CSV's other columns as `recipient_<column>`, for example `{{signal.recipient_plan}}`, so a playbook can write back to them. The submissions page and its CSV show the recipient too.

To send a form to one person when a signal fires, such as the customer of a disputed charge, add a **Send a form** step to the monitor's [playbook](https://pulso.run/docs/concepts/playbooks.md#people). To send it another way, through Slack, SMS or another tool, use a [form link](https://pulso.run/docs/concepts/playbooks.md#form-links).

Replies go to whoever sent it. Every email has a link to stop getting forms from the account, which then skips that address. An address that bounces for good, or marks the email as spam, is skipped the same way and shows as **Bounced** on the send's page.

Verified contacts don't count towards the limits. To prevent spam, reminders included, an account can send up to 50 emails per send, 100 a day (25 in its first week) and 500 a month. To send more, write to [hi@pulso.run](mailto:hi@pulso.run). An account whose emails bounce or are marked as spam too often stops sending forms until support resumes it.

### Get told of new answers

Under **Notify on new answers** on the form's data source page, pick members to email, a Slack channel to post to, or both. Each answer is sent as it arrives, up to 20 an hour, or choose **One digest an hour** for a single message with the answers since the last one. Edits to an answer don't notify again. For rules on the answers, such as only refunds over an amount, use a monitor instead.

### Fill answers in from the link

Add `?key=value` to the form's link to fill a question in, for example `…/forms/…/…?order_number=BC-10442&email=ana@example.com`. The person can still change it, and it is checked like a typed answer. **Form settings** shows the link with every key.

A **Hidden** question is not shown: it is only filled from the link, and stored like any other answer. Use it to pass along what the person shouldn't type, such as a customer id or where the link was sent from.

The key is the column monitors read, as `{{signal.key}}`. It follows the question until you edit it, and holds only lowercase letters, digits and `_`. The editor shows which monitors read each key; renaming or removing one they use warns that they will no longer get that answer. Saving such a change first lists those monitors, active ones first, with what each loses; **Save anyway** or **Keep editing**.

To watch the answers, click **Create monitor** in the editor and pick the question that tells them apart, such as the order number: Pulso creates a paused monitor on the form with that uniq by and opens it to finish.

The data source page shows:

- **Public form**: the link to share. Anyone with it can submit the form, without signing in, so treat it like a password.
- **Recent submissions**: the last answers received, updated live.

Answers are stored encrypted. Only the questions of the form are kept, and each submission is checked against them: a required question left blank, or a number, email, phone, web address, date or choice that doesn't fit, sends the person back to the form. A person can send 10 submissions a minute at most.

### Close a form or change its link

On the **Public form** card:

- **Close form** stops taking answers: the page, and every personal link, say the form is closed. **Reopen** takes them again.
- **New link** replaces the link's token. The old link stops working at once; personal links from email sends keep working.
- **Limits on the public link** caps answers **In total** and **Per day**. Over a limit, the page says it isn't taking answers for now. Personal links aren't counted.

Submissions from bots are dropped without saying so: the form has a field people don't see, and answers sent a few seconds after the page loaded, or without loading it, aren't kept.

## Explore a database

Click **Explore** on a SQL data source to open the explorer. Admins and operators can use it.

- **Run query** (⌘↵) runs the editor's content, or only the selected text if there is a selection.
- **Format** (⌘F) formats the SQL.
- ⌃Space suggests tables and columns.
- **Save** (⌘S) saves the query. See [Saved queries](https://pulso.run/docs/concepts/data-sources.md#saved-queries).
- **Create monitor** creates a paused monitor with the query. See [Monitors](https://pulso.run/docs/concepts/monitors.md).

The explorer is read-only. It shows the first 500 rows and stops a query after 30 seconds.

The side panel has two tabs:

- **Tables** lists the tables your database user can read, with their columns. Search with **Search tables and columns**, and click a table to preview its first 100 rows.
- **Saved** lists the saved queries of this data source.

In the results you can **Filter rows**, copy them as Markdown, text or CSV, and download a CSV file.

The explorer keeps your draft in the browser, so you can leave and come back to it.

## Saved queries

Save a query from the explorer with **Save** (⌘S). The dialog asks for:

- **Name**
- **Folder**: none, an existing one, or **New folder…**
- **Description** (optional)

When you edit a saved query, **Save changes** updates it and **Save as new** keeps the original and creates a copy.

Folders can be nested. Deleting a folder moves what it contains one level up.

**Build → Saved queries** lists the saved queries of every data source, with filters by data source and name. Admins and operators can create and edit saved queries; only admins and the query's author can delete one.

## Delete a data source

On the data source, click **Delete**. The confirmation lists the monitors that use it: they are paused when you delete it. Its saved queries are deleted with it.
