Skip to content

The workspaces resource covers everything outside content publishing: connections, members, permissions, and keys.

Workspaces

typescript
// List
const list = await socifyr.workspaces.list()

// Create
const ws = await socifyr.workspaces.create({ name: 'New brand' })

// Fetch one
const one = await socifyr.workspaces.get(workspaceId)

// Rename
await socifyr.workspaces.update(workspaceId, { name: 'Renamed' })

// Delete
await socifyr.workspaces.delete(workspaceId)

Connections

typescript
const connections = await socifyr.workspaces.listConnections(workspaceId)
//  [{ id, slug, platform, platformUsername, targetName, connectedAt, expiresAt }, ...]

// Platform-wide: disconnect every account for a platform
// (removes from workspace, keeps platform OAuth)
await socifyr.workspaces.disconnectPlatform(workspaceId, 'instagram')

// Platform-wide: disconnect AND revoke the OAuth tokens server-side
await socifyr.workspaces.revokePlatform(workspaceId, 'instagram')

// Platform-wide: switch which page/account posts go to (e.g. Facebook page)
await socifyr.workspaces.updatePlatformTarget(workspaceId, 'facebook', {
  targetId: '101574425127722',
  targetName: 'My Brand Page',
})

Single-connection management

These operate on one connection and leave sibling connections for the same platform intact:

typescript
// Disconnect one connection
await socifyr.workspaces.deleteConnection(workspaceId, connectionId)

// Disconnect AND revoke its OAuth tokens
await socifyr.workspaces.revokeConnection(workspaceId, connectionId)

// Fork a page-based connection (Facebook/Instagram) into a new connection
// for another page under the same OAuth grant
const forked = await socifyr.workspaces.forkConnection(workspaceId, connectionId, {
  targetId: '1004860882719628',
  targetName: 'Second Brand Page',
  targetImageUrl: 'https://cdn.example.com/avatar.png', // optional
})

// Switch the page/account a single connection posts to
await socifyr.workspaces.updateConnectionTarget(workspaceId, connectionId, {
  targetId: '1004860882719628',
  targetName: 'Second Brand Page',
})

// Refresh OAuth tokens (e.g. a platform reported expired credentials)
await socifyr.workspaces.refreshConnection(workspaceId, connectionId)

Members

typescript
const members = await socifyr.workspaces.listMembers(workspaceId)
//  [{ userId, email, name, role: 'OWNER' | 'ADMIN' | 'EDITOR' | 'CONTRIBUTOR', joinedAt }]

await socifyr.workspaces.updateMemberRole(workspaceId, userId, 'EDITOR')

await socifyr.workspaces.removeMember(workspaceId, userId)

Invitations

typescript
const invite = await socifyr.workspaces.invite(workspaceId, {
  email: 'teammate@example.com',
  roleKey: 'EDITOR',
})

const pending = await socifyr.workspaces.listInvitations(workspaceId)

await socifyr.workspaces.cancelInvitation(workspaceId, invite.id)

API keys

typescript
const keys = await socifyr.workspaces.listApiKeys(workspaceId)

const { key } = await socifyr.workspaces.createApiKey(workspaceId, {
  label: 'CI bot',
})
console.log(key) // sk_... — shown only once, save it now

await socifyr.workspaces.deleteApiKey(workspaceId, keyId)