Skip to main content
The space moderation functions let admins and moderators resolve reports, moderate entities, comments, and chat messages, manage community rules, and configure digest delivery within a space.

handleEntityReport

Resolves a reported entity by applying one or more actions.
const result = await sublay.spaces.handleEntityReport({
  spaceId: "spc_abc123",
  reportId: "rep_111",
  entityId: "ent_222",
  actions: ["remove-entity", "ban-user"],
  userId: "usr_333",
});
spaceId
string
required
The Sublay space ID.
reportId
string
required
The ID of the report to resolve.
entityId
string
required
The ID of the reported entity.
actions
string[]
required
One or more actions to apply: "remove-entity", "ban-user", and/or "dismiss".
summary
string
A summary of the resolution.
reason
string
The reason for the resolution.
userId
string
The user to ban. Required when actions includes "ban-user".
userId here is the ban target — the user being banned — not the actor performing the moderation.
ReturnsPromise<{ message: string; code: string }>

handleCommentReport

Resolves a reported comment by applying one or more actions.
const result = await sublay.spaces.handleCommentReport({
  spaceId: "spc_abc123",
  reportId: "rep_111",
  commentId: "cmt_222",
  actions: ["dismiss"],
});
spaceId
string
required
The Sublay space ID.
reportId
string
required
The ID of the report to resolve.
commentId
string
required
The ID of the reported comment.
actions
string[]
required
One or more actions to apply: "remove-comment", "ban-user", and/or "dismiss".
summary
string
A summary of the resolution.
reason
string
The reason for the resolution.
userId
string
The user to ban. Required when actions includes "ban-user".
userId here is the ban target — the user being banned — not the actor performing the moderation.
ReturnsPromise<{ message: string; code: string }>

handleSpaceChatReport

Resolves a reported space chat message by applying one or more actions.
const result = await sublay.spaces.handleSpaceChatReport({
  spaceId: "spc_abc123",
  reportId: "rep_111",
  actions: ["remove-message"],
  messageId: "msg_222",
});
spaceId
string
required
The Sublay space ID.
reportId
string
required
The ID of the report to resolve.
actions
string[]
required
One or more actions to apply: "remove-message", "ban-user", and/or "dismiss".
summary
string
A summary of the resolution.
reason
string
The reason for the resolution.
userId
string
The user to ban. Required when actions includes "ban-user".
messageId
string
The message to remove. Required when actions includes "remove-message".
userId here is the ban target — the user being banned — not the actor performing the moderation.
ReturnsPromise<{ message: string; code: string }>

moderateSpaceEntity

Approves or removes an entity in a space.
const result = await sublay.spaces.moderateSpaceEntity({
  spaceId: "spc_abc123",
  entityId: "ent_222",
  action: "remove",
  reason: "Off-topic",
});
spaceId
string
required
The Sublay space ID.
entityId
string
required
The ID of the entity to moderate.
action
string
required
The action to take: "approve" or "remove".
reason
string
The reason for the moderation action.
ReturnsPromise<{ message: string; moderationStatus: "approved" | "removed" }>

moderateSpaceComment

Approves or removes a comment in a space.
const result = await sublay.spaces.moderateSpaceComment({
  spaceId: "spc_abc123",
  commentId: "cmt_222",
  action: "approve",
});
spaceId
string
required
The Sublay space ID.
commentId
string
required
The ID of the comment to moderate.
action
string
required
The action to take: "approve" or "remove".
reason
string
The reason for the moderation action.
ReturnsPromise<{ message: string; moderationStatus: "approved" | "removed" }>

moderateSpaceChatMessage

Applies a moderation status to a space chat message.
const result = await sublay.spaces.moderateSpaceChatMessage({
  spaceId: "spc_abc123",
  messageId: "msg_222",
  moderationStatus: "removed",
  moderationReason: "Spam",
});
spaceId
string
required
The Sublay space ID.
messageId
string
required
The ID of the chat message to moderate.
moderationStatus
string
required
The moderation status to apply: "removed".
moderationReason
string
The reason for the moderation action.
ReturnsPromise<{ message: string; moderationStatus: string }>

fetchManyRules

Fetches all rules for a space.
const rules = await sublay.spaces.fetchManyRules({ spaceId: "spc_abc123" });
spaceId
string
required
The Sublay space ID.
ReturnsPromise<FetchManyRulesResponse>

fetchRule

Fetches a single rule by ID.
const rule = await sublay.spaces.fetchRule({
  spaceId: "spc_abc123",
  ruleId: "rul_222",
});
spaceId
string
required
The Sublay space ID.
ruleId
string
required
The ID of the rule to fetch.
ReturnsPromise<Rule>

createRule

Creates a rule in a space.
const rule = await sublay.spaces.createRule({
  spaceId: "spc_abc123",
  title: "Be respectful",
  description: "No harassment or hate speech.",
});
spaceId
string
required
The Sublay space ID.
title
string
required
The rule title.
description
string
The rule description.
ReturnsPromise<Rule>

updateRule

Updates a rule’s title and/or description.
const rule = await sublay.spaces.updateRule({
  spaceId: "spc_abc123",
  ruleId: "rul_222",
  title: "Be kind",
});
spaceId
string
required
The Sublay space ID.
ruleId
string
required
The ID of the rule to update.
title
string
The new rule title.
description
string
The new rule description.
ReturnsPromise<Rule>

deleteRule

Deletes a rule.
const result = await sublay.spaces.deleteRule({
  spaceId: "spc_abc123",
  ruleId: "rul_222",
});
spaceId
string
required
The Sublay space ID.
ruleId
string
required
The ID of the rule to delete.
ReturnsPromise<DeleteRuleResponse>

reorderRules

Reorders a space’s rules.
const rules = await sublay.spaces.reorderRules({
  spaceId: "spc_abc123",
  ruleIds: ["rul_333", "rul_111", "rul_222"],
});
spaceId
string
required
The Sublay space ID.
ruleIds
string[]
required
The rule IDs in the new order.
ReturnsPromise<Rule[]>

fetchDigestConfig

Fetches the digest configuration for a space.
const config = await sublay.spaces.fetchDigestConfig({
  spaceId: "spc_abc123",
});
spaceId
string
required
The Sublay space ID.
ReturnsPromise<DigestConfig>

updateDigestConfig

Updates the digest configuration.
const config = await sublay.spaces.updateDigestConfig({
  spaceId: "spc_abc123",
  digestEnabled: true,
  digestWebhookUrl: "https://example.com/digest",
  digestScheduleHour: 9,
  digestTimezone: "America/New_York",
});
spaceId
string
required
The Sublay space ID.
digestEnabled
boolean
Whether digest delivery is enabled.
digestWebhookUrl
string
The webhook URL to deliver the digest to.
digestWebhookSecret
string
The secret used to sign digest webhook deliveries.
digestScheduleHour
number
The hour of day at which the digest is delivered.
digestTimezone
string
The timezone used to interpret the schedule hour.
ReturnsPromise<DigestConfig>