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:
| Name | Type | Description |
|---|---|---|
Name | string | Required. |
Status | string | Required. Accepted values: open or locked. |
LabelIDs | array of integers | An array of IDs representing labels associated with the image. |
IsStarred | boolean | Indicates whether the template is marked as a favorite. True = favorite. |
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
| Name | Type | Description |
|---|---|---|
ID | string | The ID of the image. |
Name | string | The name of the image. |
Status | string | Indicates whether the image is open or locked. |
TargetContent | string | Indicates the purpose of the image. Possible values: image, background, video or social. |
ImageSize | integer | The size of the image file in bytes. |
LabelIDs | array of integers | An array of IDs representing labels associated with the image. |
IsStarred | boolean | Indicates whether the image is marked as a favorite. |
ImageURL | string | The URL where the image is stored. |
ThumbnailUrl | string | The URL where the thumbnail is stored. |
CreatedAt | DateTime UTC | The date and time when the image was created. |
UpdatedAt | DateTime UTC | The date and time when the image was last updated. |
ExpiresAt | DateTime UTC | The date and time when the image will expire. |
{
"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"
}
]
}