# Authentication

Product Analytics uses public API keys. Use the key for the organization and environment you want to send data to.

## Get an API key

1. Open the **Product Analytics** catalog.
2. Open the **Details** tab.
3. In **Credentials**, copy an existing key, or create one if you manage API keys for the organization.

**Continue in Altertable:** [Open Altertable](/app)

## SDK authentication examples

Initialize your SDK once with the API key for the target environment:

### TypeScript

```typescript
import { altertable } from '@altertable/altertable-js';

altertable.init('{{API_KEY}}');
```

### React

```tsx
import { altertable } from '@altertable/altertable-js';
import { AltertableProvider } from '@altertable/altertable-react';

altertable.init('{{API_KEY}}');

export function App() {
  return (
    <AltertableProvider client={altertable}>
      {/* Your app */}
    </AltertableProvider>
  );
}
```

### Python

```python
from altertable import Altertable

client = Altertable("{{API_KEY}}")
```

### Ruby

```ruby
require 'altertable'

Altertable.init('{{API_KEY}}')
```

### Swift

```swift
import Altertable

let client = Altertable(apiKey: "{{API_KEY}}")
```

### Kotlin

```kotlin
import ai.altertable.sdk.Altertable

Altertable.setup {
    apiKey = "{{API_KEY}}"
}
```

> **SDK environment selection:**
>
> The API key selects the target environment. Use separate keys for staging and production, and omit the `environment` parameter from new integrations. In JavaScript and React SDKs v1.4.0 and later, the deprecated `environment` option is ignored.

## Direct API authentication

For direct HTTP requests, use the same API key as your SDKs. See [API authentication](/docs/api-references/product-analytics.md#authentication) for supported headers and query parameters.

> **Security guidance:**
>
> - API keys are ingestion keys for product events and user identification. They cannot read historical analytics data. Identity requests can update user traits or merge identities.
> - Prefer sending keys in headers. Use the query parameter form only when a header is not practical.

## Next steps

- **[Track events](/docs/product-analytics/track.md)**: Start sending product events
- **[Identify users](/docs/product-analytics/identify.md)**: Set up user identification