# Database API keys for websites and scripts

Mint a key that lets a website or a script read or write one Truetask database: who can, each setting, visitors, revoking and Cloud plans.

URL: https://docs.truetask.io/boards/database-keys

A database API key is a credential, starting `ttdb_`, that lets a website or a script read or write the records of one Truetask database and nothing else.
A board admin of the database makes it in the database's **Share** dialog, decides what it may do, and can change or revoke it at any time.

A key is how a [database](https://docs.truetask.io/boards/databases) becomes a price list on your website, the place a sign-up form writes to, or the table a script reads every night.
How a program calls the database with it is in the [Database API](https://docs.truetask.io/integrations/databases) reference.

| Question | Answer |
| --- | --- |
| What does a key reach? | The records of the one database it was made on. Everything else in Truetask refuses it. |
| Who makes one? | Board admins of that database. |
| Where? | The database's **Share** dialog, in the **API keys** section. |
| What can it do? | Any of **Read rows**, **Add rows**, **Change rows** and **Delete rows**, up to a number of requests a minute you set. |
| Can I see it again? | No. Copy it on the screen right after you create it. |
| How do I turn it off? | **Revoke** stops it at once, together with every visitor it gave an identity to. |

## What a key reaches

A key reaches the records of the database it was made on and nothing else in Truetask.
Every other route refuses it, the MCP server and the routes that make keys included, so a read-only key cannot make itself a writing one.

A People database takes no keys at all, because its rows are your workspace's own people: its **Share** dialog has no **API keys** section.

An AI tool or an agent needs no key: it reads and writes a database through the [MCP server](https://docs.truetask.io/agents/mcp), as the person or the agent it acts for.

## Who can make a key

Board admins of the database make and manage its keys, and that includes the person who created the database.
See [Roles and permissions](https://docs.truetask.io/reference/roles) for who else counts as a board admin.
Editors and viewers do not see the **API keys** section.

## Make a key

1. Open the database, open its page menu (the dots next to its title) and choose **Share**.
2. Scroll to **API keys**, at the bottom of the **Share database** dialog, below the people, agents and teams who have access.
3. Click **New key**.
4. Fill in the **New API key** dialog, described below, and press **Create key**.
5. Copy the key from the **Key minted** screen, then press **I have copied it**.

![Truetask New API key dialog for a database, with what the key is for, the rows it may read or write, visitors, expiry and rate](https://docs.truetask.io/screenshots/database-api-key.webp)

**New key** asks four things:

- **What is it for**, which is the name you will recognise the key by later, usually the site or the script it is going to.
- **What it may do**: **Read rows**, **Add rows**, **Change rows** and **Delete rows**, where writing includes reading, so ticking a write right ticks **Read rows** too.
- **Give each visitor an identity**, and with it **A visitor lasts (days)** and **Which rows a visitor may change**. See [Visitors](https://docs.truetask.io/boards/database-keys#visitors).
- **Stops working** and **Requests a minute**: the date the key expires on, and how many calls it may make each minute, its visitors' calls included.

| Setting | Default | Range |
| --- | --- | --- |
| **What is it for** | None: a key needs a name. | Your own words. |
| **What it may do** | **Read rows** | Any of the four. |
| **Give each visitor an identity** | Off | On or off. |
| **Which rows a visitor may change** | **All rows** | **All rows** or **Own rows**. Asked only when visitors are on and the key may change or delete rows. |
| **A visitor lasts (days)** | 90 | 1 to 730. |
| **Stops working** | Never | Any date in the future. |
| **Requests a minute** | 300 | 10 to 6000. A number outside is clamped, not refused. |

## The key is shown once

Right after **Create key**, the **Key minted** screen shows the key, the database's address, and ready curl, JavaScript and Python snippets that already carry this database's id and its own column names.
Copy the key then: Truetask keeps only a hash of it and cannot show it again.
The screen stays open until you press **I have copied it**, so a click outside it cannot take the key away.

Each key then has a tile in **API keys**, with its name, the first characters of the key so two keys can be told apart, and when it stops working or when it was last used.
The tile's pill says what the key may do: **Read only**, **Read and write**, or the rights it holds, such as **Read, Add**.
Over the tile, **Own rows** marks a key whose visitors change only their own rows, a count says how many visitors it has, and **Expired** shows once its date has passed.

## Change this key

Click a key's tile, or right-click it and choose **Change this key**, to change its name, what it may do, its visitor settings, the date it stops working and its requests a minute.
The key's secret stays the same.
A key that should have a different secret is a new key and a revoke.

Turning **Give each visitor an identity** off stops the visitors the key has already handed out, from their next request.
A new **A visitor lasts (days)** applies to visitors handed out from then on, since each visitor's end date is set when it is made.

## Revoke a key

Choose **Revoke** on a key's tile or in its right-click menu.
Truetask asks **Revoke this key?** first, because the key stops working at once, anything calling with it starts failing, and it cannot be undone.
Every visitor the key handed out stops with it.
The rows the key and its visitors wrote stay in the database.

## Connect

**Connect**, at the end of the **API keys** heading, shows the database's address and the same curl, JavaScript and Python snippets at any time, with `<your key>` where the key goes.
It is where you, or the developer you hand the key to, come back for the snippets after the key itself is gone from the screen.

## Visitors

A key is one credential for a whole site, so every browser that holds it looks like the same caller to Truetask.
**Give each visitor an identity** lets the site ask Truetask for a separate identity for each browser and send that instead of the key, so every row knows which visitor added it.
Turn it on when people on your site add rows of their own, such as comments, sign-ups or bookings, and come back to see or change what they wrote.

A visitor may do what its key may do and no more, at the key's requests a minute and only until the key's own **Stops working** date.
**A visitor lasts (days)** is how long each identity works, counted from when the site asks for it.
After that the browser needs a new identity, and the new one does not own the rows the old one added.

**Which rows a visitor may change** appears once visitors are on and the key may change or delete rows.

| Choice | What it means |
| --- | --- |
| **All rows** | Any visitor can change or delete any row. |
| **Own rows** | A visitor can only change or delete the rows they added. |

Choose **Own rows** whenever the public both adds rows and edits them, so nobody can change somebody else's comment or booking.
On an **Own rows** key the key itself may not change or delete rows at all: only its visitors may, and only their own.
A script that has to correct any row therefore needs a key of its own, set to **All rows**.
People in your workspace still edit every row in Truetask as usual.

A site can also forget a visitor when somebody asks, and can label a visitor with its own user id so your team sees who it was.
The developer side of both is in [Visitors in the Database API](https://docs.truetask.io/integrations/databases#visitors).

## The trail a key leaves

Making, changing and revoking a key each leave a row in the [audit log](https://docs.truetask.io/admin/security#audit-log).
A row a key adds or changes names the key in the record's activity, and a row a visitor wrote names the visitor, by your site's own user id when it gave one, or else by the first characters of the visitor's id.
A key is nobody: a row it adds has no author, so nothing suggests that the person who made the key typed it.

> **A key in a web page is public**
>
> Anyone who reads your page's source has the key.
> Give a page a key that can do only what the page needs, which is usually reading one database.

> **Truetask Cloud only**
>
> Database keys and their visitors need a paid plan or a running trial on Truetask Cloud.
> On Free the **API keys** section offers no **New key** and no **Connect**, and says "A database's own API keys need a paid plan." instead.
> Every call made with a key or a visitor answers 403 on Free, keys minted on a paid plan included: they stay listed and revocable, and answer again once the plan is paid.
> Keys also count, together with the workspace tokens an admin creates in **Settings > Integrations > API Tokens**, toward the plan's **Workspace API tokens** limit.
> Tokens people make for themselves and the connections of AI tools never count.
> See [Plans and billing](https://docs.truetask.io/cloud/plans).

## Frequently asked questions

### Can I give a website read-only access to a Truetask database?

Yes, a Truetask database key with only **Read rows** ticked lets a website read that one database's records and nothing else.
Its tile reads **Read only**, and a page holding it can never add, change or delete a row.
Because anyone can read a key out of a page's source, a read-only key is the right one for a public page.

### Can visitors edit only their own rows in a Truetask database?

Yes, a Truetask database key with **Give each visitor an identity** on, **Change rows** or **Delete rows** ticked, and **Which rows a visitor may change** set to **Own rows** lets each visitor change or delete only the rows they added.
The site does its part by asking for an identity for each browser and sending it instead of the key, as [Visitors in the Database API](https://docs.truetask.io/integrations/databases#visitors) shows.

### Can I see a database key again after creating it?

No, Truetask shows a database key once, on the **Key minted** screen, and keeps only a hash of it afterwards.
**Connect** shows the address and the snippets again at any time, with a placeholder where the key goes.
If a key is lost, make a new one, put it where the old one was, and revoke the old one.

### What happens to visitors when I revoke a database key?

Revoking a Truetask database key stops every visitor it handed out at the same moment as the key itself.
The rows they added stay in the database with no owner, and people in your workspace can still edit them in Truetask.

### Do database keys count toward my plan's token limit?

Yes, on Truetask Cloud every database key counts toward the plan's **Workspace API tokens** limit, together with the workspace tokens an admin creates in **Settings > Integrations > API Tokens**.
Visitors do not count, and neither do the tokens people make for themselves or the connections of their AI tools.
A self-hosted instance has no such limit.

## Related

- [Database API](https://docs.truetask.io/integrations/databases) for the routes, filters and clients a key is used with
- [Databases](https://docs.truetask.io/boards/databases)
- [Roles and permissions](https://docs.truetask.io/reference/roles)
- [Audit, sessions and logs](https://docs.truetask.io/admin/security)
- [Plans and billing](https://docs.truetask.io/cloud/plans)
