> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://mailchimp.com/developer/marketing/api/templates/create/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://mailchimp.com/_mcp/server. # Add template POST https://api.mailchimp.com/3.0/templates Content-Type: application/json Create a new template for the account. Only Classic templates are supported. Reference: https://mailchimp.com/developer/marketing/api/templates/create ## Authentication - `Authorization` header (bearer token, required) — Authorization using a Mailchimp API key (a.k.a. Bearer token) - `Authorization` header (bearer token, required) — Authorization using OAuth ## Request ### Body (application/json) This endpoint expects an object. - `html` (30TemplatesPostRequestBodyContentApplicationJsonSchemaHtml, required) — The raw HTML for the template. We support the Mailchimp [Template Language](https://mailchimp.com/help/getting-started-with-mailchimps-template-language/) in any HTML code passed via the API. - `name` (string, required) — The name of the template. - `folder_id` (string, optional) — The id of the folder the template is currently in. ## Response ### 200 - `_links` (list of TemplateInstanceLinksItems, optional) — A list of link types and descriptions for the API schema documents. - `active` (boolean, optional) — User templates are not 'deleted,' but rather marked as 'inactive.' Returns whether the template is still active. - `category` (string, optional) — If available, the category the template is listed in. - `content_type` (enum, optional) — How the template's content is put together. - Allowed values: `template`, `multichannel`, `html` - `created_by` (string, optional) — The login name for template's creator. - `date_created` (datetime, optional) — The date and time the template was created in ISO 8601 format. - `date_edited` (datetime, optional) — The date and time the template was edited in ISO 8601 format. - `drag_and_drop` (boolean, optional) — Whether the template uses the drag and drop editor. - `edited_by` (string, optional) — The login name who last edited the template. - `folder_id` (string, optional) — The id of the folder the template is currently in. - `id` (integer, optional) — The individual id for the template. - `name` (string, optional) — The name of the template. - `responsive` (boolean, optional) — Whether the template contains media queries to make it responsive. - `share_url` (string, optional) — The URL used for [template sharing](https://mailchimp.com/help/share-a-template/). - `thumbnail` (string, optional) — If available, the URL for a thumbnail of the template. - `type` (string, optional) — The type of template (user, base, or gallery). ## Types ### 30TemplatesPostRequestBodyContentApplicationJsonSchemaHtml The raw HTML for the template. We support the Mailchimp [Template Language](https://mailchimp.com/help/getting-started-with-mailchimps-template-language/) in any HTML code passed via the API. ### TemplateInstanceLinksItems This object represents a link from the resource where it is found to another resource or action that may be performed. - `href` (string, optional) — This property contains a fully-qualified URL that can be called to retrieve the linked resource or perform the linked action. - `method` (enum, optional) — The HTTP method that should be used when accessing the URL defined in 'href'. - Allowed values: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `OPTIONS`, `HEAD` - `rel` (string, optional) — As with an HTML 'rel' attribute, this describes the type of link. - `schema` (string, optional) — For HTTP methods that can receive bodies (POST and PUT), this is a URL representing the schema that the body should conform to. - `targetSchema` (string, optional) — For GETs, this is a URL representing the schema that the response should conform to. ## Examples **Request** ```json { "html": "string", "name": "Freddie's Jokes" } ``` **Response** ```json { "_links": [ { "href": "string", "method": "GET", "rel": "string", "schema": "string", "targetSchema": "string" } ], "active": true, "category": "string", "content_type": "template", "created_by": "string", "date_created": "2024-01-15T09:30:00Z", "date_edited": "2024-01-15T09:30:00Z", "drag_and_drop": true, "edited_by": "string", "folder_id": "string", "id": 1, "name": "string", "responsive": true, "share_url": "string", "thumbnail": "string", "type": "string" } ``` **SDK Code** ```python import requests url = "https://api.mailchimp.com/3.0/templates" payload = { "html": "string", "name": "Freddie's Jokes" } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.mailchimp.com/3.0/templates'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"html":"string","name":"Freddie\'s Jokes"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.mailchimp.com/3.0/templates" payload := strings.NewReader("{\n \"html\": \"string\",\n \"name\": \"Freddie's Jokes\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.mailchimp.com/3.0/templates") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"html\": \"string\",\n \"name\": \"Freddie's Jokes\"\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.mailchimp.com/3.0/templates") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"html\": \"string\",\n \"name\": \"Freddie's Jokes\"\n}") .asString(); ``` ```php request('POST', 'https://api.mailchimp.com/3.0/templates', [ 'body' => '{ "html": "string", "name": "Freddie\'s Jokes" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.mailchimp.com/3.0/templates"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"html\": \"string\",\n \"name\": \"Freddie's Jokes\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "html": "string", "name": "Freddie's Jokes" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.mailchimp.com/3.0/templates")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` > Find all the Mailchimp API documentation and tools developers need to send marketing and transactional emails.