API Reference

SDK

Complete 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

auth.login(input: LoginInput): Promise<TokenResponse>

Parameters

emailstringUser email address
passwordstringUser 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

auth.signup(input: SignupInput): Promise<TokenResponse>

Parameters

emailstringUser email address
passwordstringUser password (min 8 chars)
namestring?User display name

Returns

TokenResponse with accessToken and refreshToken

auth.logout()

Revoke the current session

auth.logout(): Promise<SuccessResponse>

Returns

{ success: true }

auth.refreshToken()

Get a new access token using refresh token

auth.refreshToken(refreshToken: string): Promise<TokenResponse>

auth.verifyEmail()

Verify email with token from verification email

auth.verifyEmail(token: string): Promise<SuccessResponse>

auth.requestPasswordReset()

Send password reset email to user

auth.requestPasswordReset(email: string): Promise<SuccessResponse>

auth.resetPassword()

Reset password using token from reset email

auth.resetPassword(input: ResetPasswordInput): Promise<SuccessResponse>

platform.billing

Subscription and payment management via Stripe

billing.getPlans()

Get all available subscription plans

billing.getPlans(): Promise<Plan[]>

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

billing.getSubscription(userId: string): Promise<Subscription | null>

Returns

Current subscription or null if none

billing.createCheckout()

Create Stripe checkout session

billing.createCheckout(input: CheckoutInput): Promise<{ url: string }>

Parameters

planIdstringID of plan to subscribe to
successUrlstringRedirect URL after success
cancelUrlstringRedirect URL if cancelled

Returns

Object with Stripe checkout URL

billing.createPortalSession()

Create Stripe billing portal session

billing.createPortalSession(returnUrl: string): Promise<{ url: string }>

Returns

Object with Stripe portal URL

billing.cancelSubscription()

Cancel user's subscription at period end

billing.cancelSubscription(): Promise<Subscription>

platform.analytics

Event tracking and user analytics

analytics.track()

Track a custom event

analytics.track(input: TrackEventInput): Promise<SuccessResponse>

Parameters

eventstringEvent name (e.g., "purchase_completed")
userIdstring?User ID (optional for anonymous)
propertiesobject?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

analytics.identify(input: IdentifyInput): Promise<SuccessResponse>

Parameters

userIdstringUser ID to identify
traitsobjectUser traits (name, email, plan, etc.)

analytics.pageview()

Track a page view

analytics.pageview(input: PageviewInput): Promise<SuccessResponse>

Parameters

pathstringPage path
titlestring?Page title
referrerstring?Referrer URL

platform.ai

AI services including chat, embeddings, and image generation

ai.chat()

Generate chat completion

ai.chat(input: ChatCompletionInput): Promise<ChatCompletionResponse>

Parameters

modelstringModel ID (gpt-4, claude-3-opus, etc.)
messagesAIMessage[]Conversation messages
temperaturenumber?Sampling temperature (0-2)
maxTokensnumber?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

ai.embed(input: EmbeddingInput): Promise<EmbeddingResponse>

Parameters

modelstringEmbedding model ID
inputstring | string[]Text to embed

Returns

Array of embedding vectors

ai.generateImage()

Generate images from text

ai.generateImage(input: ImageGenerationInput): Promise<ImageGenerationResponse>

Parameters

modelstringImage model (dall-e-3, sdxl, etc.)
promptstringImage description
sizestring?Image size (1024x1024, etc.)

ai.getUsage()

Get AI usage statistics

ai.getUsage(days?: number): Promise<AIUsageStats>

Returns

Usage stats including tokens and cost

platform.storage

File upload and management

storage.upload()

Upload a file

storage.upload(input: UploadFileInput): Promise<UploadedFile>

Parameters

fileFile | BlobFile to upload
pathstring?Storage path
publicboolean?Make file publicly accessible

Returns

UploadedFile with URL and metadata

storage.delete()

Delete a file

storage.delete(fileId: string): Promise<SuccessResponse>

storage.list()

List uploaded files

storage.list(options?: ListOptions): Promise<UploadedFile[]>

platform.monitoring

Error capture and tracking

monitoring.captureException()

Capture an error/exception

monitoring.captureException(input: CaptureExceptionInput): Promise<{ id: string }>

Parameters

errorError | stringError to capture
contextobject?Additional context
userIdstring?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

monitoring.captureMessage(input: CaptureMessageInput): Promise<{ id: string }>

Parameters

messagestringMessage to capture
levelstring?Severity: info, warning, error

platform.jobs

Background job scheduling

jobs.schedule()

Schedule a background job

jobs.schedule(input: ScheduleJobInput): Promise<{ jobId: string }>

Parameters

urlstringWebhook URL to call
bodyobject?Request body
delaynumber?Delay in seconds
cronstring?Cron expression for recurring

jobs.cancel()

Cancel a scheduled job

jobs.cancel(jobId: string): Promise<SuccessResponse>

platform.privacy

GDPR/CCPA consent management

privacy.getConsentTypes()

Get configured consent types

privacy.getConsentTypes(): Promise<ConsentType[]>

privacy.getUserConsents()

Get user's consent choices

privacy.getUserConsents(userId: string): Promise<UserConsent[]>

privacy.setConsents()

Update user's consent choices

privacy.setConsents(input: SetConsentsInput): Promise<{ consents: UserConsent[] }>

privacy.acceptAll()

Accept all consent types

privacy.acceptAll(userId: string): Promise<{ consents: UserConsent[] }>

privacy.declineOptional()

Decline all optional consents

privacy.declineOptional(userId: string): Promise<{ consents: UserConsent[] }>

platform.notifications

Web push notifications

notifications.getPublicKey()

Get VAPID public key for subscription

notifications.getPublicKey(): Promise<{ publicKey: string }>

notifications.register()

Register a push subscription

notifications.register(subscription: PushSubscription): Promise<SuccessResponse>

notifications.unregister()

Remove a push subscription

notifications.unregister(endpoint: string): Promise<SuccessResponse>

platform.referrals

Referral program management

referrals.getMyCode()

Get user's referral code

referrals.getMyCode(): Promise<{ code: string; status: string }>

referrals.redeem()

Redeem a referral code

referrals.redeem(code: string): Promise<ReferralResult>

referrals.getStats()

Get user's referral statistics

referrals.getStats(): Promise<ReferralStats>