Skip to content
typescript
import { Socifyr } from '@socifyr/sdk'

const socifyr = new Socifyr({
  apiKey: 'sk_...',
  workspaceId: '...',
  apiUrl: 'https://api.socifyr.com/api', // optional
  timeout: 30_000, // optional
  maxRetries: 2, // optional
})

Options

OptionTypeDefaultDescription
apiKeystringrequiredAPI key starting with sk_
workspaceIdstringrequiredTarget workspace ID
apiUrlstringhttps://api.socifyr.com/apiOverride for self-hosted or staging
timeoutnumber30000Per-request timeout in ms
maxRetriesnumber2Retry count for transient failures (network errors, 5xx)

Self-hosted / staging

Point apiUrl at any compatible deployment:

typescript
const socifyr = new Socifyr({
  apiKey: '...',
  workspaceId: '...',
  apiUrl: 'http://localhost:8101/api',
})

Retry behavior

The SDK retries automatically on:

  • Network errors (DNS failure, connection refused, timeout)
  • HTTP 429 Too Many Requests
  • HTTP 5xx errors

It does not retry on:

  • 4xx errors except 429 (these are your problem to fix)
  • Successful responses with success: false

Retries use exponential backoff starting at 500ms.

Errors

Failed requests throw SocifyrError, which carries the HTTP status and the API's error message:

typescript
import { SocifyrError } from '@socifyr/sdk'

try {
  await socifyr.uploads.text({ connections: ['fake-slug'], text: 'hi' })
} catch (err) {
  if (err instanceof SocifyrError) {
    console.log(err.status, err.message)
  }
}

See Errors for the full error reference.