> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# Update a message template

PATCH https://%7BYour_Space_Name%7D.signalwire.com/api/messaging/whatsapp/templates/{id}
Content-Type: application/json

Updates a template's `category` or `components`. A template can only be updated while it is **not yet approved** — once approved, delete and recreate it to make changes.

#### Permissions

The API token used to authenticate must have the following scope(s) enabled to make a successful request: _Numbers_.

[Learn more about API scopes](/docs/platform/your-signalwire-api-space).

Reference: https://signalwire.com/docs/apis/rest/whatsapp/update-whatsapp-template

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: signalwire-rest
  version: 1.0.0
paths:
  /api/messaging/whatsapp/templates/{id}:
    patch:
      operationId: update_whatsapp_template
      summary: Update a message template
      description: >-
        Updates a template's `category` or `components`. A template can only be
        updated while it is **not yet approved** — once approved, delete and
        recreate it to make changes.


        #### Permissions


        The API token used to authenticate must have the following scope(s)
        enabled to make a successful request: _Numbers_.


        [Learn more about API scopes](/docs/platform/your-signalwire-api-space).
      tags:
        - whatsAppTemplates
      parameters:
        - name: id
          in: path
          description: >-
            The template ID — either the SignalWire ID (a UUID) or the Meta
            template ID (a numeric string). Both are accepted.
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          description: >-
            SignalWire Basic Authentication using Project ID and API Token.


            The client sends HTTP requests with the Authorization header
            containing

            the word Basic followed by a space and a base64-encoded string of
            project_id:token.

            The project ID will be used as the username and the API token as the
            password.


            Example:

            ```

            Authorization: Basic base64(project_id:token)

            ```
          required: true
          schema:
            type: string
      responses:
        '200':
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WhatsAppTemplateResponse'
        '400':
          description: The request is invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Types.StatusCodes.StatusCode400'
        '401':
          description: Access is unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Types.StatusCodes.StatusCode401'
        '404':
          description: The server cannot find the requested resource.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Types.StatusCodes.StatusCode404'
        '422':
          description: The request contains invalid parameters. See errors for details.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Types.StatusCodes.StatusCode422'
        '500':
          description: An internal server error occurred.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Types.StatusCodes.StatusCode500'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateWhatsAppTemplateRequest'
servers:
  - url: https://%7BYour_Space_Name%7D.signalwire.com
    description: SignalWire API
components:
  schemas:
    WhatsAppTemplateCategory:
      type: string
      enum:
        - utility
        - marketing
        - authentication
      description: The category of a WhatsApp message template.
      title: WhatsAppTemplateCategory
    WhatsAppTemplateComponent:
      type: object
      properties:
        type:
          type: string
          description: 'The component type: `HEADER`, `BODY`, `FOOTER`, or `BUTTONS`.'
      required:
        - type
      description: >-
        A template component. The `type` is one of `HEADER`, `BODY`, `FOOTER`,
        or `BUTTONS`. Additional fields depend on the component type — for
        example, a `BODY` carries `text`, while `BUTTONS` carries a `buttons`
        array. See the create example for the full shape.
      title: WhatsAppTemplateComponent
    UpdateWhatsAppTemplateRequest:
      type: object
      properties:
        category:
          $ref: '#/components/schemas/WhatsAppTemplateCategory'
          description: The updated template category. Required if `components` is omitted.
        components:
          type: array
          items:
            $ref: '#/components/schemas/WhatsAppTemplateComponent'
          description: The updated components. Required if `category` is omitted.
      description: >-
        Request body for updating a template. Provide `category`, `components`,
        or both. A template can only be updated while it is not yet approved.
      title: UpdateWhatsAppTemplateRequest
    uuid:
      type: string
      format: uuid
      description: Universal Unique Identifier.
      title: uuid
    WhatsAppTemplateParameterFormat:
      type: string
      enum:
        - named
        - positional
      description: How a template's variable placeholders are referenced.
      title: WhatsAppTemplateParameterFormat
    WhatsAppTemplateStatus:
      type: string
      enum:
        - approved
        - archived
        - deleted
        - disabled
        - flagged
        - in_appeal
        - limit_exceeded
        - locked
        - paused
        - pending
        - reinstated
        - pending_deletion
        - rejected
      description: >-
        The Meta approval status of a template. A template must be `approved`
        before it can be used to send messages.
      title: WhatsAppTemplateStatus
    WhatsAppTemplateResponse:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/uuid'
          description: The SignalWire identifier of the template.
        name:
          type: string
          description: The template name. Lowercase letters, numbers, and underscores only.
        category:
          $ref: '#/components/schemas/WhatsAppTemplateCategory'
          description: The template category.
        components:
          type: array
          items:
            $ref: '#/components/schemas/WhatsAppTemplateComponent'
          description: The template's components (header, body, footer, buttons).
        language:
          type: string
          description: The template language code.
        parameter_format:
          $ref: '#/components/schemas/WhatsAppTemplateParameterFormat'
          description: How the template's variable placeholders are referenced.
        template_id:
          type: string
          description: Meta's identifier for the template.
        template_status:
          $ref: '#/components/schemas/WhatsAppTemplateStatus'
          description: The Meta approval status of the template.
        whatsapp_business_id:
          $ref: '#/components/schemas/uuid'
          description: >-
            The SignalWire identifier of the WhatsApp Business Account the
            template belongs to.
        created_at:
          type: string
          description: The date and time when the template was created.
        updated_at:
          type: string
          description: The date and time when the template was last updated.
        discarded_at:
          type: string
          description: The date and time when the template was discarded, if applicable.
      required:
        - id
        - name
        - category
        - components
        - language
        - parameter_format
        - template_id
        - template_status
        - whatsapp_business_id
        - created_at
        - updated_at
      description: Response containing a single message template.
      title: WhatsAppTemplateResponse
    TypesStatusCodesStatusCode400Error:
      type: string
      enum:
        - Bad Request
      title: TypesStatusCodesStatusCode400Error
    Types.StatusCodes.StatusCode400:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/TypesStatusCodesStatusCode400Error'
      required:
        - error
      description: The request is invalid.
      title: Types.StatusCodes.StatusCode400
    TypesStatusCodesStatusCode401Error:
      type: string
      enum:
        - Unauthorized
      title: TypesStatusCodesStatusCode401Error
    Types.StatusCodes.StatusCode401:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/TypesStatusCodesStatusCode401Error'
      required:
        - error
      description: Access is unauthorized.
      title: Types.StatusCodes.StatusCode401
    TypesStatusCodesStatusCode404Error:
      type: string
      enum:
        - Not Found
      title: TypesStatusCodesStatusCode404Error
    Types.StatusCodes.StatusCode404:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/TypesStatusCodesStatusCode404Error'
      required:
        - error
      description: The server cannot find the requested resource.
      title: Types.StatusCodes.StatusCode404
    Types.StatusCodes.RestApiErrorItem:
      type: object
      properties:
        type:
          type: string
          description: The category of error.
        code:
          type: string
          description: A specific error code.
        message:
          type: string
          description: A description of what caused the error.
        attribute:
          type:
            - string
            - 'null'
          description: The request parameter that caused the error, if applicable.
        url:
          type: string
          description: A link to documentation about this error.
      required:
        - type
        - code
        - message
        - url
      description: Details about a specific error.
      title: Types.StatusCodes.RestApiErrorItem
    Types.StatusCodes.StatusCode422:
      type: object
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/Types.StatusCodes.RestApiErrorItem'
          description: List of validation errors.
      required:
        - errors
      description: The request contains invalid parameters. See errors for details.
      title: Types.StatusCodes.StatusCode422
    TypesStatusCodesStatusCode500Error:
      type: string
      enum:
        - Internal Server Error
      title: TypesStatusCodesStatusCode500Error
    Types.StatusCodes.StatusCode500:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/TypesStatusCodesStatusCode500Error'
      required:
        - error
      description: An internal server error occurred.
      title: Types.StatusCodes.StatusCode500
  securitySchemes:
    SignalWireBasicAuth:
      type: http
      scheme: basic
      description: >-
        SignalWire Basic Authentication using Project ID and API Token.


        The client sends HTTP requests with the Authorization header containing

        the word Basic followed by a space and a base64-encoded string of
        project_id:token.

        The project ID will be used as the username and the API token as the
        password.


        Example:

        ```

        Authorization: Basic base64(project_id:token)

        ```

```

## Examples



**Request**

```json
{}
```

**Response**

```json
{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "name": "order_update",
  "category": "utility",
  "components": [
    {
      "type": "BODY"
    }
  ],
  "language": "en_US",
  "parameter_format": "positional",
  "template_id": "1164792772433648",
  "template_status": "approved",
  "whatsapp_business_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-01-15T10:30:00Z",
  "discarded_at": "2024-01-15T10:30:00Z"
}
```

**SDK Code**

```python
import requests

url = "https://{your_space_name}.signalwire.com/api/messaging/whatsapp/templates/id"

payload = {}
headers = {
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers, auth=("<project_id>", "<api_token>"))

print(response.json())
```

```javascript
const url = 'https://{your_space_name}.signalwire.com/api/messaging/whatsapp/templates/id';
const credentials = btoa("<project_id>:<api_token>");

const options = {
  method: 'PATCH',
  headers: {
    Authorization: `Basic ${credentials}`,
    'Content-Type': 'application/json'
  },
  body: '{}'
};

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://{your_space_name}.signalwire.com/api/messaging/whatsapp/templates/id"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.SetBasicAuth("<project_id>", "<api_token>")
	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://{your_space_name}.signalwire.com/api/messaging/whatsapp/templates/id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request.basic_auth("<project_id>", "<api_token>")
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://{your_space_name}.signalwire.com/api/messaging/whatsapp/templates/id")
  .basicAuth("<project_id>", "<api_token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://{your_space_name}.signalwire.com/api/messaging/whatsapp/templates/id', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
    'auth' => ['<project_id>', '<api_token>'],
]);

echo $response->getBody();
```

```csharp
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://{your_space_name}.signalwire.com/api/messaging/whatsapp/templates/id");
client.Authenticator = new HttpBasicAuthenticator("<project_id>", "<api_token>");
var request = new RestRequest(Method.PATCH);

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let credentials = Data("<project_id>:<api_token>".utf8).base64EncodedString()

let headers = [
  "Authorization": "Basic \(credentials)",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://{your_space_name}.signalwire.com/api/messaging/whatsapp/templates/id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
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()
```