# Create an API key
Create an API key in Settings, choose what it can read and change, set when it expires, and edit or revoke it later.
An API key lets your own code or another app read and change your store through the Crate API. You create keys on the **API keys** page in **Settings**, and each key has its own permissions and expiry date.
API keys are included on every plan. Only the store owner and teammates who can manage settings can create them.
> [!IMPORTANT]
> Confirm your email address before you create a key. Until you do, Crate refuses with "Confirm your email address first, we sent a link to …". Check your spam folder or use **Resend confirmation email** in the banner.
## Step 1: Open API keys
1. In your dashboard, open **Settings**.
2. Under **Developer**, choose **API keys**.
A store with no keys shows **No API keys found**.
```screenshot developers/create-an-api-key/01-api-keys-empty
alt: The API keys page in Settings with the empty state "No API keys found" and the Create API key button
caption: The API keys page sits under Developer in Settings.
```
## Step 2: Name the key and choose permissions
1. Click **Create API key**. The **Create new API key** window opens.
2. Enter a **Name** that says what the key is for, such as "Inventory sync". The name can be up to 120 characters.
3. Under **Permissions**, choose one option:
   - **All**: full access to all resources.
   - **Read Only**: read-only access to all resources. The key can look but not change anything.
   - **Restricted**: you choose **Read** or **Write** for each resource group.
```screenshot developers/create-an-api-key/02-create-dialog
alt: The Create new API key window with the Name field, the All, Read Only and Restricted permission options, and the Expiration menu
caption: All is selected when the window opens.
```
### Choose Restricted permissions
With **Restricted**, a list of resource groups appears. Tick **Read** to let the key look at a group, or **Write** to let it create, change and delete. **Write** includes **Read** for the same group.
| Group | Covers |
| --- | --- |
| **Products** | Products, variants and collections |
| **Orders** | Orders and abandoned carts |
| **Customers** | Customers and customer groups |
| **Discounts** | Discounts and coupon codes |
| **Marketing** | Email campaigns and automations |
| **Analytics** | Sales figures and reports |
| **Subscriptions** | Subscriptions and subscription plans |
| **Apps** | Webhook endpoints |
| **Licenses** | License keys |
Hover the question mark next to a group to see everything it covers.
```screenshot developers/create-an-api-key/03-restricted
alt: The Create new API key window with Restricted selected, showing one row per resource group with Read and Write checkboxes
caption: Restricted lets you pick Read or Write for each group.
```
> [!TIP]
> Give each key the least access it needs. A reporting tool needs **Read Only**, not **All**.
## Step 3: Set the expiry
Choose an **Expiration**: **Never**, **30 days**, **90 days**, **1 year** or **Custom date**.
With **Custom date**, pick a day from tomorrow up to five years ahead. The key stops working at the end of that day.
## Step 4: Create and copy the key
1. Click **Create API key**.
2. The **API key created** window shows the key once. Click **Copy**.
3. Paste the key into your app's secret settings or a password manager.
4. Click **Done**.
Keys start with `crate_pat_`. Crate also emails the store owner that a key was created.
```screenshot developers/create-an-api-key/04-key-created
alt: The API key created window with the new key shown once, a Copy button and a Done button; the key is blurred
caption: Copy the key now. You won't see it again.
```
> [!WARNING]
> Treat a key like a password. Keep it on your server. Never put it in a web page, a mobile app or a public code repository.
## Manage your keys
The **API keys** page lists every key with its **Name**, **Permissions**, **Created** date, the first characters of the **Key**, and when it was **Last used**. A key that was never used shows **Never**.
A badge next to the key shows its expiry. It reads **Expires in 12 days**, for example, and turns amber in the last 7 days. An expired key shows **Expired**, and a revoked key shows **Revoked**.
```screenshot developers/create-an-api-key/05-keys-list
alt: The API keys table with one key, showing its name, permissions, created date, key prefix with an expiry badge, last used time and the row menu
caption: Each row shows what the key can do and when it was last used.
```
### Edit a key
1. Open the key's menu and choose **Edit**.
2. Change the **Name** or the **Permissions**.
3. Click **Save changes**.
The key keeps working with its new permissions. You can't change its expiry or see the key again. When you change permissions, Crate emails the store owner.
### Revoke a key
1. Open the key's menu and choose **Revoke**.
2. Type **confirm revoke key** in the box.
3. Click **Revoke**.
The key stops working straight away. If the key was used recently, the window warns "This key is actively in use" first, because any app that uses it will break.
```screenshot developers/create-an-api-key/06-revoke-dialog
alt: The Revoke API key window with the key name and prefix, the warning for a key in use, and the box to type confirm revoke key
caption: Type the phrase to confirm. Revoking can't be undone.
```
### Replace a key
To rotate a key, create a new one with the same permissions. Update your app to use it, then revoke the old key.
## Troubleshooting
- **"Pick at least one permission for the key."** You chose **Restricted** but left every box empty. Tick at least one **Read** or **Write**.
- **"The expiry date must be in the future."** A custom date must be tomorrow or later.
- **"The expiry date can be at most 5 years away."** Pick an earlier custom date.
- **I closed the window before copying the key.** Crate can't show it again. Revoke the key and create a new one.
- **I don't see API keys in Settings.** Ask the store owner for permission to manage settings.
