Skip to content
Last updated

Create a Label

Endpoint:

POST https://api.mailjet.com/v1/rest/labels

You can create a label using this endpoint. Labels can be used to categorize resources (templates) or images for better organization.

Body Parameters

NameTypeDescription
NamestringRequired and unique.
ColorstringRequired and should be a valid hexadecimal color (e.g., #FFFFFF).
UsedForstringIndicates if the label is used for a template (resource) or an image. Possible values are image or resource. Default is resource.

Request Example for a Template Label:

curl --request POST \
  --url https://api.mailjet.com/v1/rest/labels/ \
  --header 'Authorization: Bearer 612d5125131d406081abb9cd2afdc4e3' \
  --header 'Content-Type: application/json' \
  --data '{
    "Name": "Sport templates",
    "Color": "#FFFFFF",
    "UsedFor": "resource"
}'

Status code: 201

Request Example for an Image Label:

curl --request POST \
  --url https://api.mailjet.com/v1/rest/labels/ \
  --header 'Authorization: Bearer 612d5125131d406081abb9cd2afdc4e3' \
  --header 'Content-Type: application/json' \
  --data '{
    "Name": "Cat images",
    "Color": "#FFFFFF",
    "UsedFor": "image"
}'

Status code: 201

Response Data Field Structure

NameTypeDescription
IDintegerThe ID of the label.
NamestringThe name of the label.
ColorstringThe hexidecimal color of the label.
UsedForstringIndicates if the label is used for a template (resource) or an image

API Response Example for a Template Label:

{
    "Count": 1,
    "Total": 1,
    "Data": [
      {   
          "ID": 5,
          "OrganisationID": 2,
          "Name": "Sport templates",
          "Color": "#FFFFFF",
          "UsedFor": "resource"
      }
    ]
}

API Response Example for an Image Label:

{
    "Count": 1,
    "Total": 1,
    "Data": [
      {
        "ID": 6,
        "OrganisationID": 2,
        "Name": "Cat images",
        "Color": "#FFFFFF",
        "UsedFor": "image"
      }
    ]
}