> ## Documentation Index
> Fetch the complete documentation index at: https://docs.maqetin.com/llms.txt
> Use this file to discover all available pages before exploring further.

# API keys

> Public keys for your web page or app, secret keys with scopes for your server, who can make each, and how to revoke one.

A public key goes in your web page or app and only sends events. A secret key stays on your server and does what its scopes allow.

| Kind | Starts with | Console label | Goes in | Does |
| - | - | - | - | - |
| Public key | `mq_live_` | **Publishable** | Your web page, your app, the JavaScript SDK's `publicKey` | Sends events to `https://in.maqetin.com` and nothing else. No scopes |
| Secret key | `mq_sec_` | **Secret** | Your server only | What its scopes say, on `https://api.maqetin.com` and, with `events:write`, the event API |

Admins and the owner see the key list and make or revoke public keys. Only the owner makes or revokes secret keys; an admin sees them in the list but cannot. A member sees the **Event names** and **Trait keys** tabs under **Developers**, and asks the owner for a key. See [Members and roles](https://docs.maqetin.com/workspace/members-and-roles.md).

## Make a key

**1. Open the key list**

Open **Developers**. The **API keys** tab opens.

**2. Start a new key**

Choose **Create key**, or **Create publishable key** in a workspace with no key yet.

**3. Name it and pick its kind**

Enter a **Name** of 1 to 100 characters; your team sees it, your app never does. Under **Kind**, pick **Publishable** or **Secret** (owner only).

**4. Pick the scopes of a secret key**

Tick its **Scopes**. See [Scopes](#scopes).

**5. Create it**

Choose **Create key**. The console shows the key and how to use it.

> [!WARNING]
>
> Maqetin shows a secret key once. Copy it and store it on your server before you choose **I have stored it**; afterwards the list shows only its first characters. Never put a secret key in a web page or a mobile app. A public key stays in the list in full, so you can copy it again at any time.

A workspace holds at most 10 active keys of each kind: 10 public and 10 secret. A revoked key does not count, so revoke one to make another.

## Scopes

You choose a secret key's scopes when you make it, and they never change. On `api.maqetin.com`, a call the key has no scope for gets `403`. On `/v1/batch`, a secret key without `events:write` gets `401`.

| Scope | Lets the key |
| - | - |
| `contacts:read` | List, read and export contacts and their messages. Ticked by default |
| `contacts:delete` | Erase a contact |
| `messages:send` | Send transactional messages, for example with `messages.send` in the [JavaScript SDK](https://docs.maqetin.com/sdk/javascript.md#send-email-from-your-server). Ticked by default |
| `events:write` | Send events to the event API from your server. See [Batch](https://docs.maqetin.com/api-reference/batch.md) |

A secret key made with no scope ticked can only read contacts.

## The key list

The **API keys** tab lists every key, revoked ones included, with its **Name**, **Kind**, **Key**, **Scopes**, **Created**, **Last used** and **Status**.

**Last used** is when Maqetin last accepted the key, to the minute; it moves at most once a minute, so it can lag by one. An unused key shows **Never**. Only calls to `api.maqetin.com` move it, so a secret key that only sends events to `/v1/batch` keeps showing **Never**.

## Revoke a key

Choose **Revoke** on the key's row and confirm with **Revoke key**. Revoking works at once:

| Kind | After revoking |
| - | - |
| Public key | The event API refuses it. Every event sent with it gets a `401` and is dropped |
| Secret key | The API refuses it. Every request gets a `401`, and with `events:write`, every event sent with it is dropped |

> [!WARNING]
>
> A revoked key cannot be turned back on. Make its replacement and deploy it before you revoke the old key.

Deleting a workspace stops its keys too. See [Delete a workspace](https://docs.maqetin.com/workspace/workspaces.md#delete-a-workspace).


## Related topics

- [API reference](https://docs.maqetin.com/api-reference/introduction.md)
- [Contacts](https://docs.maqetin.com/api-reference/contacts.md)
- [JavaScript SDK](https://docs.maqetin.com/sdk/javascript.md)
- [Send a message](https://docs.maqetin.com/api-reference/send-message.md)


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