---
title: POST /tasks/{id}/assets
slug: content-marketing-platform/api/post-tasksidassets
docTags: 
createdAt: 2026-10-01T18:51:26.265Z
---

{
  "id": "JRAMc23BenA_RaTKFPKwv",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://api.cmp.optimizely.com/v3/tasks/{id}/assets",
    "servers": [
      {
        "url": "https://api.cmp.optimizely.com/v3/tasks/{id}/assets",
        "description": "v3 version of Optimizely CMP Open API"
      }
    ],
    "name": "POST /tasks/{id}/assets",
    "description": "<p>This API allows you to add an asset to a task. There currently two mechanisms to add an asset - either by uploading an asset first and then calling this API (for only <code>images</code>, <code>videos</code>, and <code>raw files</code>), or by adding an asset from the library. The 'type' parameter in the request body will determine the mechanism used to add the asset. See <a href=\"https://docs.developers.optimizely.com/content-marketing-platform/docs/upload-assets\" target=\"_blank\">Upload assets</a> to upload an asset.</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "id",
          "type": "string",
          "example": "5f857f30e1c4a2038d6179e9",
          "description": "Unique identifier of the task"
        }
      ],
      "headerParameters": [
        {
          "name": "accept",
          "type": "string",
          "kind": "optional",
          "description": "Generated from available response content types",
          "enum": [
            "application/json"
          ],
          "default": "application/json"
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "description": "<p>Payload to add an asset. There are two mechanisms for adding assets to a task:</p>\n<ul>\n<li><code>direct_upload</code> - An asset that has been uploaded using the <a href=\"https://docs.developers.optimizely.com/content-marketing-platform/docs/upload-assets\" target=\"_blank\">Upload assets</a> endpoint.</li>\n<li><code>fork_from_library</code> - This will fork an existing asset from the library to the task.\nThe <code>type</code> field is optional, and will default to <code>direct_upload</code> if not provided.\nNote: Renditions is currently not supported for library assets.</li>\n</ul>",
          "discriminator": {
            "propertyName": "type",
            "mapping": {
              "direct_upload": "#/components/schemas/TaskAssetRequestForDirectUpload",
              "fork_from_library": "#/components/schemas/TaskAssetRequestForLibrary"
            }
          },
          "customType": "TaskAssetRequest",
          "schema": [],
          "modelRef": "#/components/schemas/TaskAssetRequest",
          "complexItems": [
            {
              "name": "object",
              "schema": [
                {
                  "name": "type",
                  "kind": "optional",
                  "type": "string",
                  "description": "The mechanism for adding the asset to the task",
                  "example": "direct_upload"
                },
                {
                  "name": "key",
                  "kind": "required",
                  "type": "string",
                  "description": "<p>Unique identifier of the file upload session. This is the <code>upload_meta_fields.key</code> field retrieved from the <code>/v3/upload-url</code> endpoint.</p>",
                  "maxLength": 100
                },
                {
                  "name": "title",
                  "kind": "required",
                  "type": "string",
                  "description": "Title of the asset",
                  "example": "sample_image.png",
                  "minLength": 1,
                  "maxLength": 100
                }
              ],
              "modelRef": "#/components/schemas/TaskAssetRequestForDirectUpload",
              "customType": "TaskAssetRequestForDirectUpload"
            },
            {
              "name": "object",
              "schema": [
                {
                  "name": "type",
                  "kind": "required",
                  "type": "string",
                  "description": "The mechanism for adding the asset to the task",
                  "example": "fork_from_library"
                },
                {
                  "name": "content_id",
                  "kind": "required",
                  "type": "string<uuid>",
                  "description": "Unique identifier of the asset",
                  "example": "d1efd3c4625111f0baa002420ac8001d",
                  "format": "uuid"
                },
                {
                  "name": "content_type",
                  "kind": "required",
                  "type": "string<article | image | raw_file | structured_content | video>",
                  "description": "The type of asset",
                  "example": "image",
                  "enum": [
                    "article",
                    "image",
                    "raw_file",
                    "structured_content",
                    "video"
                  ]
                }
              ],
              "modelRef": "#/components/schemas/TaskAssetRequestForLibrary",
              "customType": "TaskAssetRequestForLibrary"
            }
          ],
          "complexType": "oneOf",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "OAuth2",
          "name": "OAuth2",
          "kind": "optional",
          "type": "oauth2",
          "oauth2Flows": {
            "clientCredentials": {
              "tokenUrl": "https://accounts.cmp.optimizely.com/o/oauth2/v1/token",
              "scopes": {}
            },
            "authorizationCode": {
              "authorizationUrl": "https://accounts.cmp.optimizely.com/o/oauth2/v1/auth",
              "tokenUrl": "https://accounts.cmp.optimizely.com/o/oauth2/v1/token",
              "scopes": {
                "openid": "Grants the ability to receive a unique identifier for the user.",
                "profile": "Grants access to user profile information.",
                "offline_access": "Grants the ability to refresh access_token using the refresh token even when user is not present (not logged in)."
              }
            }
          },
          "requiredScopes": [
            "openid",
            "profile",
            "offline_access"
          ]
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "201",
        "description": "Created asset",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "TaskAssetResponse",
            "schema": [
              {
                "name": "id",
                "kind": "required",
                "type": "string",
                "description": "Unique identifier for the asset",
                "example": "5d7f910551b00a722e0418830cee6631"
              },
              {
                "name": "title",
                "kind": "required",
                "type": "string",
                "description": "Title of the asset",
                "example": "sample_image.png"
              },
              {
                "name": "type",
                "kind": "required",
                "type": "string<article | image | video | raw_file | structured_content | compose_content>",
                "description": "Type of the asset",
                "example": "image",
                "enum": [
                  "article",
                  "image",
                  "video",
                  "raw_file",
                  "structured_content",
                  "compose_content"
                ]
              },
              {
                "name": "mime_type",
                "kind": "required",
                "type": "string",
                "description": "MIME type of the asset",
                "example": "image/png"
              },
              {
                "name": "created_at",
                "kind": "required",
                "type": "string<date-time>",
                "description": "<p>Date and time on which the asset was created, in ISO 8601 UTC format (2020-02-10T10:40</p><div></div>)<p></p>",
                "example": "2019-10-06T13:15:30Z",
                "format": "date-time"
              },
              {
                "name": "modified_at",
                "kind": "required",
                "type": "string<date-time>",
                "description": "<p>Date and time of the most recent modification of the asset, in ISO 8601 UTC format (2020-02-10T10:40</p><div></div>)<p></p>",
                "example": "2019-10-07T13:15:30Z",
                "format": "date-time"
              },
              {
                "name": "content",
                "kind": "required",
                "type": "object",
                "description": "Content of the asset",
                "modelRef": "#/components/schemas/AssetContent",
                "customType": "AssetContent",
                "schema": [
                  {
                    "name": "type",
                    "kind": "required",
                    "type": "string<url | api_url | html_body>",
                    "description": "<p>Type of the content.</p>\n<ul>\n<li>article  – <code>html_body</code></li>\n<li>image, raw_file, video  – <code>url</code></li>\n<li>structured_content  – <code>api_url</code></li>\n<li>compose_content  – <code>api_url</code></li>\n</ul>",
                    "example": "url",
                    "enum": [
                      "url",
                      "api_url",
                      "html_body"
                    ]
                  },
                  {
                    "name": "value",
                    "kind": "required",
                    "type": "string",
                    "description": "<p>Content of the asset.  - article – the html body - image, raw_file, video – the download URL - structured_content – api url - compose_content – api url</p>",
                    "example": "http://images.cmp.optimizely.com/Zz0xODQ3NDU3Y2Y2YmYzOTlmNjkyOTgyZDY3Y2I3YWM2OA==S"
                  }
                ]
              },
              {
                "name": "labels",
                "kind": "required",
                "type": "array",
                "description": "Labels associated with the asset",
                "modelRef": "#/components/schemas/ResourceLabelResponse",
                "customType": "ResourceLabelResponse[]",
                "schema": [
                  {
                    "name": "group",
                    "kind": "required",
                    "type": "object",
                    "description": "Label group",
                    "example": "",
                    "schema": [
                      {
                        "name": "id",
                        "kind": "required",
                        "type": "string",
                        "description": "Identifier of the label group",
                        "example": "2467e583a60e23fda2b89db81a453cd2"
                      },
                      {
                        "name": "name",
                        "kind": "required",
                        "type": "string",
                        "description": "Name of the label group",
                        "example": "Content Format"
                      }
                    ]
                  },
                  {
                    "name": "values",
                    "kind": "required",
                    "type": "array",
                    "description": "List of values of the label",
                    "example": "",
                    "itemType": "object",
                    "customType": "object[]",
                    "schema": [
                      {
                        "name": "id",
                        "kind": "required",
                        "type": "string",
                        "description": "Identifier of the label value",
                        "example": "71c378f3fee3d822759d1bdc2aab628c"
                      },
                      {
                        "name": "name",
                        "kind": "required",
                        "type": "string",
                        "description": "Name of the label value",
                        "example": "Photos"
                      }
                    ]
                  }
                ]
              },
              {
                "name": "links",
                "kind": "required",
                "type": "object",
                "description": "Meta links",
                "example": "",
                "schema": [
                  {
                    "name": "self",
                    "kind": "required",
                    "type": "string",
                    "description": "URL of the asset",
                    "example": "https://api.cmp.optimizely.com/v3/tasks/5f857f30e1c4a2038d6179e9/image/5d7f910551b00a722e0418830cee6631"
                  },
                  {
                    "name": "task",
                    "kind": "required",
                    "type": "string",
                    "description": "URL of the task that the asset is associated with",
                    "example": "https://api.cmp.optimizely.com/v3/tasks/5f857f30e1c4a2038d6179e9"
                  },
                  {
                    "name": "drafts",
                    "kind": "required",
                    "type": "string",
                    "nullable": true,
                    "description": "<p>URL to POST draft to the asset - null for <code>article</code> - non-null for <code>image</code>, <code>video</code>, and <code>raw file</code>.</p>",
                    "example": "https://api.cmp.optimizely.com/v3/tasks/5f857f30e1c4a2038d6179e9/assets/5d7f910551b00a722e0418830cee6631/drafts"
                  },
                  {
                    "name": "web_urls",
                    "kind": "required",
                    "type": "object",
                    "description": "Web URLs",
                    "example": "",
                    "schema": [
                      {
                        "name": "self",
                        "kind": "required",
                        "type": "string",
                        "description": "Web URL of the asset",
                        "example": "https://cmp.optimizely.com/cloud/taskv3/5f857f30e1c4a2038d6179e9?contentTabGuid=5d7f910551b00a722e0418830cee6631"
                      },
                      {
                        "name": "task",
                        "kind": "required",
                        "type": "string",
                        "description": "Web URL of the task that the asset is associated with",
                        "example": "https://cmp.optimizely.com/cloud/taskv3/5f857f30e1c4a2038d6179e9"
                      },
                      {
                        "name": "drafts",
                        "kind": "required",
                        "type": "string",
                        "nullable": true,
                        "description": "<p>Web URL of the drafts of the asset - null for <code>article</code> - non-null for <code>image</code>, <code>video</code>, and <code>raw file</code>.</p>",
                        "example": "https://cmp.optimizely.com/cloud/task/5f857f30e1c4a2038d6179e9/image/5d7f910551b00a722e0418830cee6631"
                      }
                    ]
                  }
                ]
              }
            ],
            "modelRef": "#/components/schemas/TaskAssetResponse",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "Client error",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "example": "{\"message\":\"Unsupported arguments: a,b,c\"}",
            "description": "Error payload",
            "customType": "Error",
            "schema": [
              {
                "name": "message",
                "kind": "required",
                "type": "string",
                "description": "Message describing the error",
                "example": "Not found"
              },
              {
                "name": "errors",
                "kind": "optional",
                "type": "map",
                "description": "Additional information",
                "example": "",
                "customType": "map<string, string>",
                "schema": []
              }
            ],
            "modelRef": "#/components/schemas/Error",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "401",
        "description": "Authorization error",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "example": "{\"message\":\"Unauthorized\"}",
            "description": "Error payload",
            "customType": "Error",
            "schema": [
              {
                "name": "message",
                "kind": "required",
                "type": "string",
                "description": "Message describing the error",
                "example": "Not found"
              },
              {
                "name": "errors",
                "kind": "optional",
                "type": "map",
                "description": "Additional information",
                "example": "",
                "customType": "map<string, string>",
                "schema": []
              }
            ],
            "modelRef": "#/components/schemas/Error",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "403",
        "description": "Permission error",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "example": "{\"message\":\"You do not have the permission to perform this operation\"}",
            "description": "Error payload",
            "customType": "Error",
            "schema": [
              {
                "name": "message",
                "kind": "required",
                "type": "string",
                "description": "Message describing the error",
                "example": "Not found"
              },
              {
                "name": "errors",
                "kind": "optional",
                "type": "map",
                "description": "Additional information",
                "example": "",
                "customType": "map<string, string>",
                "schema": []
              }
            ],
            "modelRef": "#/components/schemas/Error",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "404",
        "description": "Not found error",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "example": "{\"message\":\"Resource not found\"}",
            "description": "Error payload",
            "customType": "Error",
            "schema": [
              {
                "name": "message",
                "kind": "required",
                "type": "string",
                "description": "Message describing the error",
                "example": "Not found"
              },
              {
                "name": "errors",
                "kind": "optional",
                "type": "map",
                "description": "Additional information",
                "example": "",
                "customType": "map<string, string>",
                "schema": []
              }
            ],
            "modelRef": "#/components/schemas/Error",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "422",
        "description": "Unprocessable entity error",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "example": "{\"message\":\"Resource cannot be processed\"}",
            "description": "Error payload",
            "customType": "Error",
            "schema": [
              {
                "name": "message",
                "kind": "required",
                "type": "string",
                "description": "Message describing the error",
                "example": "Not found"
              },
              {
                "name": "errors",
                "kind": "optional",
                "type": "map",
                "description": "Additional information",
                "example": "",
                "customType": "map<string, string>",
                "schema": []
              }
            ],
            "modelRef": "#/components/schemas/Error",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "GK8xeEyta1NnWE3MEZ1gU",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.cmp.optimizely.com/v3/tasks/{id}/assets \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"key\": \"\",\n     \"title\": \"sample_image.png\"\n     }'"
        },
        {
          "id": "zQDdDEYSwCfr_lzojQwYa",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"key\": \"\",\n   \"title\": \"sample_image.png\"\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.cmp.optimizely.com/v3/tasks/{id}/assets\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "WSi8Pp_q_9X7431_HBEXQ",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.cmp.optimizely.com/v3/tasks/{id}/assets\")\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/json\"\nrequest.body = JSON.dump({\n   \"key\": \"\",\n   \"title\": \"sample_image.png\"\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "QT5M0nzVdPg_-OXSTPUB5",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.cmp.optimizely.com/v3/tasks/{id}/assets\"\n\npayload = json.dumps({\n   \"key\": \"\",\n   \"title\": \"sample_image.png\"\n})\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "GK8xeEyta1NnWE3MEZ1gU"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-201",
          "language": "201",
          "code": "// Created asset\n{\n  \"id\": \"5d7f910551b00a722e0418830cee6631\",\n  \"title\": \"sample_image.png\",\n  \"type\": \"image\",\n  \"mime_type\": \"image/png\",\n  \"created_at\": \"2019-10-06T13:15:30Z\",\n  \"modified_at\": \"2019-10-07T13:15:30Z\",\n  \"content\": {\n    \"type\": \"url\",\n    \"value\": \"http://images.cmp.optimizely.com/Zz0xODQ3NDU3Y2Y2YmYzOTlmNjkyOTgyZDY3Y2I3YWM2OA==S\"\n  },\n  \"labels\": [\n    {\n      \"group\": {\n        \"id\": \"2467e583a60e23fda2b89db81a453cd2\",\n        \"name\": \"Content Format\"\n      },\n      \"values\": [\n        {\n          \"id\": \"71c378f3fee3d822759d1bdc2aab628c\",\n          \"name\": \"Photos\"\n        }\n      ]\n    }\n  ],\n  \"links\": {\n    \"self\": \"https://api.cmp.optimizely.com/v3/tasks/5f857f30e1c4a2038d6179e9/image/5d7f910551b00a722e0418830cee6631\",\n    \"task\": \"https://api.cmp.optimizely.com/v3/tasks/5f857f30e1c4a2038d6179e9\",\n    \"drafts\": \"https://api.cmp.optimizely.com/v3/tasks/5f857f30e1c4a2038d6179e9/assets/5d7f910551b00a722e0418830cee6631/drafts\",\n    \"web_urls\": {\n      \"self\": \"https://cmp.optimizely.com/cloud/taskv3/5f857f30e1c4a2038d6179e9?contentTabGuid=5d7f910551b00a722e0418830cee6631\",\n      \"task\": \"https://cmp.optimizely.com/cloud/taskv3/5f857f30e1c4a2038d6179e9\",\n      \"drafts\": \"https://cmp.optimizely.com/cloud/task/5f857f30e1c4a2038d6179e9/image/5d7f910551b00a722e0418830cee6631\"\n    }\n  }\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Client error\n{\n  \"message\": \"Not found\",\n  \"errors\": \"\"\n}"
        },
        {
          "id": "response-2-401",
          "language": "401",
          "code": "// Authorization error\n{\n  \"message\": \"Not found\",\n  \"errors\": \"\"\n}"
        },
        {
          "id": "response-3-403",
          "language": "403",
          "code": "// Permission error\n{\n  \"message\": \"Not found\",\n  \"errors\": \"\"\n}"
        },
        {
          "id": "response-4-404",
          "language": "404",
          "code": "// Not found error\n{\n  \"message\": \"Not found\",\n  \"errors\": \"\"\n}"
        },
        {
          "id": "response-5-422",
          "language": "422",
          "code": "// Unprocessable entity error\n{\n  \"message\": \"Not found\",\n  \"errors\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "response-0-201"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}