Authentication methods
JWT bearer token
The primary authentication method uses JWT tokens obtained from PocketBase user authentication. This is the recommended method for production applications. Obtain a token:Query parameter token
For scenarios where setting headers is difficult, you can pass the JWT token as a query parameter:API key
API keys are useful for development, testing, and service-to-service communication. Use theX-API-Key header:
JOYSTICK_API_KEY environment variable:
Security schemes
The API supports two OpenAPI security schemes:Bearer token authentication using JWT from PocketBaseFormat:
Bearer <token>API key authentication for development and service-to-service communicationDefault development key:
dev-api-key-12345Access control
Device access
Users can only control devices they have explicit access to. Device access is managed through theallow field in the devices collection, which contains an array of authorized user IDs.
Permission-based access
Certain endpoints require specific feature-based permissions:- device-cpsi - Access to CPSI sensor data
- device-battery - Access to battery sensor data
- device-gps - Access to GPS sensor data
- device-imu - Access to IMU sensor data
- notifications - Ability to send notifications
Error responses
401 Unauthorized
Returned when no valid authentication credentials are provided:403 Forbidden - Missing permissions
Returned when the authenticated user lacks required permissions:403 Forbidden - Device access denied
Returned when the user doesn’t have access to the specified device:Public endpoints
The following endpoints do not require authentication:GET /- API welcome messageGET /api/health- Service health checkGET /swagger- Interactive API documentation