Skip to content

TypeScript SDK method reference ​

Every public method of @socifyr/sdk 0.1.0, grouped by resource, with its signature and the REST call behind it. Each call unwraps { success, data } and returns data. Void methods resolve to undefined (an HTTP 204 returns undefined).

typescript
import { Socifyr } from '@socifyr/sdk'
const socifyr = new Socifyr({ apiKey: process.env.SOCIFYR_API_KEY!, workspaceId: process.env.SOCIFYR_WORKSPACE_ID! })

Client ​

MemberSignatureCalls
constructornew Socifyr(config: SocifyrConfig)none. Throws Error if apiKey or workspaceId is empty
healthhealth(): Promise<HealthStatus>GET /health

HealthStatus is { status: 'ok' | 'degraded' | 'down', services: Record<string, 'ok' | 'down'> }.

How do I call the uploads methods? ​

Create methods ​

MethodSignatureCalls
videovideo(params: UploadVideoParams): Promise<Upload>POST /content/video
photosphotos(params: UploadPhotosParams): Promise<Upload>POST /content/photos
texttext(params: UploadTextParams): Promise<Upload>POST /content/text
documentdocument(params: UploadDocumentParams): Promise<Upload>POST /content/document
bulkSchedulebulkSchedule(params: BulkScheduleParams): Promise<BulkScheduleResult>POST /content/bulk-schedule

video, photos and document take medias entries as a Buffer, a Blob, a media library ID (24-char hex or starting with media_), or a public http(s) URL. A Buffer or Blob is first uploaded to POST /media/upload, and its ID is sent. A string that is neither an ID nor a URL is uploaded as file bytes, which is almost never what you want, so pass IDs or URLs as strings.

Shared fields (UploadOptions):

FieldTypeRequiredNotes
connectionsstring[]yesConnection slugs, for example instagram-mybrand
titlestringno
descriptionstringno
textstringnoCaption or body. Required for text() (1 to 25000 chars per the type comment)
scheduledAtstringnoISO-8601
timezonestringnoIANA name, for example America/New_York
firstCommentFirstComment | stringno{ text?, linkUrl?, imageUrl? }
linkUrlstringno
asyncbooleannoReturn requestId only; poll for status
saveDraftbooleannoSave a draft instead of publishing
contentFormatstringnoHint such as short_video, story, photo_carousel
platformOptionsRecord<string, ConnectionOptions>noKeys: connection slug, ObjectId or platform name

bulkSchedule takes { rows?: BulkScheduleRow[], csv?: string }. Provide one. Row: { text: string, connections: string[] | string, scheduledAt: string, title?: string }. CSV header: text,connections,scheduledAt,title. Returns { created: number, failed: { row: number, error: string }[] }. One bad row does not abort the batch.

The ack returned by create, publishNow, retry, publishDraft, update, archive and unarchive is an Upload:

typescript
interface Upload {
  id?: string            // normalized from uploadId or draftId
  requestId?: string
  usage?: { count: number; limit: number; remaining: number } // -1 = unlimited
  message?: string
  scheduledAt?: string
  totalChannels?: number
  retriedChannels?: number // retry only
}

Example response of an immediate text post:

json
{ "id": "6b1f0c2a9d3e4f5a6b7c8d9e", "requestId": "9f2c7a1e-3d44-4b2a-8e1f-0a5c2d7e9f10", "usage": { "count": 4, "limit": 100, "remaining": 96 } }

With async: true there is no id, only requestId, message and totalChannels.

Status, list and lifecycle ​

MethodSignatureCalls
getStatusgetStatus(requestId: string): Promise<UploadStatusResponse>GET /content/status?requestId= (accepts a content ID too)
waitForCompletionwaitForCompletion(requestId: string, intervalMs = 3000, timeoutMs = 300000): Promise<UploadStatusResponse>polls getStatus until completed, failed or partial_failure; throws plain Error on timeout
listlist(query?: UploadHistoryQuery): Promise<UploadListResponse>GET /content
getget(id: string): Promise<UploadDetail>GET /content/:id
updateupdate(id: string, params: UpdateDraftParams): Promise<Upload>PATCH /content/:id
cancelcancel(id: string): Promise<void>DELETE /content/:id
publishNowpublishNow(id: string): Promise<Upload>POST /content/:id/publish-now
publishDraftpublishDraft(id: string): Promise<Upload>POST /content/:id/publish
retryretry(id: string): Promise<Upload>POST /content/:id/retry
archivearchive(id: string): Promise<Upload>PATCH /content/:id/archive
unarchiveunarchive(id: string): Promise<Upload>PATCH /content/:id/unarchive
bulkDeletebulkDelete(ids: string[]): Promise<void>POST /content/bulk-delete
bulkArchivebulkArchive(ids: string[]): Promise<void>POST /content/bulk-archive
bulkUnarchivebulkUnarchive(ids: string[]): Promise<void>POST /content/bulk-unarchive

UploadHistoryQuery: page?, limit?, status?, platform?, type?, from?, to?. list returns { data: UploadSummary[], meta: { total, page, limit, totalPages } }.

UploadStatus values in the type: draft, pending, queued, processing, publishing, completed, partial_failure, failed. The API can also return pending_approval (a key with requireApproval creates posts in that state; the create ack then carries uploadId, status: 'pending_approval' and a message). The type does not list it.

UpdateDraftParams: type?, connections?, title?, description?, text?, firstComment?, mediaIds?, scheduledAt?, timezone?, platformOptions?, contentFormat?. Note it uses mediaIds, not medias.

Status example:

typescript
const status = await socifyr.uploads.getStatus(ack.requestId!)
// { requestId, uploadId, status: 'partial_failure', type: 'video', channels: [
//   { platform: 'youtube', connectionId, targetName, result: { status: 'success', postId, postUrl, publishedAt } },
//   { platform: 'instagram', connectionId, result: { status: 'failed', error: '...' } } ], createdAt }

See Uploads for runnable end-to-end examples.

How do I call the media methods? ​

MethodSignatureCalls
uploadupload(file: Buffer | Blob, filename?: string): Promise<MediaItem>POST /media/upload (multipart)
listlist(query?: MediaQuery): Promise<PaginatedResponse<MediaItem>>GET /media
getget(id: string): Promise<MediaItem>GET /media/:id
updateupdate(id: string, metadata: MediaMetadata): Promise<MediaItem>POST /media/:id
deletedelete(id: string): Promise<void>DELETE /media/:id
bulkDeletebulkDelete(ids: string[]): Promise<void>POST /media/bulk-delete

MediaQuery: type? (image, video, document), search?, page?, limit?, sortBy? (createdAt, name), sortOrder? (asc, desc). MediaMetadata: alt?, description?, tags?. PaginatedResponse is typed as { results, total, page, limit, pages }. See Media.

How do I call the AI methods? ​

MethodSignatureCalls
statusstatus(): Promise<AiStatus>GET /ai/status
generateContentgenerateContent(params: GenerateContentParams): Promise<GeneratedContent>POST /ai/generate-content
suggestHashtagssuggestHashtags(params: SuggestHashtagsParams): Promise<SuggestedHashtags[]>POST /ai/suggest-hashtags

See AI.

How do I call the analytics methods? ​

MethodSignatureCalls
getget(query?: AnalyticsQuery): Promise<Analytics>GET /analytics
syncsync(): Promise<AnalyticsSyncResult>POST /analytics/sync
followersfollowers(query?: AccountAnalyticsQuery): Promise<FollowerGrowth>GET /analytics/followers
accountsaccounts(query?: AccountAnalyticsQuery): Promise<AccountComparison>GET /analytics/accounts
getPostgetPost(uploadId: string): Promise<PostAnalytics>GET /analytics/post/:uploadId
getPlatformMetricsgetPlatformMetrics(): Promise<PlatformMetric[]>GET /analytics/platform-metrics

AnalyticsQuery: from?, to?, platform?, granularity? (daily, weekly, monthly). AccountAnalyticsQuery: period? (last_day, last_week, last_month, last_3months, last_year), from?, to?, connection? (slug), platform?. See Analytics.

How do I call the engagement methods? ​

MethodSignatureCalls
backfillbackfill(): Promise<{ enqueued: number }>POST /engagement/backfill
resetInsightsresetInsights(platform?: string): Promise<{ cleared: number; enqueued: number }>POST /engagement/reset-insights?platform=

See Engagement.

How do I call the webhook methods? ​

MethodSignatureCalls
createcreate(params: CreateWebhookParams): Promise<Webhook>POST /webhooks
listlist(): Promise<Webhook[]>GET /webhooks
getget(id: string): Promise<Webhook>GET /webhooks/:id
updateupdate(id: string, params: UpdateWebhookParams): Promise<Webhook>PATCH /webhooks/:id
deletedelete(id: string): Promise<void>DELETE /webhooks/:id
deliveriesdeliveries(webhookId: string): Promise<WebhookDelivery[]>GET /webhooks/:id/deliveries

Top-level helpers: verifyWebhookSignature(payload: string | Buffer, signature: string | undefined | null, secret: string): boolean and parseWebhookEvent(payload: string | Buffer): WebhookEventPayload. Constants: WEBHOOK_EVENTS, PLATFORMS. See Webhooks.

How do I call the workspaces methods? ​

All workspaceId parameters are explicit. The client's own workspaceId is only sent as the X-Workspace-Id header.

MethodSignatureCalls
usageusage(): Promise<UsageSummary>GET /usage
createcreate(params: { name: string }): Promise<Workspace>POST /workspaces
listlist(): Promise<Workspace[]>GET /workspaces
getget(id: string): Promise<Workspace>GET /workspaces/:id
updateupdate(id: string, params: { name: string }): Promise<Workspace>PATCH /workspaces/:id
deletedelete(id: string): Promise<void>DELETE /workspaces/:id
listConnectionslistConnections(workspaceId: string): Promise<Connection[]>GET /workspaces/:id/connections
refreshConnectionrefreshConnection(workspaceId: string, connection: string): Promise<ConnectionRefreshResult>POST /workspaces/:id/connections/:connection/refresh
getReconnectLinkgetReconnectLink(connection: string): Promise<ReconnectLink>POST /oauth/connections/:connection/reconnect-link
forkConnectionforkConnection(workspaceId, connectionId, { targetId, targetName, targetImageUrl? }): Promise<Record<string, unknown>>POST /workspaces/:id/connections/:connectionId/fork
updateConnectionTargetupdateConnectionTarget(workspaceId, connectionId, { targetId, targetName }): Promise<void>PATCH /workspaces/:id/connections/:connectionId/target
deleteConnectiondeleteConnection(workspaceId, connectionId): Promise<void>DELETE /workspaces/:id/connections/:connectionId
revokeConnectionrevokeConnection(workspaceId, connectionId): Promise<void>DELETE /workspaces/:id/connections/:connectionId/revoke
disconnectPlatformdisconnectPlatform(workspaceId, platform: Platform): Promise<void>DELETE /workspaces/:id/platforms/:platform
revokePlatformrevokePlatform(workspaceId, platform: Platform): Promise<void>DELETE /workspaces/:id/platforms/:platform/revoke
updatePlatformTargetupdatePlatformTarget(workspaceId, platform, { targetId, targetName }): Promise<void>PATCH /workspaces/:id/platforms/:platform/target
listMemberslistMembers(workspaceId): Promise<WorkspaceMember[]>GET /workspaces/:id/members
updateMemberRoleupdateMemberRole(workspaceId, userId, roleKey: InvitableRole): Promise<void>PATCH /workspaces/:id/members/:userId/role
removeMemberremoveMember(workspaceId, userId): Promise<void>DELETE /workspaces/:id/members/:userId
inviteinvite(workspaceId, { email, roleKey: InvitableRole }): Promise<Invitation>POST /workspaces/:id/invitations
listInvitationslistInvitations(workspaceId): Promise<Invitation[]>GET /workspaces/:id/invitations
cancelInvitationcancelInvitation(workspaceId, invitationId): Promise<void>DELETE /workspaces/:id/invitations/:invitationId
listApiKeyslistApiKeys(workspaceId): Promise<ApiKey[]>GET /workspaces/:id/api-keys
createApiKeycreateApiKey(workspaceId, { label }): Promise<ApiKeyWithSecret>POST /workspaces/:id/api-keys
updateApiKeyupdateApiKey(workspaceId, keyId, params: UpdateApiKeyParams): Promise<{ success: boolean; id: string }>PUT /workspaces/:id/api-keys/:keyId
deleteApiKeydeleteApiKey(workspaceId, keyId): Promise<void>DELETE /workspaces/:id/api-keys/:keyId

Roles: WorkspaceRole is OWNER | ADMIN | EDITOR | CONTRIBUTOR. InvitableRole excludes OWNER.

UpdateApiKeyParams: label?, dailyPostLimit?: number | null, monthlyXSpendCentsCap?: number | null (US cents), requireApproval?: boolean. Pass null to remove a cap.

UsageSummary:

typescript
{
  tier: 'free' | 'pro' | 'business'
  uploads: UsageDimension   // { used, limit: number | null, remaining: number | null, unlimited: boolean }
  accounts: UsageDimension
  xPosts: UsageDimension
  xSpendUsd: number
  storage: UsageDimension & { usedBytes: number; limitBytes: number | null }
}

See Workspaces and Connections.

FAQ ​

Do the types match the API exactly? ​

They are hand-written to match the API. Two known quirks: PaginatedResponse (used by media.list) is typed with results and pages, while uploads.list returns data and meta.totalPages. Check the actual response if a field looks missing.

Which error does each method throw? ​

All of them throw the classes in Errors.

Next steps ​