Developer Guide
Authentication
Authentication methods for SuitePortal API and portal access
Authentication
SuitePortal uses Better Auth for authentication, supporting multiple methods for different use cases.
Authentication Methods
| Method | Use Case | Description |
|---|---|---|
| API Keys | Server-to-server | Bearer token for programmatic API access |
| Social Login | Portal users | Google, GitHub, Microsoft OAuth |
| Email OTP | Portal users | Passwordless one-time code |
| Email + Password | Portal users | Traditional credentials |
API Key Authentication
For programmatic API access, use API keys in the Authorization header.
Header Format
Authorization: Bearer sp-{timestamp}-{hash}Example Request
curl -X GET "https://suiteportal.io/api/v1/invoices" \
-H "Authorization: Bearer sp-1703123456789-abc123def456"API Key Properties
| Property | Description |
|---|---|
| Format | sp-{timestamp}-{hash} |
| Scope | Organization-specific |
| Default expiration | 30 days |
| Rate limiting | Disabled |
Creating API Keys
See API Keys for instructions on creating and managing keys.
Portal Authentication
Portal users (customers, vendors, employees) authenticate via the web interface.
Social Providers
| Provider | Status |
|---|---|
| ✓ Supported | |
| GitHub | ✓ Supported |
| Microsoft | ✓ Supported |
Email OTP
Passwordless login via one-time code sent to email:
- User enters email address
- OTP is sent to email
- User enters OTP to complete login
Email + Password
Traditional email and password authentication is supported.
Session Configuration
| Setting | Value |
|---|---|
| Session duration | 3 days |
| Session update age | 1 day |
| Cookie cache | 5 minutes |
Organization Context
API keys and sessions are scoped to an organization:
| Portal Type | Data Access |
|---|---|
| Tenant | All organization data |
| Customer | Only customer's data (RLS filtered) |
| Vendor | Only vendor's data (RLS filtered) |
The tenantId is automatically derived from the authenticated context—no tenant parameter is required in API requests.
MCP OAuth (Advanced)
For AI/LLM integrations via the Model Context Protocol, OAuth 2.0 is used:
- Register OAuth application
- Complete OAuth authorization flow
- Use access token in MCP requests
OAuth tables required:
oauthApplicationoauthAccessTokenoauthConsent
Security Best Practices
API Keys
- Store keys in environment variables, not code
- Never commit keys to version control
- Use different keys for development and production
- Rotate keys regularly
- Revoke unused keys immediately
Sessions
- Use HTTPS for all requests
- Implement CSRF protection in web forms
- Log out inactive sessions
Error Responses
| Status | Error | Cause |
|---|---|---|
| 401 | API key required | Missing Authorization header |
| 401 | Invalid API key | Key not found or expired |
| 403 | Access denied | User not organization member |
Related
- API Keys - Create and manage API keys
- API Overview - Using the REST API