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

# Upload Image

> Uploads an image to the API

### Description

The first step to start processing images with the IMG Processing API is
to create an [Image Object](/api-reference/endpoints/image).
You can create an Image object by uploading an image file
or by [providing a URL](/api-reference/endpoints/creation/create) to an existing image.

This endpoint allows you to create an Image object by uploading an image file.

To upload an image, you need to send a `multipart/form-data` request to the API with the image
file as a `File` object stringified in the `image` field, and `name` field with the name of the image for identification purposes.

***


## OpenAPI

````yaml openapi.json post /v1/images/upload
openapi: 3.1.0
info:
  title: IMG Processing API
  description: >
    This powerful and flexible API provides a wide range of

    image manipulation and analysis capabilities, allowing developers to
    integrate advanced image processing

    features into their applications with ease.
  version: 1.0.0
servers:
  - url: https://api.img-processing.com
    description: IMG Processing API Server
security:
  - ApiKeyAuth: []
paths:
  /v1/images/upload:
    post:
      tags:
        - Creation Endpoints
      summary: Upload Image
      description: >-
        The first step to start processing images with the IMG Processing API is
        to create an Image Object. You can create an Image object by uploading
        an image file or by providing a URL to an existing image.


        This endpoint allows you to create an Image object by uploading an image
        file.


        To upload an image, you need to send a multipart/form-data request to
        the API with the image file as a File object stringified in the image
        field, and name field with the name of the image for identification
        purposes.
      operationId: uploadImage
      parameters: []
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 30
                  description: The name of the image to identify it on the dashboard.
                image:
                  type: string
                  format: binary
                  description: >-
                    The image file to upload. It must be a valid image format
                    (jpeg, png, webp) and not larger than 20MB.
              required:
                - name
                - image
              examples:
                - name: example-image
                  image: {}
      responses:
        '201':
          description: The API will return the created Image object in the response body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageObject'
        '401':
          description: >-
            Error object for unauthorized access. Probably due to missing or
            invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '422':
          description: Error object for validation errors.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
        '429':
          description: Error object for rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
        5XX:
          description: Error object for internal server errors.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServerError'
components:
  schemas:
    ImageObject:
      type: object
      properties:
        id:
          type: string
          description: >-
            The unique identifier of the image. This identifier is used to
            reference the image in subsequent requests.
        name:
          type: string
          description: >-
            The name of the image. This name is provided when uploading the
            image and is the way the image is identified in your account. It is
            not unique, in fact, each transformation you make to an image will
            create a new image with the same name.
        url:
          type:
            - string
            - 'null'
          description: >-
            The public URL of the image. By default, this URL is not available
            and will be `null`. You can make the image public by using the
            publish endpoint. Once the image is public, the URL will be updated
            with the public UR.
        width:
          type: number
          description: The width of the image in pixels.
        height:
          type: number
          description: The height of the image in pixels.
        format:
          type: string
          enum:
            - png
            - jpeg
            - webp
          description: >-
            The format of the image. The format can be one of the following:
            `jpeg`, `png`, `webp`
        size:
          type: number
          description: >-
            The estimated size of the image in bytes. The size is an estimate
            and may not be exact since images can be compressed or optimized
            depending on the format and quality settings used during processing.
        created_at:
          type: string
          format: date-time
          description: >-
            The date and time when the image was created. The date and time are
            in ISO 8601 format.
      required:
        - id
        - name
        - width
        - height
        - format
        - size
        - created_at
      title: Image Object
      description: >-
        The Image object represents an image processed using the IMG Processing
        API. The object contains information about the image, such as its URL,
        size, and format. The Image object is returned in the response body of
        all image processing requests.
      examples:
        - id: image_etm0g3x5iap4cld1qcfsjvo2
          name: Processed Image
          url: >-
            https://storage.img-processing.com/images/image_etm0g3x5iap4cld1qcfsjvo2
          width: 460
          height: 460
          format: jpeg
          size: 282000
          created_at: '2021-09-01T12:00:00.000Z'
    UnauthorizedError:
      type: object
      properties:
        type:
          type: string
          description: The type of error
        error:
          type: string
          description: The title of the error
        status:
          type: number
          const: 401
          description: The status of the error
        message:
          type: string
          description: The error message
      required:
        - type
        - error
        - status
        - message
      title: Unauthorized Error
      description: >-
        Error object for unauthorized access. Probably due to missing or invalid
        API key
      examples:
        - type: https://docs.img-processing.com/errors/unauthorized
          error: Unauthorized
          status: 401
          message: API key is required.
    ValidationError:
      type: object
      properties:
        type:
          type: string
          description: The type of error
        error:
          type: string
          description: The title of the error
        status:
          type: number
          const: 422
          description: The status of the error
        errors:
          type: array
          items:
            type: string
          description: The validation errors
      required:
        - type
        - error
        - status
        - errors
      title: Validation Error
      description: Error object for validation errors
      examples:
        - type: https://docs.img-processing.com/errors/validation-error
          error: Validation Error
          status: 422
          errors:
            - '{field or param} {error message}'
    RateLimitError:
      type: object
      properties:
        type:
          type: string
          description: The type of error
        error:
          type: string
          description: The title of the error
        status:
          type: number
          const: 429
          description: The status of the error
        message:
          type: string
          description: The error message
      required:
        - type
        - error
        - status
        - message
      title: Rate Limit Error
      description: Error object for rate limit exceeded.
      examples:
        - type: https://docs.img-processing.com/errors/too-many-requests
          error: Too Many Requests
          status: 429
          message: Rate limit exceeded. Try again later.
    ServerError:
      type: object
      properties:
        type:
          type: string
          description: The type of error
        error:
          type: string
          description: The title of the error
        status:
          type: number
          description: The status of the error
        message:
          type: string
          description: The error message
      required:
        - type
        - error
        - status
        - message
      title: Server Error
      description: Error object for internal server errors.
      examples:
        - type: https://docs.img-processing.com/errors/internal-error
          error: Internal Error
          status: 500
          message: >-
            An unexpected error occurred. Please try again later. If the problem
            persists, contact support.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API Key for authentication

````