# API Keys

### Creating an API Key

1. Navigate to **Settings → API Keys** in your BraidPay Dashboard.
2. Click **Create API Key**.
3. Choose:
   * **Label**: A human-readable name (e.g. *My Storefront*).
   * **Scope**:
     * `checkout`: create checkout sessions and payment links.
     * `read_only`: view transactions, invoices, balances.
     * `full`: full API access.
   * **Environment**: `test` or `live`.
4. Copy the generated key — you will only see it once.

### Using API Keys

Include your key in the `Authorization` header:

```
POST https://api.braidpay.com/v1/checkout-sessions
Authorization: Bearer sk_test_xxx123
Content-Type: application/json

```

### Rotating & Revoking

* **Rotate**: Creates a new key while the old one remains valid for a short grace period.
* **Revoke**: Immediately disables a key.

## 🚀 Developer Quickstart

### Step 1: Create a Checkout Session

```
curl -X POST https://api.braidpay.com/v1/checkout-sessions \
  -H "Authorization: Bearer sk_test_xxx123" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 5000,
    "currency": "usd",
    "successUrl": "https://merchant.com/success",
    "cancelUrl": "https://merchant.com/cancel"
  }'

```

Response:

```
{
  "id": "cs_test_123",
  "checkoutUrl": "https://checkout.braidpay.com/cs_test_123"
}

```

### Step 2: Redirect Customer

Your webhook will receive events such as `payment.succeeded`:

```
{
  "event": "payment.succeeded",
  "data": {
    "id": "cs_test_123",
    "amount": 5000,
    "currency": "usd",
    "status": "succeeded"
  }
}

```

Verify the signature (see **Webhooks** doc).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.braidpay.com/braidpay/security-and-privacy-settings/api-keys.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
