CloudSignal Docs
GuidesAPI Keys

Key types

Understanding publishable and secret API keys in CloudSignal.

CloudSignal uses two types of API keys to support different security requirements: publishable keys and secret keys.

Publishable keys (pk_)

Publishable keys are designed to be safe for use in client-side code.

Characteristics

AspectDetail
Prefixpk_ (for example pk_live_abc123...)
VisibilitySafe to expose in browsers, mobile apps, public repos
PermissionsLimited to read-only and public operations
Use caseClient-side API calls

What publishable keys can do

OperationAllowed
REST bridge publish (with ACL)Yes
Read public organization infoYes
Token exchange (with auth provider)Yes
Create or delete clientsNo
Modify ACL rulesNo
Access billingNo

Example usage

// Safe to use in browser code
const CLOUDSIGNAL_PK = 'pk_live_abc123xyz';

// REST bridge - publish with client permissions
await fetch('https://rest-publisher.cloudsignal.app/publish', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${CLOUDSIGNAL_PK}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    topic: 'agents/agent-01/state',
    payload: { status: 'idle' },
  }),
});

Even though publishable keys are safe to expose, ACL rules still apply. A publishable key can only access topics the associated user has permission for.

Secret keys (sk_)

Secret keys provide full access to your CloudSignal organization.

Characteristics

AspectDetail
Prefixsk_ (for example sk_live_def456...)
VisibilityNever expose. Server-side only.
PermissionsFull access to all API operations
Use caseServer-side automation, admin tasks

What secret keys can do

OperationAllowed
All publishable key operationsYes
Create or delete clientsYes
Modify ACL rulesYes
Manage auth providersYes
Token exchange (server-side)Yes
Access organization settingsYes

Example usage

// Server-side only - never expose this key
const CLOUDSIGNAL_SK = process.env.CLOUDSIGNAL_SECRET_KEY;

// Create a new MQTT client programmatically
const response = await fetch('https://api.cloudsignal.io/v2/clients', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${CLOUDSIGNAL_SK}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    username: 'agent-001',
    password: generateSecurePassword(),
  }),
});

Security critical: secret keys should only exist in server-side code, environment variables, or secure secret managers. Never commit them to version control or expose in client-side code.

Choosing the right key

Pick by where the code runs:

  • If your code runs in a browser or mobile app, use a publishable key (pk_).
  • If your code runs server-side (Node.js, Python, Go, automation, CI/CD), use a secret key (sk_).

Common scenarios

ScenarioKey typeReason
React app publishing eventspk_Client-side, limited scope
Node.js backend creating clientssk_Server-side, admin operation
Mobile app token exchangepk_Client-side, user-scoped
CI/CD pipeline managing ACLssk_Automation, admin operation
Browser-based dashboardpk_Client-side, user context
Webhook handlersk_Server-side, system operation

Security best practices

For publishable keys

PracticeWhy
Use ACL rulesLimit which topics the key can access
Scope to user contextPair with user authentication
Rate limitImplement client-side rate limiting
Monitor usageWatch for unusual patterns

For secret keys

PracticeWhy
Environment variablesStore in process.env, not code
Secret managersUse AWS Secrets Manager, HashiCorp Vault, and similar tools
Rotate regularlyChange keys every 90 days
Minimal exposureOnly give access to services that need it
Audit logsMonitor API usage for anomalies

Environment variable example

# .env file (never commit this)
CLOUDSIGNAL_PK=pk_live_abc123xyz
CLOUDSIGNAL_SK=sk_live_def456uvw

# Access in code
const publishableKey = process.env.CLOUDSIGNAL_PK;
const secretKey = process.env.CLOUDSIGNAL_SK;

Key identification

You can identify key types by their prefix:

pk_live_abc123xyz...  -> Publishable (live/production)
pk_test_abc123xyz...  -> Publishable (test/development)
sk_live_def456uvw...  -> Secret (live/production)
sk_test_def456uvw...  -> Secret (test/development)

Test keys (_test_) work with test or sandbox environments and won't affect production data.


Next steps

On this page