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

# Upload Image

> Upload an image file to the CDN and receive the media file id, fileserver URL, and CDN URL in the response.

## Supported formats

jpeg, png, gif, webp, svg, bmp, tiff, and ico. Maximum file size is 50 MB.

## Example usage

```bash theme={null}
curl -X POST https://api.wizcommerce.com/v1/media/upload \
  -H "X-API-Key: YOUR_ACCESS_TOKEN_HERE" \
  -F "file=@/path/to/image.jpg" \
  -F "entity_type=misc"
```

The optional `entity_type` field defaults to `misc` when omitted.


## OpenAPI

````yaml post /v1/media/upload
openapi: 3.0.0
info:
  description: Open API's for WizCommerce API's
  title: WizCommerce Open API's
  termsOfService: https://wizcommerce.com/terms/
  contact:
    name: Tech Support
    url: https://help.wizcommerce.com/
    email: tech@wizcommerce.com
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
  version: '1.0'
servers:
  - url: https://api.wizcommerce.com
    description: Production BaseURL
  - url: https://api-staging.sourcerer.tech
    description: Staging BaseURL
security: []
paths:
  /v1/media/upload:
    post:
      tags:
        - Media
      summary: Upload Image
      description: >-
        Uploads an image file, stores it on the CDN, and returns its media file
        id, fileserver url and cdn url in real time.
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  description: Image file to upload (max 50 MB)
                  type: string
                  format: binary
                entity_type:
                  description: Entity type the image belongs to
                  type: string
                  default: misc
              required:
                - file
        required: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/dtos.SuccessResponse'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/mediafile.UploadImageResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.HttpError'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.HttpError'
        '413':
          description: Request Entity Too Large
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.HttpError'
        '415':
          description: Unsupported Media Type
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.HttpError'
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.HttpError'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.HttpError'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.HttpError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    dtos.SuccessResponse:
      type: object
      properties:
        data:
          x-order: '1'
    mediafile.UploadImageResponse:
      type: object
      properties:
        media_file_id:
          type: string
          x-order: '1'
          example: 4f0c8d2e-1a3b-4c5d-9e7f-0a1b2c3d4e5f
        url:
          type: string
          x-order: '2'
          example: >-
            https://images.example.com/files/4f0c8d2e-1a3b-4c5d-9e7f-0a1b2c3d4e5f
        cdn_url:
          type: string
          x-order: '3'
          example: >-
            https://cdn.example.com/assets/4f0c8d2e-1a3b-4c5d-9e7f-0a1b2c3d4e5f.jpg
    errors.HttpError:
      type: object
      properties:
        code:
          type: string
          x-order: '1'
        message:
          type: string
          x-order: '2'
        details:
          type: array
          items:
            $ref: '#/components/schemas/errors.HttpErrorDetails'
          x-order: '3'
    errors.HttpErrorDetails:
      type: object
      properties:
        field:
          type: string
          x-order: '1'
        reason:
          type: string
          x-order: '2'
  securitySchemes:
    ApiKeyAuth:
      description: API Key for authentication
      type: apiKey
      name: X-API-Key
      in: header

````