> Check an API key works, see whether it's a live or test key, and get its Key ID and your SDK script URL.

Source: https://plandalf.com/docs/api/organization

API and webhooks

# Organization

One endpoint that tells you who a key belongs to. Call it to check a new key, to see whether it's a test or live key, and to get two values you need elsewhere: the key's ID for signing buyer tokens, and your SDK script URL.

## Example

```bash
curl https://admin.plandalf.dev/api/v1/organization \
  -H "Authorization: Bearer $PLANDALF_API_KEY"
```

```json
{
  "id": 12,
  "name": "Summit Studio",
  "ulid": "01KF0ZR7J3N4Q8T2V6X9Y5B1CD",
  "default_currency": "usd",
  "api_key": { "id": "l0BrqEpKzYI", "mode": "test" },
  "sdk_url": "https://YOUR-ORG.plandalf.dev/js/plandalf-sdk.js"
}
```

-   `api_key.id` is the `kid` for [buyer identity tokens](https://plandalf.com/docs/developers/identify-buyers) signed with this key.
-   `api_key.mode` is `test` or `live`: the events this key's [webhook endpoints](https://plandalf.com/docs/api/webhooks) receive.
-   `sdk_url` is the script tag's `src`. See [The Plandalf SDK](https://plandalf.com/docs/developers/sdk).

## Endpoint

### Retrieve the organization

GET `/api/v1/organization`

The organization the API key or OAuth token belongs to. Use it to check a key works, to learn whether it is a live or test key, and to find the URL of the organization's browser SDK. `api_key.id` is the `kid` header for customer identity JWTs signed with this key; `api_key.mode` is the event mode its webhook endpoints receive. `api_key` is null for OAuth tokens that aren't tied to a key.

```bash
curl https://admin.plandalf.dev/api/v1/organization \
  -H "Authorization: Bearer $PLANDALF_API_KEY"
```

#### Response

```json
{
  "id": 0,
  "name": "string",
  "ulid": "string",
  "default_currency": "string",
  "api_key": {
    "id": "string",
    "mode": "test"
  },
  "sdk_url": "string"
}
```

#### Errors

Status

When

`401`

The API key or OAuth token is missing or invalid.

Something wrong or missing? Email [hello@plandalf.com](mailto:hello@plandalf.com).
