Skip to content

Upload an Image

Endpoint:

POST https://api.mailjet.com/v1/data/images

Upload an image along with its metadata. This endpoint accepts multipart/mixed and multipart/form-data where the image file and its metadata are submitted together.

The maximum upload size for a single image is 2MB. Image files that will be used in emails should not exceed 200 KB to optimize loading times.

Request Content Type

multipart/mixed or multipart/form-data

Request Parts:

file (required): The binary data of the image. Supported content types: image/jpeg, image/png, image/svg, image/gif, image/webp. Metadata(required): A JSON object containing the following body parameters:

NameTypeDescription
NamestringRequired.
StatusstringRequired. Accepted values: open or locked.
LabelIDsarray of integersAn array of IDs representing labels associated with the image.
IsStarredbooleanIndicates whether the template is marked as a favorite. True = favorite.

Example Request

curl --request POST \
  --url https://api.mailjet.com/v1/data/images \
  --header 'Authorization: Bearer 612d5125131d406081abb9cd2afdc4e3' \
  --form 'file=@"postman-cloud:///1eee6a09-165d-4570-99d2-1e863ed3ac2c";type=image/jpeg' \
  --form 'Metadata="{
\"Name\": \"My Image\",
\"Status\": \"open\"
}";type=application/json'

Status code: 201

Response Data Field Structure

NameTypeDescription
IDstringThe ID of the image.
NamestringThe name of the image.
StatusstringIndicates whether the image is open or locked.
TargetContentstringIndicates the purpose of the image. Possible values: image, background, video or social.
ImageSizeintegerThe size of the image file in bytes.
LabelIDsarray of integersAn array of IDs representing labels associated with the image.
IsStarredbooleanIndicates whether the image is marked as a favorite.
ImageURLstringThe URL where the image is stored.
ThumbnailUrlstringThe URL where the thumbnail is stored.
CreatedAtDateTime UTCThe date and time when the image was created.
UpdatedAtDateTime UTCThe date and time when the image was last updated.
ExpiresAtDateTime UTCThe date and time when the image will expire.

API Response

{
    "Count": 1,
    "Total": 1,
    "Data": [
        {
            "ID": "a3da1de2-2319-44e9-9c75-e6a00a2ec5da",
            "OrganisationID": 2,
            "Name": "My Image",
            "Status": "open",
            "TargetContent": "image",
            "ImageSize": 425155,
            "ThumbnailSize": 0,
            "TotalSize": 425155,
            "LabelIDs": [],
            "IsStarred": false,
            "ImageUrl": "https://0abcd.mjt.lu/img2/0abcd/a3da1de2-2319-44e9-9c75-e6a00a2ec5da/content",
            "ThumbnailUrl": null,
            "CreatedAt": "2024-05-23T12:51:58.97041Z",
            "UpdatedAt": "2024-05-23T12:51:58.97041Z",
            "ExpiresAt": "2024-12-10T00:00:00Z"
        }
    ]
}