---
title: "Create a new product media file"
method: POST
path: "/api/rest/v1/media-files"
tags: ["Product media file"]
---

# Create a new product media file

`POST /api/rest/v1/media-files`

## Request

- Base URL: `http://demo.akeneo.com`
- URL: `http://demo.akeneo.com/api/rest/v1/media-files`
- Auth: none declared. Required headers: `Content-type`

This endpoint allows you to create a new media file and associate it to an attribute value of a given product or product model.

## Headers

- `Content-type` string, required

## Request body

- object
  - `product` string: The product to which the media file will be associated. It is a JSON string that follows this format '{"identifier":"product_identifier", "attribute":"attribute_code", "scope":"channel_code","locale":"locale_code"}'. You have to either use this field or the `product_model` field, but not both at the same time.
  - `product_model` string: The product model to which the media file will be associated. It is a JSON string that follows this format '{"code":"product_model_code", "attribute":"attribute_code", "scope":"channel_code","locale":"locale_code"}'. You have to either use this field or the `product` field, but not both at the same time.
  - `file` string, binary, required: The binaries of the file

## Response `201`

Created

## Other responses

- `400`: Bad request
- `401`: Authentication required
- `403`: Access forbidden
- `415`: Unsupported Media type
- `422`: Unprocessable entity

---

[API](https://skmtc.dev/akeneo/apis/akeneo-pim-rest-api.md) - [All operations](https://skmtc.dev/akeneo/apis/akeneo-pim-rest-api/llms.txt) - [OpenAPI document](https://skmtc.dev/akeneo/apis/akeneo-pim-rest-api/revisions/d8bda9b93b59?raw)
