> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sublay.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Space Moderation

> Resolve reports, moderate content, and manage rules

The space moderation functions let admins and moderators resolve reports, moderate entities, comments, and chat messages, and manage community rules within a space.

***

### handleEntityReport

Resolves a reported entity by applying one or more actions.

```typescript theme={null}
const result = await sublay.spaces.handleEntityReport({
  spaceId: "spc_abc123",
  reportId: "rep_111",
  entityId: "ent_222",
  actions: ["remove-entity", "ban-user"],
  reason: "Spam",
  summary: "Removed and banned for spam",
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="reportId" type="string" required>
  The ID of the report to resolve.
</ParamField>

<ParamField body="entityId" type="string" required>
  The ID of the reported entity.
</ParamField>

<ParamField body="actions" type="string[]" required>
  One or more actions to apply: `"remove-entity"`, `"ban-user"`, and/or `"dismiss"`. `"ban-user"` bans the author of the reported content and requires `reason`.
</ParamField>

<ParamField body="summary" type="string">
  The resolution note stored on the report. Required, whatever the actions.
</ParamField>

<ParamField body="reason" type="string">
  Reason for the ban, kept in the space's ban log. Required when `actions` includes `ban-user`.
</ParamField>

**Returns** — `Promise<{ message: string; code: string }>`

***

### handleCommentReport

Resolves a reported comment by applying one or more actions.

```typescript theme={null}
const result = await sublay.spaces.handleCommentReport({
  spaceId: "spc_abc123",
  reportId: "rep_111",
  commentId: "cmt_222",
  actions: ["dismiss"],
  summary: "No violation found",
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="reportId" type="string" required>
  The ID of the report to resolve.
</ParamField>

<ParamField body="commentId" type="string" required>
  The ID of the reported comment.
</ParamField>

<ParamField body="actions" type="string[]" required>
  One or more actions to apply: `"remove-comment"`, `"ban-user"`, and/or `"dismiss"`. `"ban-user"` bans the author of the reported content and requires `reason`.
</ParamField>

<ParamField body="summary" type="string">
  The resolution note stored on the report. Required, whatever the actions.
</ParamField>

<ParamField body="reason" type="string">
  Reason for the ban, kept in the space's ban log. Required when `actions` includes `ban-user`.
</ParamField>

**Returns** — `Promise<{ message: string; code: string }>`

***

### handleSpaceChatReport

Resolves a reported space chat message by applying one or more actions.

```typescript theme={null}
const result = await sublay.spaces.handleSpaceChatReport({
  spaceId: "spc_abc123",
  reportId: "rep_111",
  actions: ["remove-message"],
  messageId: "msg_222",
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="reportId" type="string" required>
  The ID of the report to resolve.
</ParamField>

<ParamField body="actions" type="string[]" required>
  One or more actions to apply: `"remove-message"`, `"ban-user"`, and/or `"dismiss"`. `"ban-user"` bans the author of the reported content and requires `reason`.
</ParamField>

<ParamField body="summary" type="string">
  A summary of the resolution.
</ParamField>

<ParamField body="reason" type="string">
  Reason for the ban, kept in the space's ban log, and the removal reason for `remove-message`. Required when `actions` includes `ban-user`.
</ParamField>

<ParamField body="messageId" type="string">
  The message to remove. Required when `actions` includes `"remove-message"`.
</ParamField>

**Returns** — `Promise<{ message: string; code: string }>`

***

### moderateSpaceEntity

Approves or removes an entity in a space.

```typescript theme={null}
const result = await sublay.spaces.moderateSpaceEntity({
  spaceId: "spc_abc123",
  entityId: "ent_222",
  action: "remove",
  reason: "Off-topic",
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="entityId" type="string" required>
  The ID of the entity to moderate.
</ParamField>

<ParamField body="action" type="string" required>
  The action to take: `"approve"` or `"remove"`.
</ParamField>

<ParamField body="reason" type="string">
  The reason for the moderation action.
</ParamField>

**Returns** — `Promise<{ message: string; moderationStatus: "approved" | "removed" }>`

***

### setSpaceEntityNsfw

Sets the NSFW own-flag on an entity within a space — including other users' entities. Separate from `moderateSpaceEntity`: it **labels** the entity (`nsfw`), it does not approve/remove it. Requires the acting user to be an admin or moderator of the space.

```typescript theme={null}
const result = await sublay.spaces.setSpaceEntityNsfw({
  spaceId: "spc_abc123",
  entityId: "ent_222",
  nsfw: true,
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID containing the entity.
</ParamField>

<ParamField body="entityId" type="string" required>
  The ID of the entity to flag or unflag.
</ParamField>

<ParamField body="nsfw" type="boolean" required>
  The NSFW own-flag to set on the entity.
</ParamField>

**Returns** — `Promise<{ message: string; nsfw: boolean }>`

***

### moderateSpaceComment

Approves or removes a comment in a space.

```typescript theme={null}
const result = await sublay.spaces.moderateSpaceComment({
  spaceId: "spc_abc123",
  commentId: "cmt_222",
  action: "approve",
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="commentId" type="string" required>
  The ID of the comment to moderate.
</ParamField>

<ParamField body="action" type="string" required>
  The action to take: `"approve"` or `"remove"`.
</ParamField>

<ParamField body="reason" type="string">
  The reason for the moderation action.
</ParamField>

**Returns** — `Promise<{ message: string; moderationStatus: "approved" | "removed" }>`

***

### moderateSpaceChatMessage

Applies a moderation status to a space chat message.

```typescript theme={null}
const result = await sublay.spaces.moderateSpaceChatMessage({
  spaceId: "spc_abc123",
  messageId: "msg_222",
  moderationStatus: "removed",
  moderationReason: "Spam",
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="messageId" type="string" required>
  The ID of the chat message to moderate.
</ParamField>

<ParamField body="moderationStatus" type="string" required>
  The moderation status to apply: `"removed"`.
</ParamField>

<ParamField body="moderationReason" type="string">
  The reason for the moderation action.
</ParamField>

**Returns** — `Promise<{ message: string; moderationStatus: string }>`

***

### fetchManyRules

Fetches all rules for a space.

```typescript theme={null}
const rules = await sublay.spaces.fetchManyRules({ spaceId: "spc_abc123" });
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

**Returns** — `Promise<FetchManyRulesResponse>`

***

### fetchRule

Fetches a single rule by ID.

```typescript theme={null}
const rule = await sublay.spaces.fetchRule({
  spaceId: "spc_abc123",
  ruleId: "rul_222",
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="ruleId" type="string" required>
  The ID of the rule to fetch.
</ParamField>

**Returns** — `Promise<Rule>`

***

### createRule

Creates a rule in a space.

```typescript theme={null}
const rule = await sublay.spaces.createRule({
  spaceId: "spc_abc123",
  title: "Be respectful",
  description: "No harassment or hate speech.",
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="title" type="string" required>
  The rule title.
</ParamField>

<ParamField body="description" type="string">
  The rule description.
</ParamField>

**Returns** — `Promise<Rule>`

***

### updateRule

Updates a rule's title and/or description.

```typescript theme={null}
const rule = await sublay.spaces.updateRule({
  spaceId: "spc_abc123",
  ruleId: "rul_222",
  title: "Be kind",
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="ruleId" type="string" required>
  The ID of the rule to update.
</ParamField>

<ParamField body="title" type="string">
  The new rule title.
</ParamField>

<ParamField body="description" type="string">
  The new rule description.
</ParamField>

**Returns** — `Promise<Rule>`

***

### deleteRule

Deletes a rule.

```typescript theme={null}
const result = await sublay.spaces.deleteRule({
  spaceId: "spc_abc123",
  ruleId: "rul_222",
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="ruleId" type="string" required>
  The ID of the rule to delete.
</ParamField>

**Returns** — `Promise<DeleteRuleResponse>`

***

### reorderRules

Reorders a space's rules.

```typescript theme={null}
const rules = await sublay.spaces.reorderRules({
  spaceId: "spc_abc123",
  ruleIds: ["rul_333", "rul_111", "rul_222"],
});
```

<ParamField body="spaceId" type="string" required>
  The Sublay space ID.
</ParamField>

<ParamField body="ruleIds" type="string[]" required>
  The rule IDs in the new order.
</ParamField>

**Returns** — `Promise<Rule[]>`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.