API Reference
SDKComplete reference for all Sylphx Platform SDK methods.
10 Services
Full-stack coverage
50+ Methods
Everything you need
TypeScript
Full type safety
Examples
Copy-paste ready
platform.auth
Authentication methods for user login, signup, and session management
auth.login()
Authenticate a user with email and password
Parameters
| string | User email address | |
| password | string | User password |
Returns
TokenResponse with accessToken and refreshToken
Example
const result = await platform.auth.login({
email: 'user@example.com',
password: 'password123',
})auth.signup()
Register a new user account
Parameters
| string | User email address | |
| password | string | User password (min 8 chars) |
| name | string? | User display name |
Returns
TokenResponse with accessToken and refreshToken
auth.logout()
Revoke the current session
Returns
{ success: true }
auth.refreshToken()
Get a new access token using refresh token
auth.verifyEmail()
Verify email with token from verification email
auth.requestPasswordReset()
Send password reset email to user
auth.resetPassword()
Reset password using token from reset email
platform.billing
Subscription and payment management via Stripe
billing.getPlans()
Get all available subscription plans
Returns
Array of Plan objects with pricing details
Example
const plans = await platform.billing.getPlans()
// [{ id, name, price, interval, features, ... }]billing.getSubscription()
Get user's current subscription
Returns
Current subscription or null if none
billing.createCheckout()
Create Stripe checkout session
Parameters
| planId | string | ID of plan to subscribe to |
| successUrl | string | Redirect URL after success |
| cancelUrl | string | Redirect URL if cancelled |
Returns
Object with Stripe checkout URL
billing.createPortalSession()
Create Stripe billing portal session
Returns
Object with Stripe portal URL
billing.cancelSubscription()
Cancel user's subscription at period end
platform.analytics
Event tracking and user analytics
analytics.track()
Track a custom event
Parameters
| event | string | Event name (e.g., "purchase_completed") |
| userId | string? | User ID (optional for anonymous) |
| properties | object? | Custom event properties |
Example
await platform.analytics.track({
event: 'button_clicked',
userId: user.id,
properties: { buttonId: 'cta-hero' },
})analytics.identify()
Associate traits with a user
Parameters
| userId | string | User ID to identify |
| traits | object | User traits (name, email, plan, etc.) |
analytics.pageview()
Track a page view
Parameters
| path | string | Page path |
| title | string? | Page title |
| referrer | string? | Referrer URL |
platform.ai
AI services including chat, embeddings, and image generation
ai.chat()
Generate chat completion
Parameters
| model | string | Model ID (gpt-4, claude-3-opus, etc.) |
| messages | AIMessage[] | Conversation messages |
| temperature | number? | Sampling temperature (0-2) |
| maxTokens | number? | Max tokens to generate |
Example
const response = await platform.ai.chat({
model: 'gpt-4',
messages: [
{ role: 'system', content: 'You are helpful.' },
{ role: 'user', content: 'Hello!' },
],
})
console.log(response.message.content)ai.embed()
Generate text embeddings
Parameters
| model | string | Embedding model ID |
| input | string | string[] | Text to embed |
Returns
Array of embedding vectors
ai.generateImage()
Generate images from text
Parameters
| model | string | Image model (dall-e-3, sdxl, etc.) |
| prompt | string | Image description |
| size | string? | Image size (1024x1024, etc.) |
ai.getUsage()
Get AI usage statistics
Returns
Usage stats including tokens and cost
platform.storage
File upload and management
storage.upload()
Upload a file
Parameters
| file | File | Blob | File to upload |
| path | string? | Storage path |
| public | boolean? | Make file publicly accessible |
Returns
UploadedFile with URL and metadata
storage.delete()
Delete a file
storage.list()
List uploaded files
platform.monitoring
Error capture and tracking
monitoring.captureException()
Capture an error/exception
Parameters
| error | Error | string | Error to capture |
| context | object? | Additional context |
| userId | string? | User who experienced error |
Example
try {
await riskyOperation()
} catch (error) {
await platform.monitoring.captureException({
error,
context: { operation: 'checkout' },
userId: user.id,
})
}monitoring.captureMessage()
Capture a message/warning
Parameters
| message | string | Message to capture |
| level | string? | Severity: info, warning, error |
platform.jobs
Background job scheduling
jobs.schedule()
Schedule a background job
Parameters
| url | string | Webhook URL to call |
| body | object? | Request body |
| delay | number? | Delay in seconds |
| cron | string? | Cron expression for recurring |
jobs.cancel()
Cancel a scheduled job
platform.consent
GDPR/CCPA consent management
consent.getConsentTypes()
Get configured consent types
consent.getUserConsents()
Get user's consent choices
consent.setConsents()
Update user's consent choices
consent.acceptAll()
Accept all consent types
consent.declineOptional()
Decline all optional consents
platform.notifications
Web push notifications
notifications.getPublicKey()
Get VAPID public key for subscription
notifications.register()
Register a push subscription
notifications.unregister()
Remove a push subscription
platform.referrals
Referral program management
referrals.getMyCode()
Get user's referral code
referrals.redeem()
Redeem a referral code
referrals.getStats()
Get user's referral statistics