Authentication Method
All API endpoints (except/api/configLocale) require HTTP Basic Authentication using your admin username and password.
Basic Authentication
Basic Authentication sends credentials as a Base64-encoded string in theAuthorization header:
username:password before encoding.
Setting Up Credentials
Before using the API, you must configure your admin credentials:- First Time Setup: When you first start Sunshine, you’ll be redirected to the welcome page to create your username and password
- Via Web UI: Navigate to
https://localhost:47990/passwordto update your credentials - Via API: Use the
/api/passwordendpoint (see Configuration endpoints)
credentials.json file in your Sunshine configuration directory.
Making Authenticated Requests
Using curl
The-u flag automatically handles Basic Authentication encoding:
Using Python (requests)
Using JavaScript (fetch)
Using PowerShell
Authentication Flow
Successful Authentication
When authentication succeeds, the API returns the requested data with HTTP 200 status:Failed Authentication
When authentication fails, the API returns HTTP 401 Unauthorized:WWW-Authenticate header prompting for credentials:
No Credentials Set
If no credentials have been configured, requests are redirected to the welcome page:IP-Based Access Control
In addition to username/password authentication, Sunshine enforces IP-based access control. Requests from unauthorized network origins receive HTTP 403 Forbidden:origin_web_ui_allowed configuration setting controls which network interfaces can access the Web UI and API.
Unauthenticated Endpoints
The following endpoint does not require authentication:GET /api/configLocale- Returns the locale setting for the Web UI
Security Considerations
HTTPS Required
The API is only served over HTTPS to protect credentials in transit. Sunshine generates a self-signed certificate on first run.Certificate Verification
When using the API with self-signed certificates, you may need to:- Disable certificate verification in your HTTP client (development only)
- Add the certificate to your system’s trust store (recommended for production)
- Use the
-kor--insecureflag in curl
Password Storage
Passwords are hashed using a cryptographic hash function combined with a random salt before storage. The salt and hash are stored incredentials.json.
Credential Updates
To update credentials, you must provide:- Current username and password (to verify authorization)
- New username (optional, defaults to current)
- New password and confirmation
Example: Complete Request
Here’s a complete example of an authenticated API request:- Uses GET method
- Authenticates with Basic Auth (
-u admin:password) - Sets the Content-Type header
- Skips certificate verification (
-k) - Requests the list of applications

