# Assign Campaign Message Template

Creates a non-reusable version of the template and assigns it to the message.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m`

**Scopes:**
`campaigns:write`

# OpenAPI definition

```json
{
  "openapi": "3.0.2",
  "info": {
    "title": "Campaigns API",
    "version": "2023-10-15",
    "description": "The Klaviyo REST API. Please visit https://developers.klaviyo.com for more details.",
    "contact": {
      "name": "Klaviyo Developer Experience Team",
      "email": "developers@klaviyo.com",
      "url": "https://developers.klaviyo.com"
    },
    "termsOfService": "https://www.klaviyo.com/legal/api-terms",
    "license": {
      "name": "License",
      "url": "https://www.klaviyo.com/legal"
    }
  },
  "servers": [
    {
      "url": "https://a.klaviyo.com",
      "description": "Production"
    }
  ],
  "paths": {
    "/api/campaign-message-assign-template/": {
      "post": {
        "operationId": "create_campaign_message_assign_template",
        "summary": "Assign Campaign Message Template",
        "description": "Creates a non-reusable version of the template and assigns it to the message.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m`\n\n**Scopes:**\n`campaigns:write`",
        "parameters": [
          {
            "name": "revision",
            "in": "header",
            "description": "API endpoint revision (format: YYYY-MM-DD[.suffix])",
            "required": true,
            "schema": {
              "type": "string",
              "default": "2023-10-15"
            }
          }
        ],
        "requestBody": {
          "description": "Takes a reusable template, clones it, and assigns the non-reusable clone to the message.",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CampaignMessageAssignTemplateQuery"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PostCampaignMessageResponse"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/ClientError"
          },
          "5XX": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "tags": [
          "Messages"
        ],
        "x-klaviyo-pre-release": "None",
        "x-klaviyo-ratelimit": {
          "burst": "10/s",
          "steady": "150/m"
        },
        "x-klaviyo-scopes": [
          "campaigns:write"
        ],
        "x-klaviyo-subtag": "Messages"
      }
    }
  },
  "components": {
    "schemas": {
      "EmailContentSubObject": {
        "type": "object",
        "properties": {
          "subject": {
            "description": "The subject of the message",
            "type": "string",
            "example": "Buy our product!",
            "default": "Buy our product!"
          },
          "preview_text": {
            "description": "Preview text associated with the message",
            "type": "string",
            "example": "My preview text",
            "default": "My preview text"
          },
          "from_email": {
            "description": "The email the message should be sent from",
            "type": "string",
            "example": "store@my-company.com",
            "default": "store@my-company.com"
          },
          "from_label": {
            "description": "The label associated with the from_email",
            "type": "string",
            "example": "My Company",
            "default": "My Company"
          },
          "reply_to_email": {
            "description": "Optional Reply-To email address",
            "type": "string",
            "example": "reply-to@my-company.com",
            "default": "reply-to@my-company.com"
          },
          "cc_email": {
            "description": "Optional CC email address",
            "type": "string",
            "example": "cc@my-company.com",
            "default": "cc@my-company.com"
          },
          "bcc_email": {
            "description": "Optional BCC email address",
            "type": "string",
            "example": "bcc@my-company.com",
            "default": "bcc@my-company.com"
          }
        }
      },
      "SMSContentSubObject": {
        "type": "object",
        "properties": {
          "body": {
            "description": "The message body",
            "type": "string",
            "example": "My preview sms",
            "default": "My preview sms"
          },
          "media_url": {
            "description": "URL for included media",
            "type": "string"
          }
        }
      },
      "SendTimeSubObject": {
        "type": "object",
        "properties": {
          "datetime": {
            "description": "The datetime that the message is to be sent",
            "type": "string",
            "format": "date-time",
            "example": "2022-11-08T00:00:00",
            "default": "2022-11-08T00:00:00"
          },
          "is_local": {
            "description": "Whether that datetime is to be a local datetime for the recipient",
            "type": "boolean"
          }
        },
        "required": [
          "datetime",
          "is_local"
        ]
      },
      "RenderOptionsSubObject": {
        "type": "object",
        "properties": {
          "shorten_links": {
            "type": "boolean",
            "example": true,
            "default": true
          },
          "add_org_prefix": {
            "type": "boolean",
            "example": true,
            "default": true
          },
          "add_info_link": {
            "type": "boolean",
            "example": true,
            "default": true
          },
          "add_opt_out_language": {
            "type": "boolean",
            "default": false
          }
        }
      },
      "CampaignMessageAssignTemplateQueryResourceObject": {
        "type": "object",
        "properties": {
          "type": {
            "$ref": "#/components/schemas/CampaignMessageEnum"
          },
          "id": {
            "description": "The message ID to be assigned to",
            "type": "string"
          },
          "relationships": {
            "type": "object",
            "properties": {
              "template": {
                "type": "object",
                "properties": {
                  "data": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "$ref": "#/components/schemas/TemplateEnum"
                      },
                      "id": {
                        "description": "The template ID to assign",
                        "type": "string",
                        "example": "RipRmi",
                        "default": "RipRmi"
                      }
                    },
                    "required": [
                      "type",
                      "id"
                    ]
                  }
                },
                "required": [
                  "data"
                ]
              }
            },
            "required": [
              "template"
            ]
          }
        },
        "required": [
          "type",
          "id",
          "relationships"
        ]
      },
      "CampaignMessageAssignTemplateQuery": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/CampaignMessageAssignTemplateQueryResourceObject"
          }
        },
        "required": [
          "data"
        ]
      },
      "PostCampaignMessageResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "type": {
                "$ref": "#/components/schemas/CampaignMessageEnum"
              },
              "id": {
                "description": "The message ID",
                "type": "string"
              },
              "attributes": {
                "type": "object",
                "properties": {
                  "label": {
                    "description": "The label or name on the message",
                    "type": "string"
                  },
                  "channel": {
                    "description": "The channel the message is to be sent on",
                    "type": "string"
                  },
                  "content": {
                    "description": "Additional attributes relating to the content of the message",
                    "oneOf": [
                      {
                        "$ref": "#/components/schemas/EmailContentSubObject"
                      },
                      {
                        "$ref": "#/components/schemas/SMSContentSubObject"
                      }
                    ]
                  },
                  "send_times": {
                    "description": "The list of appropriate Send Time Sub-objects associated with the message",
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/SendTimeSubObject"
                    }
                  },
                  "render_options": {
                    "description": "Additional options for rendering the message",
                    "$ref": "#/components/schemas/RenderOptionsSubObject"
                  },
                  "created_at": {
                    "description": "The datetime when the message was created",
                    "type": "string",
                    "format": "date-time",
                    "example": "2022-11-08T00:00:00",
                    "default": "2022-11-08T00:00:00"
                  },
                  "updated_at": {
                    "description": "The datetime when the message was last updated",
                    "type": "string",
                    "format": "date-time",
                    "example": "2022-11-08T00:00:00",
                    "default": "2022-11-08T00:00:00"
                  }
                },
                "required": [
                  "label",
                  "channel",
                  "content"
                ]
              },
              "relationships": {
                "type": "object",
                "properties": {
                  "campaign": {
                    "type": "object",
                    "properties": {
                      "data": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "$ref": "#/components/schemas/CampaignEnum"
                          },
                          "id": {
                            "description": "The parent campaign id",
                            "type": "string"
                          }
                        },
                        "required": [
                          "type",
                          "id"
                        ]
                      },
                      "links": {
                        "$ref": "#/components/schemas/RelationshipLinks"
                      }
                    },
                    "required": [
                      "data"
                    ]
                  },
                  "template": {
                    "type": "object",
                    "properties": {
                      "data": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "$ref": "#/components/schemas/TemplateEnum"
                          },
                          "id": {
                            "description": "The associated template id",
                            "type": "string"
                          }
                        },
                        "required": [
                          "type",
                          "id"
                        ]
                      },
                      "links": {
                        "$ref": "#/components/schemas/RelationshipLinks"
                      }
                    },
                    "required": [
                      "data"
                    ]
                  }
                }
              },
              "links": {
                "$ref": "#/components/schemas/ObjectLinks"
              }
            },
            "required": [
              "type",
              "id",
              "attributes",
              "links"
            ]
          }
        },
        "required": [
          "data"
        ]
      },
      "RelationshipLinks": {
        "type": "object",
        "properties": {
          "self": {
            "type": "string",
            "format": "uri"
          },
          "related": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "self",
          "related"
        ]
      },
      "ObjectLinks": {
        "type": "object",
        "properties": {
          "self": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "self"
        ]
      },
      "TemplateEnum": {
        "type": "string",
        "enum": [
          "template"
        ]
      },
      "CampaignEnum": {
        "type": "string",
        "enum": [
          "campaign"
        ]
      },
      "CampaignMessageEnum": {
        "type": "string",
        "enum": [
          "campaign-message"
        ]
      }
    },
    "responses": {
      "ClientError": {
        "description": "Client Error",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "errors": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "id",
                      "code",
                      "title",
                      "detail"
                    ],
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "code": {
                        "type": "string"
                      },
                      "title": {
                        "type": "string"
                      },
                      "detail": {
                        "type": "string"
                      },
                      "source": {
                        "type": "object",
                        "properties": {
                          "pointer": {
                            "type": "string"
                          },
                          "parameter": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              },
              "required": [
                "errors"
              ]
            }
          }
        }
      },
      "ServerError": {
        "description": "Server Error",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "errors": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "id",
                      "code",
                      "title",
                      "detail"
                    ],
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "code": {
                        "type": "string"
                      },
                      "title": {
                        "type": "string"
                      },
                      "detail": {
                        "type": "string"
                      },
                      "source": {
                        "type": "object",
                        "properties": {
                          "pointer": {
                            "type": "string"
                          },
                          "parameter": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              },
              "required": [
                "errors"
              ]
            }
          }
        }
      }
    },
    "securitySchemes": {
      "Klaviyo-API-Key": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "Private key authentication for /api/ endpoints is performed by setting the `Authorization` header to `Klaviyo-API-Key your-private-api-key`<br>For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#authentication",
        "x-default": "Klaviyo-API-Key your-private-api-key"
      }
    }
  },
  "tags": [
    {
      "name": "Messages"
    }
  ],
  "security": [
    {
      "Klaviyo-API-Key": []
    }
  ],
  "x-readme": {
    "explorer-enabled": false,
    "proxy-enabled": true,
    "samples-enabled": true
  },
  "_id": {
    "buffer": {
      "0": 101,
      "1": 45,
      "2": 164,
      "3": 185,
      "4": 236,
      "5": 156,
      "6": 226,
      "7": 0,
      "8": 79,
      "9": 19,
      "10": 207,
      "11": 106
    }
  }
}
```