# Activate browser key

Exchanges a publishable key and origin for a short-lived browser activation token.

Use this from browser integrations before creating jobs. Send the publishable key in the JSON body; the API validates the Origin header against the key's allowed-origins list.

| Method | Path | Authentication | Stability |
| --- | --- | --- | --- |
| POST | /v1/browser/activate | No Authorization header; publishable key in JSON body with allowed Origin | stable |

## Request fields

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| publishable_key | string | Yes | Publishable key shown once in the dashboard. |
| Origin header | string | Yes | Browser origin that must match an allowed origin for the publishable key. |

## Response fields

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| ok | boolean | Yes | True when activation succeeds. |
| activation_token | string | Yes | Short-lived token bound to the project and origin. |
| expires_at_ms | integer | Yes | Unix epoch milliseconds for token expiry. |
| key_id | string | Yes | Activated publishable key identifier. |
| wrapper_tenant_id | string | Yes | Wrapper tenant bound to the token. |
| project_id | string | Yes | Project bound to the token. |

## Errors

| Status | Code | Description |
| --- | --- | --- |
| 401 | unauthorized | Missing or unknown publishable key. |
| 403 | forbidden | Origin is not allowed for this key. |
| 400 | validation_error | publishable_key is missing or malformed, or the Origin header is absent. |

## Response example

```json
{
  "ok": true,
  "activation_token": "wbat_demo_eyJhbGciOi...",
  "expires_at_ms": 1777032600000,
  "key_id": "key_demo_123",
  "wrapper_tenant_id": "wbt_demo_123",
  "project_id": "wbproj_demo_8jK42"
}
```

## cURL

```bash
curl -X POST https://api.wavebird.ai/v1/browser/activate \
  -H "Origin: https://publisher.example" \
  -H "Content-Type: application/json" \
  -d '{
    "publishable_key": "pk_test_wavebird_demo_publishable"
  }'
```

## Node

```javascript
const response = await fetch("https://api.wavebird.ai/v1/browser/activate", {
  method: "POST",
  headers: {
    Origin: "https://publisher.example",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({ publishable_key: "pk_test_wavebird_demo_publishable" })
});

const data = await response.json();
console.log(data);
```

## Python

```python
import json
import urllib.request

request = urllib.request.Request(
    "https://api.wavebird.ai/v1/browser/activate",
    data=json.dumps({"publishable_key": "pk_test_wavebird_demo_publishable"}).encode("utf-8"),
    headers={
        "Origin": "https://publisher.example",
        "Content-Type": "application/json",
    },
    method="POST",
)

with urllib.request.urlopen(request) as response:
    print(response.read().decode("utf-8"))
```
