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

# Upload image

> Upload an image file (multipart/form-data). Allowed: JPEG, PNG, GIF, WebP; max 10 MB. With `kind=file`, stores a hosted document instead and answers its resource, normally in `state` `scanning` until the malware scan finishes; read it again with `GET /api/file-upload/{fileId}`.



## OpenAPI

````yaml /openapi.json post /api/file-upload
openapi: 3.0.0
info:
  description: >-
    Public REST API for Benchmark Email.


    Authenticate every request by including your API key in the `X-API-Key`
    header.

    Each key is issued with one or more scopes that control which endpoints it
    may call.


    Rate limits: 60 requests per minute per account.

    Monthly quota: determined by your subscription plan.


    Contact text field values are HTML-entity encoded. When a contact is
    created, updated or imported, Benchmark stores its text field values
    HTML-entity escaped: `&` `<` `>` `"` `'` `/` `\` and the backtick become
    `&amp;` `&lt;` `&gt;` `&quot;` `&#x27;` `&#x2F;` `&#x5C;` and `&#96;`.
    Responses return that stored form (for example `Maple &amp; Co` for `Maple &
    Co`), so decode values before displaying them. Send plain, unescaped text in
    requests and search filters: Benchmark escapes it before storing or matching
    it. Create and update also remove anything that looks like an HTML tag,
    including the text after a bare `<`.
  title: Benchmark Email API
  version: 1.0.0
servers:
  - description: >-
      Your account's API base URL. Copy the full URL shown on Settings > API
      Keys in your Benchmark Email account and paste it here.
    url: '{apiBaseUrl}'
    variables:
      apiBaseUrl:
        default: ''
        description: >-
          Your account's API base URL. Copy it from Settings > API Keys in your
          Benchmark Email account.
security:
  - apiKeyAuth: []
tags:
  - description: Account related endpoints
    name: account
  - description: File upload (Unlayer custom storage) endpoints
    name: file-upload
  - description: Contact related endpoints
    name: contact
  - description: Contact structure related endpoints
    name: contact-structure
  - description: List related endpoints
    name: lists
  - description: Contact import related endpoints
    name: contact-import
  - description: Email domain related endpoints
    name: email-domain
  - description: Email campaign related endpoints
    name: email-campaign
  - description: Email template related endpoints
    name: email-template
  - description: Report related endpoints
    name: reports
paths:
  /api/file-upload:
    post:
      tags:
        - file-upload
      summary: Upload image
      description: >-
        Upload an image file (multipart/form-data). Allowed: JPEG, PNG, GIF,
        WebP; max 10 MB. With `kind=file`, stores a hosted document instead and
        answers its resource, normally in `state` `scanning` until the malware
        scan finishes; read it again with `GET /api/file-upload/{fileId}`.
      operationId: uploadFile
      parameters:
        - description: >-
            Source recorded on the stored file. Defaults to `upload`; files
            stored under other sources are excluded from the default listing.
          in: query
          name: source
          required: false
          schema:
            default: upload
            enum:
              - upload
              - brand-kit
            type: string
        - description: >-
            When `true`, an identical active image of the same source (same
            bytes and file name) is returned with `deduplicated: true` instead
            of a new copy, so the file is not stored again when an identical
            active image already exists.
          in: query
          name: dedupe
          required: false
          schema:
            default: 'false'
            enum:
              - 'true'
              - 'false'
            type: string
        - description: >-
            Set to `file` for a hosted document (.pdf, .docx, .pptx, .csv, .txt,
            at most 10 MB) used by the Benchmark email editor's file links.
            `kind=file` is for the email editor only: requests authenticated
            with an API key receive 403. With `kind=file`, `source` and `dedupe`
            are rejected on upload, and `fileType`, `source`, `includeImported`
            and `sort` on the list. Omit it for the image library.
          in: query
          name: kind
          required: false
          schema:
            enum:
              - file
            type: string
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                file:
                  format: binary
                  type: string
              required:
                - file
              type: object
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                anyOf:
                  - properties:
                      createdAt:
                        format: date-time
                        type: string
                      deduplicated:
                        description: >-
                          Present only when `dedupe=true`. True when an
                          identical active image of the same source already
                          existed and that file was returned instead of a new
                          copy
                        type: boolean
                      fileId:
                        format: uuid
                        type: string
                      fileSize:
                        type: integer
                      height:
                        description: Image height in pixels when known
                        minimum: 1
                        type: integer
                      mimeType:
                        type: string
                      originalName:
                        type: string
                      url:
                        format: uri
                        type: string
                      width:
                        description: Image width in pixels when known
                        minimum: 1
                        type: integer
                    type: object
                  - description: A hosted document, answered for kind=file.
                    properties:
                      createdAt:
                        format: date-time
                        type: string
                      downloadUrl:
                        description: Present only when state is ready.
                        format: uri
                        type: string
                      fileId:
                        format: uuid
                        type: string
                      fileSize:
                        type: integer
                      kind:
                        enum:
                          - file
                        type: string
                      mimeType:
                        type: string
                      originalName:
                        type: string
                      state:
                        enum:
                          - scanning
                          - ready
                          - rejected
                          - unavailable
                        type: string
                    required:
                      - fileId
                      - kind
                      - originalName
                      - mimeType
                      - fileSize
                      - createdAt
                      - state
                    type: object
          description: >-
            Image stored, or (with `dedupe=true`) an identical existing image
            returned
        '400':
          content:
            application/json:
              example:
                errors:
                  - debug:
                      allowedExtensions:
                        - .pdf
                        - .docx
                        - .pptx
                        - .csv
                        - .txt
                    errorType: InvalidTypeError
                    field: file
                    message: >-
                      This file type or format isn't supported. Accepted: .pdf,
                      .docx, .pptx, .csv, .txt
              schema:
                properties:
                  errors:
                    description: List of application errors
                    items:
                      properties:
                        debug:
                          description: Error details, when the error has any
                          type: object
                        errorType:
                          description: >-
                            Error code (e.g. ContactFieldInUseError,
                            ValidationError)
                          type: string
                        field:
                          description: Field path when applicable
                          type: string
                        fieldId:
                          description: Field identifier when applicable
                          type: string
                        message:
                          description: Human-readable error message
                          type: string
                      required:
                        - message
                        - errorType
                      type: object
                    type: array
                required:
                  - errors
                type: object
          description: >-
            Invalid file type or size, or a `source` or `dedupe` value outside
            its allowed values, which is rejected as `ModelValidationError`.
            Allowed: JPEG, PNG, GIF, WebP; max 10 MB. With `kind=file`: a `kind`
            value other than `file`, or `source` or `dedupe` present
            (`ModelValidationError`); an extension, file name, declared type or
            content that is not an accepted document, accepted: .pdf, .docx,
            .pptx, .csv, .txt (`InvalidTypeError`, `debug.allowedExtensions`); a
            body whose `Content-Length` is over 10 MB (`MaxSizeFieldError`,
            `debug.maxSizeMb`); no `file` part (`RequiredFieldError`); a file
            outside the `file` field, a second file, or an oversized or unnamed
            form field (`ModelValidationError`); an account with no grey-label
            domain (`ValidationError`); UTF-16 text without a byte-order mark
            (`TextEncodingNotSupportedError`); a PDF with embedded files
            (`EmbeddedAttachmentsError`); a CSV cell that starts a formula
            (`SpreadsheetFormulaError`); or a PDF that cannot be inspected
            (`FileNotInspectableError`).
        '403':
          description: >-
            API key missing the files:write scope; with `kind=file`, any API
            key, or an account without file attachments (`ForbiddenError`)
        '413':
          content:
            application/json:
              example:
                errors:
                  - errorType: MaxSizeFieldError
                    field: file
                    message: File too large
              schema:
                properties:
                  errors:
                    description: List of application errors
                    items:
                      properties:
                        debug:
                          description: Not present on this response
                          type: object
                        errorType:
                          description: >-
                            Error code (e.g. ContactFieldInUseError,
                            ValidationError)
                          type: string
                        field:
                          description: Field path when applicable
                          type: string
                        fieldId:
                          description: Field identifier when applicable
                          type: string
                        message:
                          description: Human-readable error message
                          type: string
                      required:
                        - message
                        - errorType
                      type: object
                    type: array
                required:
                  - errors
                type: object
          description: >-
            The file passed 10 MB while it was being received
            (`MaxSizeFieldError`, the same `errorType` as the 400 for a
            `Content-Length` already over the limit). A body larger than 10 MB
            may get either status.
        '429':
          content:
            application/json:
              example:
                errors:
                  - debug:
                      limit: 50
                      retryAfter: 3600
                    errorType: FileUploadRateLimitedError
                    message: Daily file upload limit reached. Try again later.
              schema:
                properties:
                  errors:
                    description: List of application errors
                    items:
                      properties:
                        debug:
                          properties:
                            limit:
                              description: Uploads allowed per limit window
                              type: integer
                            retryAfter:
                              description: >-
                                Seconds to wait; the same value as the
                                Retry-After header
                              type: integer
                          type: object
                        errorType:
                          description: >-
                            Error code (e.g. ContactFieldInUseError,
                            ValidationError)
                          type: string
                        field:
                          description: Field path when applicable
                          type: string
                        fieldId:
                          description: Field identifier when applicable
                          type: string
                        message:
                          description: Human-readable error message
                          type: string
                      required:
                        - message
                        - errorType
                        - debug
                      type: object
                    type: array
                required:
                  - errors
                type: object
          description: >-
            With `kind=file`: the account's file upload limit is reached
            (`FileUploadRateLimitedError`). Retry after the number of seconds in
            `Retry-After`.
          headers:
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
        '503':
          content:
            application/json:
              example:
                errors:
                  - debug:
                      retryAfter: 5
                    errorType: ServiceUnavailableError
                    message: File uploads are temporarily unavailable. Try again.
              schema:
                properties:
                  errors:
                    description: List of application errors
                    items:
                      properties:
                        debug:
                          properties:
                            retryAfter:
                              description: >-
                                Seconds to wait; the same value as the
                                Retry-After header
                              type: integer
                          type: object
                        errorType:
                          description: >-
                            Error code (e.g. ContactFieldInUseError,
                            ValidationError)
                          type: string
                        field:
                          description: Field path when applicable
                          type: string
                        fieldId:
                          description: Field identifier when applicable
                          type: string
                        message:
                          description: Human-readable error message
                          type: string
                      required:
                        - message
                        - errorType
                        - debug
                      type: object
                    type: array
                required:
                  - errors
                type: object
          description: >-
            With `kind=file`: uploads are paused, or storage, the upload limiter
            or the document check is unavailable or busy
            (`ServiceUnavailableError`). Nothing is stored. Retry after the
            number of seconds in `Retry-After`.
          headers:
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
      security:
        - apiKeyAuth: []
components:
  securitySchemes:
    apiKeyAuth:
      description: API key authentication
      in: header
      name: X-API-Key
      type: apiKey

````

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