---
title: "Update a template"
description: "Updates a template. With `PUT`, send every required field. Send `PATCH` instead to change\nonly the fields you include.\n"
version: "v2"
---

> Documentation Index
> Fetch the complete documentation index at: https://dev.touchsms.com.au/llms.txt
> Use this file to discover all available pages before exploring further.

Path: touchSMS API › Templates

`PUT /v2/templates/{template}`

Updates a template. With `PUT`, send every required field. Send `PATCH` instead to change
only the fields you include.

## Authentication

- `basicAuth`, http, header `Authorization`

## Path parameters

- `template` (`updateTemplate.path.template`; integer, required) — Template ID.

## Request body

_Required._

- `sender_id` (`updateTemplate.sender_id`; string, required) — A sender ID your account can send from, e.g. a dedicated number in E.164 format or `SHARED_NUMBER`.
  - example `"SHARED_NUMBER"`
- `name` (`updateTemplate.name`; string, required)
  - maxLength 255; example `"Appointment Reminder"`
- `message` (`updateTemplate.message`; string, required)
  - example `"Hi {{firstname}}, reminder of your appointment tomorrow."`
- `subject` (`updateTemplate.subject`; string | null, optional) — MMS subject.
  - maxLength 40

## Example request

```json
{
  "sender_id": "SHARED_NUMBER",
  "name": "Appointment Reminder",
  "message": "Hi {{firstname}}, reminder of your appointment tomorrow.",
  "subject": "string"
}
```

## Code samples

### cURL

```bash
curl --request PUT \
  --url https://app.touchsms.com.au/api/v2/templates/1234 \
  --header 'Authorization: Basic <credentials>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "sender_id": "SHARED_NUMBER",
  "name": "Appointment Reminder",
  "message": "Hi {{firstname}}, reminder of your appointment tomorrow.",
  "subject": "string"
}
'
```

### TypeScript

```typescript
const url = 'https://app.touchsms.com.au/api/v2/templates/1234';
const options = {
  method: 'PUT',
  headers: {'Content-Type': 'application/json', Authorization: 'Basic <credentials>'},
  body: JSON.stringify({
    sender_id: 'SHARED_NUMBER',
    name: 'Appointment Reminder',
    message: 'Hi {{firstname}}, reminder of your appointment tomorrow.',
    subject: 'string'
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://app.touchsms.com.au/api/v2/templates/1234"

payload = {
    "sender_id": "SHARED_NUMBER",
    "name": "Appointment Reminder",
    "message": "Hi {{firstname}}, reminder of your appointment tomorrow.",
    "subject": "string"
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Basic <credentials>"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

The updated template.

#### Example

```json
{
  "data": {
    "id": 1234,
    "user": 5678,
    "name": "Appointment Reminder",
    "message": "Hi {{firstname}}, reminder of your appointment tomorrow.",
    "subject": null,
    "replies": true,
    "sender_id": "SHARED_NUMBER",
    "updated": "2024-03-11T02:14:07Z",
    "created": "2024-02-02T23:51:19Z"
  }
}
```

- `data` (`updateTemplate.response.200.data`; object, optional)
  - example `{"id":1234,"user":5678,"name":"Appointment Reminder","message":"Hi {{firstname}}, reminder of your appointment tomorrow.","subject":null,"replies":true,"sender_id":"SHARED_NUMBER","updated":"2024-03-11T02:14:07Z","created":"2024-02-02T23:51:19Z"}`
  - `id` (`updateTemplate.response.200.data.id`; integer, optional)
  - `user` (`updateTemplate.response.200.data.user`; integer | null, optional) — ID of the user that owns the template. `null` on templates shared with your team.
  - `name` (`updateTemplate.response.200.data.name`; string, optional)
  - `message` (`updateTemplate.response.200.data.message`; string, optional) — Template body. May contain merge fields such as `{{firstname}}`.
  - `subject` (`updateTemplate.response.200.data.subject`; string | null, optional) — MMS subject, up to 40 characters.
  - `replies` (`updateTemplate.response.200.data.replies`; boolean, optional) — Whether replies are enabled for messages sent with this template.
  - `sender_id` (`updateTemplate.response.200.data.sender_id`; string | null, optional) — Sender ID the template sends from.
  - `updated` (`updateTemplate.response.200.data.updated`; string, optional)
    - format `date-time`
  - `created` (`updateTemplate.response.200.data.created`; string, optional)
    - format `date-time`

### 401

Missing, malformed or invalid API credentials.

#### Example

```json
{
  "message": "Unauthenticated."
}
```

- `message` (`updateTemplate.response.401.message`; string, required)

### 403

The resource exists but does not belong to you, or you lack permission.

#### Example

```json
{
  "message": "This action is unauthorized."
}
```

- `message` (`updateTemplate.response.403.message`; string, required)

### 404

The resource does not exist.

#### Example

```json
{
  "message": "Not Found"
}
```

- `message` (`updateTemplate.response.404.message`; string, required)

### 422

The request failed validation. `errors` lists the messages for each invalid field.

#### Example

```json
{
  "message": "The messages field is required.",
  "errors": {
    "messages": [
      "The messages field is required."
    ]
  }
}
```

- `message` (`updateTemplate.response.422.message`; string, optional)
- `errors` (`updateTemplate.response.422.errors`; map<array<string>>, optional)


Source: https://dev.touchsms.com.au/api/templates/update/index.md
