---
title: Retrieve a mail ID
slug: campaign/api/retrieve-a-mail-id
docTags: 
createdAt: 2026-09-02T15:04:15.718Z
---

{
  "id": "3_o1Q9Q-qJJ980SL7CbFf",
  "type": "api-oas-v2",
  "data": {
    "method": "GET",
    "url": "https://api.campaign.episerver.net/rest/{clientId}/mailid",
    "servers": [
      {
        "url": "https://api.campaign.episerver.net/rest/{clientId}/mailid"
      }
    ],
    "name": "Retrieve a mail ID",
    "description": "<p>Retrieve a mail ID (for further usage). A mail ID is the aggregation of the mailing ID, recipient list ID and recipient ID.</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "clientId",
          "type": "string",
          "description": "Client ID"
        }
      ],
      "headerParameters": [
        {
          "name": "accept",
          "type": "string",
          "kind": "optional",
          "description": "Generated from available response content types",
          "enum": [
            "application/json",
            "application/vnd.optivo.broadmail.v1+json"
          ],
          "default": "application/json"
        }
      ],
      "queryParameters": [
        {
          "kind": "required",
          "name": "MailingToUserID",
          "type": "integer<int64>",
          "description": "MailingToUserID",
          "format": "int64"
        }
      ],
      "bodyDataParameters": [],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "Authorization",
          "name": "Authorization",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "The mail ID information was retrieved successfully.",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "RestMailId",
            "schema": [
              {
                "name": "mailId",
                "kind": "optional",
                "type": "string",
                "description": "Encoded mail ID"
              }
            ],
            "modelRef": "#/components/schemas/RestMailId",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "A valid mailingToUserId must be provided.",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "409",
        "description": "The indicated mailingToUser ID is not assigned to the indicated client. Ensure that \"clientId\" and \"mailingToUserId\" are correct and that \"mailingToUserId\" is assigned to the indicated client.",
        "jsonExample": "",
        "isExpanded": true
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "zv4TqjilTkXON5NgeaDGK",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request GET \\\n     --url 'https://api.campaign.episerver.net/rest/{clientId}/mailid?MailingToUserID=integer%3Cint64%3E' \\\n     --header 'accept: application/json'"
        },
        {
          "id": "2OOjV8_2BJ_GNZMcFn0yC",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar requestOptions = {\n   method: 'GET',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.campaign.episerver.net/rest/{clientId}/mailid?MailingToUserID=integer<int64>\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "Whuc73oh3BBKYQqXW4pgy",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.campaign.episerver.net/rest/{clientId}/mailid?MailingToUserID=integer<int64>\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Get.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "-Dn9dlp5I8UZkvsxUPKIl",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.campaign.episerver.net/rest/{clientId}/mailid?MailingToUserID=integer<int64>\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"GET\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "zv4TqjilTkXON5NgeaDGK"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// The mail ID information was retrieved successfully.\n{\n  \"mailId\": \"\"\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// A valid mailingToUserId must be provided.\n"
        },
        {
          "id": "response-2-409",
          "language": "409",
          "code": "// The indicated mailingToUser ID is not assigned to the indicated client. Ensure that \"clientId\" and \"mailingToUserId\" are correct and that \"mailingToUserId\" is assigned to the indicated client.\n"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}