Skip to main content

Authentication

The SensorUp GraphQL API supports multiple authentication methods depending on your use case and environment.

Authentication Methods

All authentication methods use the same session ID mechanism - either via the sensorup_sessionid cookie (browser) or x-sensorup-sessionid header (API clients).

Session-Based Authentication

Session-based authentication is the primary method for interactive applications where users log in with username and password.

Sign In

Variables:

Session Response

Checking Current Session

Sign Out

Using Your Session

After successful sign-in, your session ID is used to authenticate subsequent API requests. There are two methods: When you sign in through a web browser, the sensorup_sessionid cookie is automatically set and sent with each request:
This happens automatically - you don’t need to manually set this cookie in browser applications.

2. Header Authentication (Machine-to-Machine)

For API clients, mobile apps, and integrations, pass the session ID in the x-sensorup-sessionid header:
Using with HTTP clients:

Multi-Factor Authentication (MFA)

When MFA is required, the sign-in mutation returns a challengeName:

MFA Challenge Response

Challenge Types

Completing MFA Challenge

Variables:

API Key Authentication

API keys are designed for machine-to-machine communication and integration scenarios. API keys generate sessions just like user logins, but with longer lifetimes.

Creating an API Key

Variables:
The response includes an apiKeySessionId which is the session ID you’ll use for authentication.
API keys provide full access to the API with the same permissions as the user who created them. Store them securely and rotate them regularly.

Using API Keys

Use the API key session ID in the x-sensorup-sessionid header (same as regular sessions):
Integration Example:

AWS Credentials

For accessing AWS services (S3, etc.), you can obtain temporary AWS credentials:

Getting AWS Credentials

Response:

Using AWS Credentials

Federated Sign-In (SSO)

For organizations using SSO, you can authenticate with Cognito tokens:
Variables:
SSO configuration is tenant-specific. Contact your SensorUp account team for SSO setup and configuration.

Session Management

Session Expiration

Sessions have two expiration times:
  • Soft Expiry (Idle Timeout): Session extends with activity up to this limit
  • Hard Expiry (Maximum Lifetime): Absolute maximum session duration - requires re-authentication after this time
Session lifetimes vary by client application type: How it works:
  • If you’re actively using the API, your session stays valid until the hard expiry time
  • If you’re inactive for longer than the soft expiry (idle timeout), the session expires
  • After hard expiry, you must sign in again regardless of activity
  • The expiresAt field in the session response reflects the current soft expiry time
  • The expiresAtHard field shows the absolute maximum session lifetime

Switching User Groups

If your user has access to multiple tenant groups:
Variables:

Re-authentication

For sensitive operations, you may need to re-authenticate:
Variables:

Device Management

Track and manage authenticated devices:

Listing Devices

Forgetting Devices

Variables:

Password Management

Forgot Password

Variables:

Reset Password

Variables:

Authentication Configuration

Query authentication configuration for your environment:

Best Practices

  1. Use sessions for interactive applications: Session-based auth with MFA provides the best security for user-facing applications
  2. Use API keys for integrations: Machine-to-machine communication should use API keys with appropriate scoping
  3. Rotate credentials regularly: Implement key rotation policies for long-lived API keys
  4. Handle session expiration gracefully: Check expiresAt and refresh or re-authenticate before expiration
  5. Store credentials securely: Never commit credentials to version control; use environment variables or secret management systems
  6. Monitor authentication events: Track authentication failures and unusual patterns

Next Steps