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

# Analyze a text message

> Analyzes a text message/comment and returns its moderation classification, severity, target, detected language, and a recommended moderation action.

Before diving in, we recommend reading the [text taxonomy](/en/documentation/taxonomy/text-classifications) to understand the classifications, severities, and moderation signals returned by this endpoint.




## OpenAPI

````yaml /openapi/analyze.openapi.yaml post /analyze/v1/text
openapi: 3.1.0
info:
  title: Bodyguard Analyze API
  version: 1.0.0
servers:
  - url: https://api.bodyguard.ai
security:
  - ApiKeyAuth: []
tags:
  - name: Analyze
    description: Content analysis endpoints.
paths:
  /analyze/v1/text:
    post:
      tags:
        - Analyze
      summary: Analyze a text message
      description: >
        Analyzes a text message/comment and returns its moderation
        classification, severity, target, detected language, and a recommended
        moderation action.


        Before diving in, we recommend reading the [text
        taxonomy](/en/documentation/taxonomy/text-classifications) to understand
        the classifications, severities, and moderation signals returned by this
        endpoint.
      operationId: bodyguard.analyze.v1.AnalyzeText
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/bodyguard.analyze.v1.AnalyzeTextRequest'
            examples:
              simpleComment:
                summary: Simple comment analysis
                value:
                  channelId: __YOUR_CHANNEL_ID__
                  text: Einstein is an asshole
                  publishedAt: '2026-04-23T10:30:00.000Z'
              commentWithContext:
                summary: Comment with an author and post context
                value:
                  channelId: __YOUR_CHANNEL_ID__
                  text: Einstein is an asshole
                  publishedAt: '2026-04-23T10:30:00.000Z'
                  language: en
                  reference: comment-12346
                  author:
                    username: johndoe
                    reference: user-987
                    permalink: https://example.com/users/johndoe
                    profilePictureUrl: https://cdn.example.com/avatars/johndoe.jpg
                  post:
                    title: New product launch
                    reference: post-42
                    publishedAt: '2025-01-15T09:00:00Z'
                    permalink: https://example.com/posts/42
      responses:
        '200':
          description: Analysis completed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/bodyguard.analyze.v1.AnalyzeTextResponse'
              examples:
                toxic:
                  summary: Toxic, remove
                  value:
                    textAnalysis:
                      type: HATEFUL
                      classifications:
                        - INSULT
                      severity: HIGH
                      directedAt: AUTHOR_OF_COMMENT
                      language: en
                      recommendedAction: REMOVE
                      censoredText: Einstein is an *******
                      classificationMeta:
                        INSULT:
                          severity: MEDIUM
                neutral:
                  summary: Neutral, keep
                  value:
                    textAnalysis:
                      type: POSITIVE
                      classifications:
                        - SUPPORTIVE
                      severity: NONE
                      directedAt: NONE
                      language: en
                      recommendedAction: KEEP
                      censoredText: Awesome news !
                      classification_meta: {}
components:
  schemas:
    bodyguard.analyze.v1.AnalyzeTextRequest:
      type: object
      required:
        - channelId
        - text
      properties:
        channelId:
          type: string
          format: uuid
          description: >-
            Identifier of the [channel](/en/api-reference/concepts#channel) the
            text belongs to. Provided by Bodyguard.
        text:
          type: string
          maxLength: 10000
          description: The text content to analyze.
          example: I love this product!
        publishedAt:
          type: string
          format: date-time
          description: >-
            [Publication
            date](/en/api-reference/concepts#publication-date-publishedat) of
            the message. Defaults to the current date and time if omitted. This
            value must be stable across retries or resubmissions of the same
            message — changing it will cause the message to be duplicated in
            Bodyguard's records. Dates before 2020-01-01 are not supported.
        reference:
          type: string
          maxLength: 256
          description: >-
            Your own stable identifier for this piece of content (e.g. a comment
            ID from your database). Bodyguard echoes it back in webhooks and
            stored results, making it easy to correlate analysis with your own
            records. If omitted, a random reference is automatically generated.
        permalink:
          type: string
          format: uri
          description: A public URL pointing to the content, if available.
        language:
          type: string
          minLength: 2
          maxLength: 2
          description: >-
            Hint about the content language as an ISO 639-1 code (e.g. `en`,
            `fr`). If omitted, language is auto-detected.
          example: en
        post:
          $ref: '#/components/schemas/bodyguard.analyze.v1.AnalyzeTextRequest.Post'
        author:
          $ref: '#/components/schemas/bodyguard.analyze.v1.AnalyzeTextRequest.Author'
    bodyguard.analyze.v1.AnalyzeTextResponse:
      type: object
      properties:
        textAnalysis:
          $ref: '#/components/schemas/bodyguard.analyze.v1.TextAnalysis'
    bodyguard.analyze.v1.AnalyzeTextRequest.Post:
      type: object
      required:
        - title
      description: >-
        Metadata about the post the analyzed content belongs to. Optional, but
        strongly recommended: it powers context-aware moderation based on the
        post topic, which can't work without it. This information also appears
        on the Dashboard analytics through post-level data.
      properties:
        title:
          type: string
          maxLength: 2048
          description: Title or short description of the post.
        reference:
          type: string
          maxLength: 256
          description: >-
            Your own stable identifier for this post (e.g. a post ID from your
            database). Bodyguard echoes it back in webhooks and stored results,
            making it easy to correlate analysis with your own records. If
            omitted, a reference is automatically generated from `publishedAt`
            and `title` — meaning two posts with the same title and publication
            date will be considered the same post.
        publishedAt:
          type: string
          format: date-time
          description: >-
            [Publication
            date](/en/api-reference/concepts#publication-date-publishedat) of
            the post. Defaults to 00:00 of the current day if omitted. This
            value must be stable across all messages belonging to the same post
            — changing it will cause the post to be duplicated in Bodyguard's
            records. Dates before 2020-01-01 are not supported.
        permalink:
          type: string
          format: uri
          description: Public URL of the post.
    bodyguard.analyze.v1.AnalyzeTextRequest.Author:
      type: object
      required:
        - username
      description: >-
        Metadata about the author of the content. Optional, but strongly
        recommended: some features only work with it — for example, spam
        management is tracked per author. This information also appears on the
        Dashboard analytics through author-level data.
      properties:
        username:
          type: string
          maxLength: 255
          description: Display name / username of the author.
        reference:
          type: string
          maxLength: 256
          description: >-
            Your own stable identifier for this author (e.g. a user ID from your
            database). Bodyguard echoes it back in webhooks and stored results,
            making it easy to correlate analysis with your own records. If
            omitted, a reference is automatically generated from `username` —
            meaning two authors with the same username will be considered the
            same author.
        permalink:
          type: string
          format: uri
          description: Public URL of the author's profile.
        profilePictureUrl:
          type: string
          format: uri
          description: URL of the author's profile picture.
    bodyguard.analyze.v1.TextAnalysis:
      type: object
      description: Moderation result for a piece of text.
      properties:
        type:
          $ref: '#/components/schemas/bodyguard.std.v1.Type'
        classifications:
          type: array
          description: >-
            Fine-grained labels describing the content (e.g. `INSULT`, `SPAM`).
            See the [text
            taxonomy](/en/documentation/taxonomy/text-classifications) for the
            full list and descriptions of each classification.
          items:
            type: string
        severity:
          $ref: '#/components/schemas/bodyguard.std.v1.Severity'
        directedAt:
          $ref: '#/components/schemas/bodyguard.std.v1.DirectedAt'
        language:
          type: string
          description: Detected language as an ISO 639-1 code.
        recommendedAction:
          $ref: '#/components/schemas/bodyguard.std.v1.RecommendedAction'
        censoredText:
          type: string
          description: The original text with sensitive content censored with `*`.
        classificationMeta:
          type: object
          additionalProperties:
            $ref: >-
              #/components/schemas/bodyguard.analyze.v1.TextAnalysis.ClassificationMeta
    bodyguard.std.v1.Type:
      type: string
      description: >-
        The broad category of the analyzed content. For finer-grained detail,
        see `classifications`. See the [text
        taxonomy](/en/documentation/taxonomy/text-classifications) for the full
        description of each value.
      enum:
        - NEUTRAL
        - HATEFUL
        - POSITIVE
        - NONE
        - HATE_SPEECH
        - CRITICISM
        - UNDESIRABLE
    bodyguard.std.v1.Severity:
      type: string
      description: >-
        Severity of the detected issue, if any. See the [text
        taxonomy](/en/documentation/taxonomy/text-classifications) for the full
        description of each value.
      enum:
        - LOW
        - MEDIUM
        - HIGH
        - CRITICAL
        - NONE
    bodyguard.std.v1.DirectedAt:
      type: string
      description: >-
        Who or what the content is directed at. See the [text
        taxonomy](/en/documentation/taxonomy/text-classifications) for the full
        description of each value.
      enum:
        - USER
        - USER_FAMILY
        - SINGLE_PERSON
        - GROUP
        - EVERYONE
        - AUTHOR_OF_COMMENT
        - HATERS
        - NONE
        - ENTITY
    bodyguard.std.v1.RecommendedAction:
      type: string
      description: The moderation action Bodyguard recommends you apply to this content.
      enum:
        - KEEP
        - REMOVE
        - WATCH
    bodyguard.analyze.v1.TextAnalysis.ClassificationMeta:
      type: object
      description: >
        Additional metadata for each detected classification.

        **Important:** Bodyguard cannot guarantee that this metadata will be
        present for every classification — for example, some non-toxic
        classifications may not have any."
      properties:
        severity:
          $ref: '#/components/schemas/bodyguard.std.v1.Severity'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: |
        API key authentication. Provide your key in the `Authorization`
        header with the `ApiKey` scheme:
        ```
        Authorization: ApiKey <your-api-key>
        ```

````