---
title: Create a personalized attachment
slug: campaign/api/create-a-personalized-attachment
docTags: 
createdAt: 2026-09-02T15:04:15.718Z
---

{
  "id": "W1_FqjaEv5lLWpJvvUp3z",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://api.campaign.episerver.net/rest/{clientId}/attachments/personalized",
    "servers": [
      {
        "url": "https://api.campaign.episerver.net/rest/{clientId}/attachments/personalized"
      }
    ],
    "name": "Create a personalized attachment",
    "description": "<p>Create a personalized attachment. You can specify the attachment name and attachment file(s).</p>",
    "contentType": "multipart/form-data",
    "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": [],
      "bodyDataParameters": [],
      "formDataParameters": [
        {
          "name": "file",
          "kind": "required",
          "type": "string<binary>",
          "description": "file to be uploaded",
          "format": "binary"
        },
        {
          "name": "name",
          "kind": "optional",
          "type": "string",
          "description": "name of the attachment"
        }
      ],
      "oAuthParameters": [
        {
          "id": "Authorization",
          "name": "Authorization",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "The attachment was created successfully.",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "RestPersonalizedAttachmentUpload",
            "schema": [
              {
                "name": "uploadedFiles",
                "kind": "optional",
                "type": "array",
                "description": "List of uploaded attachments",
                "modelRef": "#/components/schemas/RestPersonalizedAttachment",
                "customType": "RestPersonalizedAttachment[]",
                "schema": [
                  {
                    "name": "fileName",
                    "kind": "optional",
                    "type": "string",
                    "description": "File name"
                  },
                  {
                    "name": "fileSize",
                    "kind": "optional",
                    "type": "integer<int64>",
                    "description": "File size in bytes",
                    "format": "int64"
                  },
                  {
                    "name": "id",
                    "kind": "optional",
                    "type": "integer<int64>",
                    "description": "Attachment ID",
                    "format": "int64"
                  },
                  {
                    "name": "contentType",
                    "kind": "optional",
                    "type": "string",
                    "description": "File content type"
                  },
                  {
                    "name": "expiresAt",
                    "kind": "optional",
                    "type": "string<date-time>",
                    "description": "Expiry date",
                    "format": "date-time"
                  },
                  {
                    "name": "created",
                    "kind": "optional",
                    "type": "string<date-time>",
                    "description": "Creation date",
                    "format": "date-time"
                  }
                ]
              },
              {
                "name": "token",
                "kind": "optional",
                "type": "string",
                "description": "<p>Personalized attachment token for all files uploaded - can be used when sending transactional mailings</p>"
              }
            ],
            "modelRef": "#/components/schemas/RestPersonalizedAttachmentUpload",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "An erroneous request was sent.",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "406",
        "description": "The uploaded file is empty.",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "500",
        "description": "The request could not be processed successfully.",
        "jsonExample": "",
        "isExpanded": true
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "erAUxCYEcc82-xPh57RS2",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.campaign.episerver.net/rest/{clientId}/attachments/personalized \\\n     --header 'accept: application/json' \\\n     --header 'content-type: multipart/form-data' \\\n     --form 'file=@\"/path/to/file\"'"
        },
        {
          "id": "-iHtWjwji-ks0YlAXZ87k",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"multipart/form-data\");\n\nvar formdata = new FormData();\nformdata.append(\"file\", fileInput.files[0], \"file\");\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: formdata,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.campaign.episerver.net/rest/{clientId}/attachments/personalized\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "Jy3sitXHwDJgvUXa_9UME",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.campaign.episerver.net/rest/{clientId}/attachments/personalized\")\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\"] = \"multipart/form-data\"\nform_data = [['file', File.open('/path/to/file')]]\nrequest.set_form form_data, 'multipart/form-data'\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "UFNKOwYIJ9NQCdv6nbR5r",
          "language": "python",
          "label": "Python",
          "code": "import requests\n\nurl = \"https://api.campaign.episerver.net/rest/{clientId}/attachments/personalized\"\n\npayload = {}\nfiles=[\n   ('file',('file',open('/path/to/file','rb'),'application/octet-stream'))\n]\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'multipart/form-data'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload, files=files)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "erAUxCYEcc82-xPh57RS2"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// The attachment was created successfully.\n{\n  \"uploadedFiles\": [\n    {\n      \"fileName\": \"\",\n      \"fileSize\": \"\",\n      \"id\": \"\",\n      \"contentType\": \"\",\n      \"expiresAt\": \"\",\n      \"created\": \"\"\n    }\n  ],\n  \"token\": \"\"\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// An erroneous request was sent.\n"
        },
        {
          "id": "response-2-406",
          "language": "406",
          "code": "// The uploaded file is empty.\n"
        },
        {
          "id": "response-3-500",
          "language": "500",
          "code": "// The request could not be processed successfully.\n"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}