> ## 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 an image

> Analyzes an image by URL or by image bytes. Returns a list of classifications for the image and, when OCR is enabled, the text extracted from the image along with its own text analysis.

Send the image in one of two ways:

- **By URL:** an `application/json` body with `imageUrl`.
- **By bytes:** a `multipart/form-data` body with the image file in the `imageData` part. The other fields are sent as form fields.

Only **PNG**, **JPEG** and **WebP** images are accepted, and the image must not exceed **1 MiB** (1,048,576 bytes). Requests with an unsupported format or an oversized image are rejected with a `400 Bad Request`.

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




## OpenAPI

````yaml /openapi/analyze.openapi.yaml post /analyze/v1/image
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/image:
    post:
      tags:
        - Analyze
      summary: Analyze an image
      description: >
        Analyzes an image by URL or by image bytes. Returns a list of
        classifications for the image and, when OCR is enabled, the text
        extracted from the image along with its own text analysis.


        Send the image in one of two ways:


        - **By URL:** an `application/json` body with `imageUrl`.

        - **By bytes:** a `multipart/form-data` body with the image file in the
        `imageData` part. The other fields are sent as form fields.


        Only **PNG**, **JPEG** and **WebP** images are accepted, and the image
        must not exceed **1 MiB** (1,048,576 bytes). Requests with an
        unsupported format or an oversized image are rejected with a `400 Bad
        Request`.


        Before diving in, we recommend reading the [image
        taxonomy](/en/documentation/taxonomy/image-classifications) to
        understand the classifications returned by this endpoint.
      operationId: bodyguard.analyze.v1.AnalyzeImage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/bodyguard.analyze.v1.AnalyzeImageRequest'
            examples:
              byUrl:
                summary: Analyze an image by URL
                value:
                  channelId: <your-channel-id>
                  publishedAt: '2026-04-23T10:30:00.000Z'
                  imageUrl: https://cdn.example.com/uploads/photo.jpg
              withContext:
                summary: Analyze an image with an author and post context
                value:
                  channelId: <your-channel-id>
                  publishedAt: '2026-04-23T10:30:00.000Z'
                  imageUrl: https://cdn.example.com/uploads/photo.jpg
                  author:
                    username: johndoe
                    reference: user-987
                    countryCode: US
                  post:
                    title: New product launch
                    reference: post-42
                    publishedAt: '2025-01-15T09:00:00Z'
                    countryCodes:
                      - US
                      - CA
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/bodyguard.analyze.v1.AnalyzeImageRequest'
            examples:
              byFile:
                summary: Analyze an image file
                value:
                  channelId: <your-channel-id>
                  publishedAt: '2026-04-23T10:30:00.000Z'
      responses:
        '200':
          description: Analysis completed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/bodyguard.analyze.v1.AnalyzeImageResponse'
              examples:
                classified:
                  summary: Image classified as sexual content
                  value:
                    imageAnalysis:
                      classifications:
                        - PARTIAL_NUDITY
                      classificationMeta:
                        PARTIAL_NUDITY:
                          confidenceScore: 0.92
                      detectedUrls: []
                      ocrAnalysis:
                        text: Text extracted from the image
                        textAnalysis:
                          type: HATEFUL
                          classifications:
                            - INSULT
                          severity: HIGH
                          directedAt: AUTHOR_OF_COMMENT
                          language: en
                          recommendedAction: REMOVE
                          censoredText: Einstein is an *******
                          classificationMeta:
                            INSULT:
                              severity: MEDIUM
                          detectedUrls: []
                withUrls:
                  summary: Image with a QR code and a URL in its text
                  value:
                    imageAnalysis:
                      classifications:
                        - QR_CODE
                      classificationMeta:
                        QR_CODE:
                          confidenceScore: 0.98
                      detectedUrls:
                        - url: https://www.example.com/pay
                      ocrAnalysis:
                        text: Visit https://www.example.com/deals
                        textAnalysis:
                          type: NEUTRAL
                          classifications: []
                          severity: NONE
                          directedAt: NONE
                          language: en
                          recommendedAction: KEEP
                          censoredText: Visit https://www.example.com/deals
                          classificationMeta: {}
                          detectedUrls:
                            - url: https://www.example.com/deals
components:
  schemas:
    bodyguard.analyze.v1.AnalyzeImageRequest:
      type: object
      required:
        - channelId
      properties:
        channelId:
          type: string
          description: >-
            Identifier of the [channel](/en/api-reference/concepts#channel) the
            image belongs to. Provided by Bodyguard.
        publishedAt:
          type: string
          format: date-time
          description: >-
            [Publication
            date](/en/api-reference/concepts#publication-date-publishedat) of
            the image.
        imageUrl:
          type: string
          format: uri
          description: >
            Public URL of the image to analyze, sent in an `application/json`
            body. The image must be a PNG, JPEG or WebP file no larger than 1
            MiB. Only one of `imageUrl` or `imageData` can be provided.


            When fetching the image, Bodyguard sends the user-agent
            `Bodyguard-Analyze/1.0 (+https://bodyguard.ai/bot)`. If you
            allowlist Bodyguard on a CDN or firewall, match on the stable
            `Bodyguard-Analyze` product token rather than the full string — the
            version number and bot URL may change over time. Image fetches are
            not sent from a fixed set of IP addresses, so the user-agent is the
            signal to allowlist against.
        imageData:
          type: string
          format: binary
          description: >-
            The image file, sent in a `multipart/form-data` body. The image must
            be a PNG, JPEG or WebP file no larger than 1 MiB. Only one of
            `imageUrl` or `imageData` can be provided.
        post:
          $ref: '#/components/schemas/bodyguard.analyze.v1.AnalyzeTextRequest.Post'
        author:
          $ref: '#/components/schemas/bodyguard.analyze.v1.AnalyzeTextRequest.Author'
      oneOf:
        - required:
            - imageUrl
        - required:
            - imageData
    bodyguard.analyze.v1.AnalyzeImageResponse:
      type: object
      properties:
        imageAnalysis:
          $ref: '#/components/schemas/bodyguard.analyze.v1.ImageAnalysis'
    bodyguard.analyze.v1.AnalyzeTextRequest.Post:
      type: object
      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. Can be omitted or left
            empty, in which case `reference` is required.
        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. Required
            if `title` is omitted or empty. 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.
        countryCodes:
          type: array
          description: >-
            Countries the post is aimed at, as uppercase ISO 3166-1 alpha-2
            codes (e.g. `US`, `FR`). A post can target several countries. Helps
            Bodyguard resolve words whose meaning changes from one country to
            another. If omitted, no country context is applied for the post.
          items:
            type: string
            minLength: 2
            maxLength: 2
          example:
            - US
            - CA
      anyOf:
        - required:
            - title
        - required:
            - reference
    bodyguard.analyze.v1.AnalyzeTextRequest.Author:
      type: object
      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. Can be omitted or left empty,
            in which case `reference` is required.
        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. Required
            if `username` is omitted or empty. 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.
        countryCode:
          type: string
          minLength: 2
          maxLength: 2
          description: >-
            Country the author is located in, as an uppercase ISO 3166-1 alpha-2
            code (e.g. `US`, `FR`). Helps Bodyguard resolve words whose meaning
            changes from one country to another. If omitted, no country context
            is applied for the author.
          example: US
      anyOf:
        - required:
            - username
        - required:
            - reference
    bodyguard.analyze.v1.ImageAnalysis:
      type: object
      description: Moderation result for an image.
      properties:
        classifications:
          type: array
          description: >-
            Classifications detected on the image itself. An empty array means
            the image was analyzed successfully and Bodyguard did not detect any
            sensitive content — it can be treated as safe.
          items:
            type: string
        classificationMeta:
          type: object
          additionalProperties:
            $ref: >-
              #/components/schemas/bodyguard.analyze.v1.ImageAnalysis.ClassificationMeta
        detectedUrls:
          type: array
          description: >-
            URLs found in the image itself, for example in a QR code. Empty if
            no URL was found. URLs found in the text of the image are returned
            in `ocrAnalysis.textAnalysis.detectedUrls`. Detected URLs do not
            change the classifications. *Additional pricing may apply.*
          items:
            $ref: '#/components/schemas/bodyguard.std.v1.DetectedUrl'
        ocrAnalysis:
          description: >-
            Text extracted from the image by OCR, together with a text analysis.
            `null` if OCR is disabled or no text was found in the image.
          oneOf:
            - $ref: >-
                #/components/schemas/bodyguard.analyze.v1.ImageAnalysis.OcrAnalysis
            - type: 'null'
    bodyguard.analyze.v1.ImageAnalysis.ClassificationMeta:
      type: object
      description: >-
        Additional metadata for each detected image classification. Keys match
        entries in `classifications`.
      properties:
        confidenceScore:
          type: number
          format: float
          minimum: 0
          maximum: 1
          description: >-
            Bodyguard's confidence that the classification applies to the image,
            between `0` and `1`. Higher means more confident. Relying on this
            score is discouraged: Bodyguard already filters out classifications
            whose confidence is too low, so the presence of a classification in
            the response is the signal you should use to decide whether to act
            on it.
    bodyguard.std.v1.DetectedUrl:
      type: object
      description: A URL found in the analyzed content.
      properties:
        url:
          type: string
          description: The URL found in the content.
    bodyguard.analyze.v1.ImageAnalysis.OcrAnalysis:
      type: object
      properties:
        text:
          type: string
          description: The text snippet extracted from the image.
        textAnalysis:
          $ref: '#/components/schemas/bodyguard.analyze.v1.TextAnalysis'
    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
        detectedUrls:
          type: array
          description: URLs found in the text. Empty if no URL was found.
          items:
            $ref: '#/components/schemas/bodyguard.std.v1.DetectedUrl'
        textSequence:
          $ref: '#/components/schemas/bodyguard.analyze.v1.TextAnalysis.TextSequence'
          description: >-
            Present only when the [text
            sequence](/en/api-reference/concepts#text-sequence) ending with this
            text was detected as problematic. Absent otherwise.
    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'
    bodyguard.analyze.v1.TextAnalysis.TextSequence:
      type: object
      description: >-
        Analysis of consecutive texts from the same author on the same post,
        combined into one text. See [text
        sequence](/en/api-reference/concepts#text-sequence).
      properties:
        references:
          type: array
          description: >-
            The `reference` of every text in the sequence, in order, including
            the current one.
          items:
            type: string
        textAnalysis:
          $ref: '#/components/schemas/bodyguard.analyze.v1.TextAnalysis'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      x-default: ApiKey <your-api-key>
      description: |
        API key authentication. Provide your key in the `Authorization`
        header with the `ApiKey` scheme:
        ```
        Authorization: ApiKey <your-api-key>
        ```

````

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