---
title: Test a message template
slug: campaign/api/test-a-message-template
docTags: 
createdAt: 2026-09-02T15:04:15.718Z
---

{
  "id": "jRx6Qi3EcMaNpJRxvmYzW",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://api.campaign.episerver.net/rest/{clientId}/messagetemplates/{messageTemplateId}/test",
    "servers": [
      {
        "url": "https://api.campaign.episerver.net/rest/{clientId}/messagetemplates/{messageTemplateId}/test"
      }
    ],
    "name": "Test a message template",
    "description": "Send a test mailing to check content and layout of a message template before sending the actual mailing.",
    "contentType": "application/x-www-form-urlencoded",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "clientId",
          "type": "string",
          "description": "Client ID"
        },
        {
          "kind": "required",
          "name": "messageTemplateId",
          "type": "integer<int64>",
          "description": "Message template ID",
          "format": "int64"
        }
      ],
      "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": [],
      "bodyDataParameters": [],
      "formDataParameters": [
        {
          "name": "recipientIds",
          "kind": "required",
          "type": "array",
          "description": "<p>Comma-separated list of recipient IDs from the provided recipient list (\"recipientListId\"). If a recipient is not found in the provided recipient list, no test mailing will be sent to this recipient.</p>",
          "example": "",
          "itemType": "string",
          "customType": "string[]",
          "itemExample": "",
          "itemDefault": ""
        },
        {
          "name": "mimeType",
          "kind": "optional",
          "type": "string",
          "description": "<p>Mime type of the mailing during sending (use an empty string for the mailing mime type)</p>",
          "example": "text/plain, text/html, text/multipart"
        },
        {
          "name": "subject",
          "kind": "optional",
          "type": "string",
          "description": "<p>Subject of a test message template (if message template has a subject set)</p>"
        },
        {
          "name": "senderAddress",
          "kind": "optional",
          "type": "string",
          "description": "<p>Sender address for test message template (if message template has a sender address set)</p>"
        },
        {
          "name": "recipientListId",
          "kind": "required",
          "type": "integer<int64>",
          "description": "ID of the recipient list for the test mailing",
          "format": "int64"
        }
      ],
      "oAuthParameters": [
        {
          "id": "Authorization",
          "name": "Authorization",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "202",
        "description": "The message template was sent successfully.",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "MessageTemplateTestResponse",
            "schema": [
              {
                "name": "mailingId",
                "kind": "optional",
                "type": "integer<int64>",
                "description": "",
                "format": "int64"
              }
            ],
            "modelRef": "#/components/schemas/MessageTemplateTestResponse",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "oCp2KxPtYxJd1K6ocgRXn",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.campaign.episerver.net/rest/{clientId}/messagetemplates/{messageTemplateId}/test \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/x-www-form-urlencoded' \\\n     --data 'recipientIds=array' \\\n     --data 'recipientListId=integer<int64>'"
        },
        {
          "id": "VBM1aw_jG2hFjxhYhhjk4",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/x-www-form-urlencoded\");\n\nvar urlencoded = new URLSearchParams();\nurlencoded.append(\"recipientIds\", \"array\");\nurlencoded.append(\"recipientListId\", \"integer<int64>\");\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: urlencoded,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.campaign.episerver.net/rest/{clientId}/messagetemplates/{messageTemplateId}/test\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "IHVB9XNScRCCE489XeT5e",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.campaign.episerver.net/rest/{clientId}/messagetemplates/{messageTemplateId}/test\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/x-www-form-urlencoded\"\nrequest.body = \"recipientIds=array&recipientListId=integer%3Cint64%3E\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "pDH50Rb-InjSxY9bETQx9",
          "language": "python",
          "label": "Python",
          "code": "import requests\n\nurl = \"https://api.campaign.episerver.net/rest/{clientId}/messagetemplates/{messageTemplateId}/test\"\n\npayload = 'recipientIds=array&recipientListId=integer%3Cint64%3E'\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/x-www-form-urlencoded'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "oCp2KxPtYxJd1K6ocgRXn"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-202",
          "language": "202",
          "code": "// The message template was sent successfully.\n{\n  \"mailingId\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "response-0-202"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}