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

# User moderation

> Learn how to manage users to improve moderation

<Frame>
  <img className="block" src="https://mintcdn.com/moderationapi/O8C8LNLiFOm8YTLj/users/author-detail.png?fit=max&auto=format&n=O8C8LNLiFOm8YTLj&q=85&s=5edd235321ed5797d45d0a0706921373" alt="Author detail page showing trust level, sentiment, flags, and moderation activity" width="1784" height="1021" data-path="users/author-detail.png" />
</Frame>

## Introduction

Enabling user management in Moderation API solves some of the most common moderation challenges for community platforms.

This is done by introducing the concept of authors (users) in the moderation process. Each author has a [trust level](/users/trust-levels) that is automatically adjusted based on their behavior and moderation history.

User management lets you:

* Tailor and improve moderation accuracy based on trust levels
* Skip moderation for trusted users
* Block or suspend users
* Fraud detection using behavioral analysis

<CardGroup cols={2}>
  <Card title="User dashboard" icon="users" href="https://dash.moderationapi.com/users">
    Access the user dashboard to view and manage your users.
  </Card>

  <Card title="Author API" icon="terminal" href="/api-reference/author/create-a-new-author">
    Access endpoints to read and update author details.
  </Card>
</CardGroup>

## Get started

Just add an `authorId` when submitting content to a [moderation
endpoint](/api-reference/moderate/analyze-text).

We recommend using the user ID from your system
but any unique identifier like email or username will work.

You should now see your users appear in the [user dashboard](https://dash.moderationapi.com/users).

<Note>
  There might be a delay in user creation and trust level calculation. This is
  because we process users in batches to optimize performance.
</Note>

## Typical workflow

Here's a common workflow for implementing user management in your moderation system:

<Steps>
  <Step title="Submit content with author ID">
    Start by including an `authorId` when submitting content for moderation:

    ```javascript theme={"theme":"nord"}
    const response = await fetch("https://api.moderationapi.com/v1/moderate", {
      method: "POST",
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        content: {
          type: "text",
          text: "User's message content",
        },
        authorId: "user_123",
      }),
    });
    ```

    Authors are automatically created on first submission.
  </Step>

  <Step title="Sync author details">
    [Add additional author information](/users/updating-authors) to improve trust scoring and enable fraud detection:

    ```javascript theme={"theme":"nord"}
    await fetch("https://api.moderationapi.com/v1/authors/user_123", {
      method: "PUT",
      headers: { Authorization: "Bearer YOUR_API_KEY" },
      body: JSON.stringify({
        name: "John Doe",
        email: "john@example.com",
        metadata: {
          email_verified: true,
          is_paying_customer: true,
        },
      }),
    });
    ```
  </Step>

  <Step title="Monitor trust levels">
    Check the user dashboard or use the API to monitor [trust levels](/users/trust-levels):

    * **New users (Level 0)**: Extra scrutiny for first-time posters
    * **Established users (Level 2+)**: Reduced moderation overhead
    * **Problematic users (Level -1)**: Automatic flagging for review
  </Step>

  <Step title="Take moderation actions">
    <Frame>
      <img className="block  mx-auto" style={{ maxWidth: "300px" }} src="https://mintcdn.com/moderationapi/97t5arQgQAdQo2TY/users/moderate-action.png?fit=max&auto=format&n=97t5arQgQAdQo2TY&q=85&s=aefb5c797e5b8ac30164b73a04212ef1" alt="User actions dashboard" width="552" height="458" data-path="users/moderate-action.png" />
    </Frame>

    When you identify problematic users, take action from the [user dashboard](https://dash.moderationapi.com/project/latest/authors):

    The user's status will be updated and your application can respond accordingly.
  </Step>

  <Step title="Check user status in your app">
    Before allowing users to post, check their status and respond appropriately:

    ```javascript theme={"theme":"nord"}
    const author = await fetch(`/api/v1/authors/${userId}`);
    const userData = await author.json();

    if (userData.status !== "enabled") {
      if (userData.status === "suspended") {
        const suspendedUntil = new Date(userData.block.until);
        throw new Error(
          `Account suspended until ${suspendedUntil.toLocaleDateString()}`,
        );
      } else if (userData.status === "blocked") {
        throw new Error("Account has been permanently blocked");
      }
    }

    // User is enabled - allow posting
    await publishContent(content);
    ```
  </Step>

  <Step title="Handle webhook notifications">
    Set up [webhooks](/actions/webhooks) to automatically notify users of moderation actions:

    ```javascript theme={"theme":"nord"}
    // Webhook handler for user actions
    app.post("/webhook/user-actions", (req, res) => {
      const event = req.body;

      if (event.type === "author.suspended") {
        const { author } = event.data.object;
        const reason = author.block?.reason;
        const until = author.block?.until; // Unix ms timestamp

        sendEmail(author.email, {
          subject: "Account Temporarily Suspended",
          body: `Your account has been suspended. Reason: ${reason}`,
          unsuspendDate: until ? new Date(until) : undefined,
        });
      }

      res.status(200).send("OK");
    });
    ```
  </Step>
</Steps>
