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 408, 500, 502, 503, 504

It does not retry on:

  • Other 4xx errors, including 429 (these are your problem to handle)
  • Non-idempotent requests — only GET, HEAD, and OPTIONS are retried, so a POST that times out is never silently re-sent
  • Successful responses with success: false

Retries use exponential backoff with jitter, capped at 10s.

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.