Key Types Overview
Public Keys
For browsers, mobile apps, and client-side code
Server Keys (sk_)
For backend services, APIs, and server-to-server communication
Public Keys
When to Use
- Browser applications
- Mobile apps (iOS, Android, React Native)
- Client-side JavaScript
- Any code that runs on user devices
Security Features
- Origin validation: Requests are validated against allowed domains
- Restricted permissions: Can only subscribe to channels
- Safe to expose: Designed to be included in client-side code
Example
Server Keys
When to Use
- Backend APIs (Node.js, Python, Go, etc.)
- Serverless functions (AWS Lambda, Vercel, Cloudflare Workers)
- Scheduled jobs and cron tasks
- Webhooks and integrations
- CI/CD pipelines
Security Features
- No origin restrictions: Works from any server environment
- Full permissions: Can publish and subscribe
- Must be kept secret: Should never be exposed in client-side code
Example
Getting Your API Keys
1
Navigate to Console
Go to console.aptly.cloud and select your project
2
View API Keys Section
Scroll to the API Keys section on your project dashboard
3
Copy Keys
- Public Key: Use for client-side applications
- Server Key: Use for server-side applications
Best Practices
For Public Keys
For Server Keys
Common Use Cases
Use Case 1: Web Application
Use Case 2: Mobile App
Use Case 3: Serverless Function
Security Checklist
- Store server keys in environment variables
- Add
.envfiles to.gitignore - Use public keys for all client-side code
- Configure allowed origins for public keys
- Rotate keys if accidentally exposed
- Use different keys for development and production
Key Rotation
If you believe your server key has been compromised:1
Navigate to Console
Go to console.aptly.cloud and select your project
2
Generate New Key
Scroll to the API Keys section on your project dashboard
3
Update Applications
Update all services using the old key