> For a complete page index, fetch https://developer.close.com/llms.txt # Create an SMS template POST https://api.close.com/api/v1/sms_template/ Content-Type: application/json Reference: https://developer.close.com/api/resources/sms-templates/create ## Authentication - `Authorization` header (basic auth, required) — Use your API key as the username and leave the password empty. - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Request ### Body (application/json) This endpoint expects a CreateSMSTemplate. - `name` (string, required) - `attachments` (list of CreateSMSTemplateAttachment, optional) - `is_shared` (boolean, optional) - `text` (string, optional) ## Response ### 201 Successful response ## Errors ### 400 Bad Request Error Bad request - `any` ### 401 Unauthorized Error Unauthorized - `any` ### 404 Not Found Error Not found - `any` ## Types ### CreateSMSTemplateAttachment - `content_type` (string, required) - `filename` (string, required) - `url` (string, required) ## Examples **Request** ```json { "name": "Cold 1", "is_shared": false, "text": "Hey {{ contact.first_name }}, ever considered Close?" } ``` **Response** ```json { "created_by": "user_l2RN00c7kDGBRRV7nfUsyWhMfRHu6OP9YCKP9UwQDXY", "date_created": "2022-09-26T15:08:02.179681", "date_updated": "2022-09-26T15:08:02.179681", "id": "smstmpl_0Yu13KOvH2cj1GSFzG9VRH", "is_shared": false, "name": "Cold 1", "organization_id": "orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH", "owned_by": "user_l2RN00c7kDGBRRV7nfUsyWhMfRHu6OP9YCKP9UwQDXY", "status": "active", "text": "Hey {{ contact.first_name }}, ever considered Close?", "updated_by": "user_l2RN00c7kDGBRRV7nfUsyWhMfRHu6OP9YCKP9UwQDXY" } ``` **SDK Code** ```python sms_templates_create_example import requests url = "https://api.close.com/api/v1/sms_template/" payload = { "name": "Cold 1", "is_shared": False, "text": "Hey {{ contact.first_name }}, ever considered Close?" } headers = { "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers, auth=("", "")) print(response.json()) ``` ```javascript sms_templates_create_example const url = 'https://api.close.com/api/v1/sms_template/'; const credentials = btoa(":"); const options = { method: 'POST', headers: {Authorization: `Basic ${credentials}`, 'Content-Type': 'application/json'}, body: '{"name":"Cold 1","is_shared":false,"text":"Hey {{ contact.first_name }}, ever considered Close?"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go sms_templates_create_example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.close.com/api/v1/sms_template/" payload := strings.NewReader("{\n \"name\": \"Cold 1\",\n \"is_shared\": false,\n \"text\": \"Hey {{ contact.first_name }}, ever considered Close?\"\n}") req, _ := http.NewRequest("POST", url, payload) req.SetBasicAuth("", "") 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 sms_templates_create_example require 'uri' require 'net/http' url = URI("https://api.close.com/api/v1/sms_template/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request.basic_auth("", "") request["Content-Type"] = 'application/json' request.body = "{\n \"name\": \"Cold 1\",\n \"is_shared\": false,\n \"text\": \"Hey {{ contact.first_name }}, ever considered Close?\"\n}" response = http.request(request) puts response.read_body ``` ```java sms_templates_create_example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.close.com/api/v1/sms_template/") .basicAuth("", "") .header("Content-Type", "application/json") .body("{\n \"name\": \"Cold 1\",\n \"is_shared\": false,\n \"text\": \"Hey {{ contact.first_name }}, ever considered Close?\"\n}") .asString(); ``` ```php sms_templates_create_example request('POST', 'https://api.close.com/api/v1/sms_template/', [ 'body' => '{ "name": "Cold 1", "is_shared": false, "text": "Hey {{ contact.first_name }}, ever considered Close?" }', 'headers' => [ 'Content-Type' => 'application/json', ], 'auth' => ['', ''], ]); echo $response->getBody(); ``` ```csharp sms_templates_create_example using RestSharp; using RestSharp.Authenticators; var client = new RestClient("https://api.close.com/api/v1/sms_template/"); client.Authenticator = new HttpBasicAuthenticator("", ""); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"name\": \"Cold 1\",\n \"is_shared\": false,\n \"text\": \"Hey {{ contact.first_name }}, ever considered Close?\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ```