> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.mercoa.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.mercoa.com/_mcp/server.

# Update entity email template

PUT https://api.mercoa.com/entity/{entityId}/email-template/{emailTemplateId}
Content-Type: application/json

Update entity email template

Reference: https://docs.mercoa.com/embedded-ap-ar/api-reference/entity/email-template/update

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `entityId` (string, required) — Entity ID or Entity ForeignID
- `emailTemplateId` (string, required) — Email Template ID or Email Template ForeignID

### Body (application/json)

This endpoint expects an object.

- `templateType` (enum, required)
  - Allowed values: `PAYMENT`, `DISBURSEMENT`
- `name` (string, required) — The name of the email template.
- `subject` (string, required) — The subject of the email template.
- `content` (string, required) — The HTML content of the email template.
- `isDefault` (boolean, optional) — If true, this email template will be used as the default template for new invoices.

## Response

### 200

- `id` (string, required)
- `entityId` (string, required) — The ID of the entity that this email template is associated with.
- `templateType` (enum, required)
  - Allowed values: `PAYMENT`, `DISBURSEMENT`
- `name` (string, required) — The name of the email template.
- `subject` (string, required) — The subject of the email template.
- `content` (string, required) — The HTML content of the email template.
- `isDefault` (boolean, required) — True if this email template is the default template for new invoices.

## Errors

### 400 Bad Request

- `errorName` ("BadRequest", required)
- `content` (string, required)

### 401 Unauthorized

- `errorName` ("Unauthorized", required)
- `content` (string, required)

### 403 Forbidden

- `errorName` ("Forbidden", required)
- `content` (string, required)

### 404 Not Found

- `errorName` ("NotFound", required)
- `content` (string, required)

### 409 Conflict

- `errorName` ("Conflict", required)
- `content` (string, required)

### 500 Internal Server Error

- `errorName` ("InternalServerError", required)
- `content` (string, required)

### 501 Unimplemented

- `errorName` ("Unimplemented", required)
- `content` (string, required)

## Examples

**Request**

```json
{
  "templateType": "PAYMENT",
  "name": "Generic Payment Email",
  "subject": "Action Required - Your payment is due",
  "content": "<h1>Your invoice has been sent.</h1>",
  "isDefault": true
}
```

**Response**

```json
{
  "id": "emt_8545a84e-a45f-41bf-bdf1-33b42a55812c",
  "entityId": "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d",
  "templateType": "PAYMENT",
  "name": "Generic Payment Email",
  "subject": "Action Required - Your payment is due",
  "content": "<h1>Your invoice has been sent.</h1>",
  "isDefault": true
}
```

**SDK Code**

```python
import requests

url = "https://api.mercoa.com/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/email-template/emt_8545a84e-a45f-41bf-bdf1-33b42a55812c"

payload = {
    "templateType": "PAYMENT",
    "name": "Generic Payment Email",
    "subject": "Action Required - Your payment is due",
    "content": "<h1>Your invoice has been sent.</h1>",
    "isDefault": True
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```typescript
import { MercoaClient } from "@mercoa/javascript";

const client = new MercoaClient({ token: "YOUR_TOKEN" });
await client.entity.emailTemplate.update("ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced", "emt_8545a84e-a45f-41bf-bdf1-33b42a55812c", {
    templateType: "PAYMENT",
    name: "Generic Payment Email",
    subject: "Action Required - Your payment is due",
    content: "<h1>Your invoice has been sent.</h1>",
    isDefault: true
});

```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.mercoa.com/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/email-template/emt_8545a84e-a45f-41bf-bdf1-33b42a55812c"

	payload := strings.NewReader("{\n  \"templateType\": \"PAYMENT\",\n  \"name\": \"Generic Payment Email\",\n  \"subject\": \"Action Required - Your payment is due\",\n  \"content\": \"<h1>Your invoice has been sent.</h1>\",\n  \"isDefault\": true\n}")

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

	req.Header.Add("Authorization", "Bearer <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://api.mercoa.com/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/email-template/emt_8545a84e-a45f-41bf-bdf1-33b42a55812c")

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"templateType\": \"PAYMENT\",\n  \"name\": \"Generic Payment Email\",\n  \"subject\": \"Action Required - Your payment is due\",\n  \"content\": \"<h1>Your invoice has been sent.</h1>\",\n  \"isDefault\": true\n}"

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.put("https://api.mercoa.com/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/email-template/emt_8545a84e-a45f-41bf-bdf1-33b42a55812c")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"templateType\": \"PAYMENT\",\n  \"name\": \"Generic Payment Email\",\n  \"subject\": \"Action Required - Your payment is due\",\n  \"content\": \"<h1>Your invoice has been sent.</h1>\",\n  \"isDefault\": true\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.mercoa.com/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/email-template/emt_8545a84e-a45f-41bf-bdf1-33b42a55812c', [
  'body' => '{
  "templateType": "PAYMENT",
  "name": "Generic Payment Email",
  "subject": "Action Required - Your payment is due",
  "content": "<h1>Your invoice has been sent.</h1>",
  "isDefault": true
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.mercoa.com/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/email-template/emt_8545a84e-a45f-41bf-bdf1-33b42a55812c");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"templateType\": \"PAYMENT\",\n  \"name\": \"Generic Payment Email\",\n  \"subject\": \"Action Required - Your payment is due\",\n  \"content\": \"<h1>Your invoice has been sent.</h1>\",\n  \"isDefault\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "templateType": "PAYMENT",
  "name": "Generic Payment Email",
  "subject": "Action Required - Your payment is due",
  "content": "<h1>Your invoice has been sent.</h1>",
  "isDefault": true
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity/ent_a0f6ea94-0761-4a5e-a416-3c453cb7eced/email-template/emt_8545a84e-a45f-41bf-bdf1-33b42a55812c")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
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()
```