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
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | required | API key starting with sk_ |
workspaceId | string | required | Target workspace ID |
apiUrl | string | https://api.socifyr.com/api | Override for self-hosted or staging |
timeout | number | 30000 | Per-request timeout in ms |
maxRetries | number | 2 | Retry 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
5xxerrors
It does not retry on:
4xxerrors except429(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.