openapi: 3.1.0

info:
  title: CopySight API
  version: 1.1.0
  summary: Detect intellectual property in images and video.
  description: |
    Analyze an image or video and receive the intellectual property detected
    in it: trademarks, brand designs, characters, public figures and artworks,
    each with a location and a similarity score.

    Call the API from your backend and branch on HTTP status codes; error
    bodies are plain text or JSON depending on the status. Results are a
    detection signal, not a legal determination.
  contact:
    name: CopySight support
    email: hello@copysight.ai
    url: https://copysight.ai/docs

externalDocs:
  description: API documentation
  url: https://copysight.ai/docs

servers:
  - url: https://api.copysight.ai/v1
    description: Production

security:
  - ApiKeyAuth: []

tags:
  - name: Analysis
    description: Image and video analysis.

paths:
  /verify:
    post:
      operationId: verifyMedia
      tags: [Analysis]
      summary: Analyze an image or video
      description: >-
        Analyzes one image or video and returns the intellectual property
        detected in it. The result is returned in the response.
      x-codeSamples:
        - lang: Shell
          label: Image file
          source: |
            curl -X POST "https://api.copysight.ai/v1/verify" \
              -H "X-API-Key: $COPYSIGHT_API_KEY" \
              -F "file=@artwork.png"
        - lang: Shell
          label: URL, with V2 detection
          source: |
            curl -X POST "https://api.copysight.ai/v1/verify" \
              -H "X-API-Key: $COPYSIGHT_API_KEY" \
              -F "url=https://example.com/artwork.png" \
              -F "advanced=true"
        - lang: Shell
          label: Video
          source: |
            curl -X POST "https://api.copysight.ai/v1/verify" \
              -H "X-API-Key: $COPYSIGHT_API_KEY" \
              -F "file=@spot.mp4" \
              -F "scene_change_sensitivity=0.10"
      requestBody:
        required: true
        description: >-
          Use `multipart/form-data` for file uploads and for requests that set
          options. `application/json` accepts a `url` only.
        content:
          multipart/form-data:
            schema:
              $ref: "#/components/schemas/VerifyRequest"
          application/json:
            schema:
              $ref: "#/components/schemas/VerifyUrlRequest"
            example:
              url: https://example.com/artwork.png
      responses:
        "200":
          description: >-
            Analysis result: `ImageResult` for an image, `VideoResult` for a
            video.
          headers:
            X-Request-Id:
              $ref: "#/components/headers/X-Request-Id"
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: "#/components/schemas/ImageResult"
                  - $ref: "#/components/schemas/VideoResult"
              examples:
                image:
                  summary: Image
                  value:
                    contains_face: false
                    detected_ips:
                      - name: Mickey Mouse
                        category: Characters
                        author: Walt Disney and Ub Iwerks
                        owner: The Walt Disney Company
                        bounding_box:
                          x: 0.277
                          y: 0.469
                          width: 0.021
                          height: 0.022
                        similarity: 0.98
                video:
                  summary: Video
                  value:
                    media_type: video
                    frames_analyzed: 12
                    duration_seconds: 27.4
                    contains_face: true
                    detected_ips:
                      Mickey Mouse:
                        category: Characters
                        author: Walt Disney and Ub Iwerks
                        owner: The Walt Disney Company
                        max_similarity: 0.98
                        occurrence_count: 2
                        occurrences:
                          - timecode: 4.0
                            timecode_label: "0:04"
                            similarity: 0.91
                            bounding_box:
                              x: 0.1
                              y: 0.2
                              width: 0.22
                              height: 0.14
                          - timecode: 19.0
                            timecode_label: "0:19"
                            similarity: 0.98
                            bounding_box:
                              x: 0.55
                              y: 0.31
                              width: 0.19
                              height: 0.12
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "413":
          $ref: "#/components/responses/PayloadTooLarge"
        "422":
          $ref: "#/components/responses/UnprocessableMedia"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/ServerError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"

components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key, prefixed `cs_live_`. Keep it server-side.

  headers:
    X-Request-Id:
      description: Request identifier. Include it in support requests.
      schema:
        type: string
        example: 8ef969bdcfeeb912349304bc7feda354

  responses:
    BadRequest:
      description: >-
        The request is invalid: no media was provided, the file is empty, or
        the `url` is not a reachable `http(s)` address. Do not retry
        unchanged.
      content:
        text/plain:
          schema:
            type: string
          example: "Bad Request: provide a 'file' or a 'url'."
    Unauthorized:
      description: The API key is missing, invalid or revoked.
      content:
        text/plain:
          schema:
            type: string
          example: Unauthorized. Missing API Key.
    PaymentRequired:
      description: >-
        The account has no credits remaining. Do not retry until credits are
        added.
      content:
        text/plain:
          schema:
            type: string
          example: "Payment Required: Insufficient credits."
    PayloadTooLarge:
      description: >-
        The media exceeds the size limit: 32 MB for `file`, 200 MB for `url`.
      content:
        text/plain:
          schema:
            type: string
          example: Payload Too Large.
    UnprocessableMedia:
      description: >-
        The media could not be decoded or has no analyzable content. Do not
        retry unchanged.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error: The image could not be processed. Please ensure it is a valid format and try again.
    TooManyRequests:
      description: >-
        Rate limit exceeded. Retry after the `Retry-After` interval when
        present, otherwise with exponential backoff.
      headers:
        Retry-After:
          description: Seconds to wait before retrying.
          schema:
            type: integer
    ServerError:
      description: Unexpected server error. Safe to retry once.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error: An internal server error occurred. Our team has been notified.
        text/plain:
          schema:
            type: string
    ServiceUnavailable:
      description: The service is temporarily unavailable.
      content:
        text/plain:
          schema:
            type: string
          example: Service temporarily unavailable.

  schemas:
    VerifyRequest:
      type: object
      description: One media item, provided as `file` or `url`.
      anyOf:
        - required: [file]
        - required: [url]
      properties:
        file:
          type: string
          format: binary
          description: >-
            Image or video file, up to 32 MB. Takes precedence over `url`.
        url:
          type: string
          format: uri
          description: >-
            Public or pre-signed `http(s)` URL of the media, up to 200 MB.
            Fetched without credentials, as user agent `CopysightBot/1.0`.
        advanced:
          type: boolean
          default: false
          description: >-
            Detection version. `false` selects V1; `true` selects V2, which
            is higher-precision. The response format is unchanged. Form field
            only.
        scene_change_sensitivity:
          type: number
          minimum: 0
          maximum: 1
          default: 0.15
          description: >-
            Video only. Scene-change threshold for frame selection. Lower
            values analyze more frames. Form field only.
        sensitivity:
          type: number
          minimum: 0
          maximum: 1
          deprecated: true
          description: Deprecated alias of `scene_change_sensitivity`.

    VerifyUrlRequest:
      type: object
      description: URL submission as JSON. Options are not accepted; defaults apply.
      required: [url]
      properties:
        url:
          type: string
          format: uri
          description: Public or pre-signed `http(s)` URL of the media.

    Error:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Human-readable message. Subject to change.

    IpCategory:
      type: string
      description: Intellectual property category.
      enum:
        - Trademarks
        - Brand and iconic designs
        - Characters
        - Celebrities and famous people
        - Art and artists

    BoundingBox:
      type: object
      description: >-
        Location of the detection, as fractions of the image or frame
        dimensions.
      required: [x, y, width, height]
      properties:
        x:
          type: number
          minimum: 0
          maximum: 1
          description: Left edge.
        y:
          type: number
          minimum: 0
          maximum: 1
          description: Top edge.
        width:
          type: number
          minimum: 0
          maximum: 1
          description: Box width.
        height:
          type: number
          minimum: 0
          maximum: 1
          description: Box height.

    DetectedIp:
      type: object
      required: [name, category, author, owner, bounding_box, similarity]
      properties:
        name:
          type: string
          description: Name of the intellectual property.
        category:
          $ref: "#/components/schemas/IpCategory"
        author:
          type: string
          description: Original creator, or `"N/A"`.
        owner:
          type: string
          description: Current rights holder, or `"N/A"`.
        bounding_box:
          $ref: "#/components/schemas/BoundingBox"
        similarity:
          type: number
          minimum: 0
          maximum: 1
          description: Similarity score, from 0 to 1.

    ImageResult:
      type: object
      description: Result for an image.
      required: [contains_face, detected_ips]
      properties:
        contains_face:
          type: boolean
          description: Whether the image contains a human face.
        detected_ips:
          type: array
          description: Detected intellectual property. Empty when none is detected.
          items:
            $ref: "#/components/schemas/DetectedIp"

    VideoOccurrence:
      type: object
      required: [timecode, timecode_label, similarity, bounding_box]
      properties:
        timecode:
          type: number
          description: Seconds from the start of the video.
        timecode_label:
          type: string
          description: Timecode formatted as `M:SS`.
        similarity:
          type: number
          minimum: 0
          maximum: 1
          description: Similarity score in this frame, from 0 to 1.
        bounding_box:
          $ref: "#/components/schemas/BoundingBox"

    VideoDetectedIp:
      type: object
      required: [category, author, owner, max_similarity, occurrence_count, occurrences]
      properties:
        category:
          $ref: "#/components/schemas/IpCategory"
        author:
          type: string
          description: Original creator, or `"N/A"`.
        owner:
          type: string
          description: Current rights holder, or `"N/A"`.
        max_similarity:
          type: number
          minimum: 0
          maximum: 1
          description: Highest similarity score across occurrences.
        occurrence_count:
          type: integer
          description: Number of analyzed frames containing the IP.
        occurrences:
          type: array
          description: Occurrences in chronological order.
          items:
            $ref: "#/components/schemas/VideoOccurrence"

    VideoResult:
      type: object
      description: Result for a video.
      required: [media_type, frames_analyzed, contains_face, detected_ips]
      properties:
        media_type:
          type: string
          const: video
          description: Always `"video"`. Present on video results only.
        frames_analyzed:
          type: integer
          description: Number of frames analyzed.
        duration_seconds:
          type: number
          description: Timecode of the last analyzed frame, in seconds.
        source_duration_seconds:
          type: number
          description: Duration of the source video, in seconds, when available.
        resolution:
          type: object
          description: Pixel dimensions of the source video, when available.
          properties:
            width:
              type: integer
              description: Width in pixels.
            height:
              type: integer
              description: Height in pixels.
        contains_face:
          type: boolean
          description: Whether any analyzed frame contains a human face.
        detected_ips:
          type: object
          description: Detected intellectual property, keyed by name. Empty when none is detected.
          additionalProperties:
            $ref: "#/components/schemas/VideoDetectedIp"
