# API key quickstart

Preview: opening soon. These examples become callable when API keys and an exposed route are enabled. Use the [reference](/docs/api) to choose a route that has opened.

1. Ask the shop owner to turn on **Allow API keys** in Settings, Developers. A person with **Can create API keys** opens **Settings, Developers, API keys** and chooses **Create**.
2. Name the key, select only the areas needed, choose an expiry, and complete the email code or passkey check. The key appears once. Save it in your server's secret store.
3. Find an open `GET /v1/shops/{organization_id}/...` route in the [reference](/docs/api). Replace the path placeholder below with that exact route and replace the organization ID with the key's shop ID. A key for another shop returns 404.

Set `OG_KEY` to the real key in your server environment. `og_live_YOUR_KEY` below is a placeholder. Run the command in a private shell, since pasted keys can enter shell history. The example path is a template, not a published endpoint.

```bash
: "${OG_KEY:?Set OG_KEY to your key first}"
SHOP_ID='00000000-0000-4000-8000-000000000001'
OPEN_ROUTE='...'
curl -i -H "Authorization: Bearer ${OG_KEY}" "https://api.outdoorgrid.ai/v1/shops/${SHOP_ID}/${OPEN_ROUTE}"
```

Save the following as `first-call.mjs` and run `node first-call.mjs` with Node 20 or newer:

```js
const key = process.env.OG_KEY ?? "og_live_YOUR_KEY";
const shopId = "00000000-0000-4000-8000-000000000001";
const openRoute = "...";
const response = await fetch(`https://api.outdoorgrid.ai/v1/shops/${shopId}/${openRoute}`, {
  headers: { Authorization: `Bearer ${key}` },
});
const body = await response.json();
console.log(response.status, body);
```

Install httpx with `python3 -m pip install httpx`, save the following as `first_call.py`, then run `python3 first_call.py`:

```python
import os
import httpx

key = os.environ.get("OG_KEY", "og_live_YOUR_KEY")
shop_id = "00000000-0000-4000-8000-000000000001"
open_route = "..."
url = f"https://api.outdoorgrid.ai/v1/shops/{shop_id}/{open_route}"
with httpx.Client(timeout=10) as client:
    response = client.get(url, headers={"Authorization": f"Bearer {key}"})
    print(response.status_code, response.json())
```

A successful response is JSON for that route. Check its field descriptions and paging rules in the reference. A non-success response may be an [API problem](/docs/api-keys/errors). A 404 can mean the route is not open, the shop does not match the key, or the record is unavailable.
