# How to Get an API Key

> A simple guide to finding, copying, generating, and regenerating your X02 API key for developer scripts, bots, and ShareX integrations.

Source: https://x02.me/blog/how-to-get-an-api-key · 2026-09-01 · X02 Team

An **API Key** is a unique secret token that identifies your X02 account when uploading files outside of your web browser. You need an API key if you want to:
* Connect desktop screenshot utilities like **ShareX** or **Flameshot**.
* Automate uploads from a shell script, cron job, or CI pipeline with `curl`.
* Write automated scripts in Python, Node.js, Go, or Bash.
* Integrate build artifact uploads into GitHub Actions or GitLab CI/CD.

This guide covers how to get your API key from the dashboard, how to generate one programmatically, and how to use it securely.

> [!TIP]
> **Quick Navigation:**
> * [Getting Your API Key from the Dashboard](#part-1-the-easy-guide-for-everyone)
> * [How to Regenerate a Compromised Key](#how-to-regenerate-your-api-key)
> * [Authenticating API Requests (cURL, JS, Python)](#part-2-the-developer--power-user-guide)
> * [Programmatic Key Generation Endpoint](#2-generating-a-key-programmatically-via-api)
> * [Folder-Specific API Keys](#3-generating-folder-specific-api-keys)
> * [Security Best Practices](#security-best-practices)
> * [Next Steps & Related Tutorials](#next-steps--related-tutorials)

---

## Part 1: The Easy Guide (For Everyone)

Every registered X02 user automatically gets a personal API key. You can find and copy it in less than 10 seconds.

![Architecture Diagram](/blog-diagrams/how-to-get-an-api-key-1.svg)

### Step-by-Step: Copying Your API Key

| Where to Go | Direct Link | Action |
| :--- | :--- | :--- |
| **`Dashboard`**  **`Settings`**  **`API Keys`** | [Open Dashboard Settings](https://x02.me/dashboard) | Click **Copy API Key** |

1. **Log in** to your account at **[x02.me](https://x02.me)**.
2. Open your **Dashboard** and navigate to **Settings**.
3. Scroll to the **API Keys** section.
4. Click the **Copy** button next to your key.

Your API key is now copied to your clipboard and ready to paste into ShareX or your custom scripts.

---

### How to Regenerate Your API Key

If you accidentally exposed your API key on a public GitHub repository or livestream, you should regenerate it immediately:

1. Go to **Dashboard**  **Settings**  **API Keys**.
2. Click **Regenerate API Key**.
3. Confirm the prompt.

> [!IMPORTANT]
> Regenerating your API key immediately invalidates the old key. Be sure to update your ShareX profile, `.env` files, and CI/CD secrets with your new token.

---

## Part 2: The Developer & Power User Guide

---

### 1. Using Your API Key in HTTP Requests

To authenticate requests to the X02 API, provide your key in the `x-api-key` header (or as a `Bearer` token in the `Authorization` header):

#### cURL Example:
```bash
curl -X POST "https://x02.me/api/upload" \
  -H "x-api-key: YOUR_X02_API_KEY" \
  -F "file=@screenshot.png"
```

#### Node.js / TypeScript Example:
```typescript
const response = await fetch("https://x02.me/api/upload", {
  method: "POST",
  headers: {
    "x-api-key": process.env.X02_API_KEY!,
    "Accept": "application/json",
  },
  body: formData,
});
```

#### Python Example:
```python
import os
import requests

headers = {
    "x-api-key": os.getenv("X02_API_KEY"),
    "Accept": "application/json"
}

with open("report.pdf", "rb") as f:
    response = requests.post("https://x02.me/api/upload", headers=headers, files={"file": f})

print(response.json())
```

---

### 2. Generating a Key Programmatically via API

If you are building an automated provisioning tool, you can request an API key programmatically:

```bash
curl -X POST "https://x02.me/api/keys/generate"
```

#### JSON Response:
```json
{
  "success": true,
  "data": {
    "apiKey": "x02_k928fa8bc910283...",
    "limits": {
      "dailyLimit": 50,
      "hourlyLimit": 20
    }
  }
}
```

---

### 3. Generating Folder-Specific API Keys

If you want an API key that automatically routes all uploaded files into a specific folder:

```bash
curl -X POST "https://x02.me/api/user/folders/FOLDER_ID/key" \
  -H "x-api-key: YOUR_PRIMARY_API_KEY"
```

Any upload sent with this key will land straight inside the designated folder without requiring extra folder parameters.

---

## Security Best Practices

| Rule | Why It Matters |
|---|---|
| **Never commit keys to Git** | Use `.env` files and add `.env` to your `.gitignore` to prevent secret leaks. |
| **Use GitHub Secrets in CI/CD** | Add your key under **Repository Settings**  **Secrets and variables**  **Actions** as `X02_API_KEY`. |
| **Regenerate Leaked Keys Immediately** | If a key is exposed publicly, click Regenerate in your dashboard to revoke access instantly. |

---

## Next Steps & Related Tutorials

| What to learn next | Guide Link |
| :--- | :--- |
| **Use your API key to connect ShareX** | [How to Integrate ShareX with X02 ](/blog/how-to-integrate-sharex-with-x02) |
| **Upload files using cURL, the REST API, or MCP** | [How to Upload Files to X02 ](/blog/how-to-upload-files-to-x02) |
| **Create dedicated upload keys for folders** | [How to Organize Files with Folders ](/blog/how-to-organize-files-with-folders) |
| **Swap uploaded files via API** | [How to Replace a File Without Changing Its Link ](/blog/how-to-replace-file-without-changing-link) |
