# API keys and authentication

Every request to the Desktop Books API carries an API key that starts with `dbk_`. A key reads either one company file or every file in your account, it is shown once when you make it, and it goes in the `Authorization` header, never in the URL. Assistants connecting over MCP sign in instead of using a key.

## Make a key

Open **API keys** in the app. Give the key a label that says where it will live ("Excel on the office PC", "Month-end script"), pick a company file or **All company files**, and click **Create key**. Copy it right away: we keep only a hash of the key, so it can't be shown again. Only owners and admins of an account can make or revoke keys.

## Which scope to pick

| Company file setting | Can read | Good for |
| --- | --- | --- |
| One company file | That file only | A report or a sheet for one client |
| All company files | Every file in the account, including ones added later | Your own scripts across every client |

Firms usually make one key per client file and one key per place it's used. A key handed to one client's workbook then can't read another client's books, and revoking one doesn't break the rest.

## Send it as a Bearer token

```bash
curl -H "Authorization: Bearer dbk_your_key" "https://desktop-app.greatwork.company/v1/files"
```

## Or as Basic auth

Put the key in the user name and leave the password empty. This is the form Excel and Power BI store in their own credential manager (see [Excel and Power Query](/docs/excel-power-query)):

```bash
curl -u "dbk_your_key:" "https://desktop-app.greatwork.company/v1/files"
```

## Check what a key can see

`GET /v1/me` returns the account the key belongs to and its scope, so a script can confirm it has the right key before it reads anything:

```bash
curl -H "Authorization: Bearer dbk_your_key" "https://desktop-app.greatwork.company/v1/me"
```

## Never in the URL

Query strings end up in browser history, proxy logs and shared screenshots. If a key arrives in the URL, the API refuses it with `400 key_in_url` and reads nothing. Treat that key as exposed: revoke it and make a new one. This is also why the Power Query recipe doesn't use Power Query's `ApiKeyName` option: Microsoft's documentation shows it adding the key to the URL as a query parameter.

## Revoke a key

Click **Revoke** next to the key on the **API keys** page. Requests with it get `401 invalid_key` from then on. The list shows when each key was last used and how many reads it has made, which helps you find keys nobody uses any more.

## What a key can't do

No key can write to QuickBooks, because Desktop Books has no write endpoints and the `.qwc` file asks QuickBooks for read access only. A key also can't change account settings, see the Web Connector password or invite people; those happen only in the signed-in app.

## Errors you may see

| Status | Code | Meaning |
| --- | --- | --- |
| 401 | `unauthorized` | No key, or the header isn't Bearer or Basic |
| 401 | `invalid_key` | The key is wrong or was revoked |
| 400 | `key_in_url` | The key was sent in the query string |
| 404 | `file_not_found` | The key can't read that company file |

Every code is in [API errors](/docs/errors). Assistants connect with a one-click sign-in instead of a key: see [MCP](/docs/mcp). Next: [Requests and pagination](/docs/requests-and-pagination).

Checked on November 29, 2026 against Microsoft's [Web.Contents reference](https://learn.microsoft.com/en-us/powerquery-m/web-contents).

Previous: [Connect a company file](/docs/connect-a-company-file) | Next: [Requests and pages](/docs/requests-and-pagination)
