# Edit Template

Canonical: https://docs.bluehola.com/docs/templates-flows-media/patch-v1-templates-id
OpenAPI: https://docs.bluehola.com/openapi.yaml

<div class="endpoint"><span class="endpoint-method endpoint-method--patch">PATCH</span><code class="endpoint-path">/v1/templates/{id}</code></div>

Edit template content or Max Price. Content changes return to PENDING for review; bid-only changes retain the current status.

:::note[Authentication]

Send `Authorization: Bearer <API_KEY>` in the request headers; required scope: `templates:manage`. Which resources an API Key can reach is determined by its current authorization scope.

:::

## Request

Base URL: `https://api.bluehola.com`

### Parameters

| Name | In | Required | Type / constraints | Description |
| --- | --- | --- | --- | --- |
| `id` | path | Yes | string | The platform's template ID, `tmpl_...` |

### Request body
A request body is required.
### Request body fields

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `components` | array | No | The new component array (replaces the whole thing) |
| `category` | MARKETING \| UTILITY \| AUTHENTICATION | No | The new category |
| `parameterFormat` | positional \| named | No | The parameter placeholder style |
| `allowCategoryChange` | boolean | No | Allow Meta to reclassify the category during review (avoids rejection over a category mismatch) |
| `messageSendTtlSeconds` | integer | No | The TTL for messages sent with this template |
| `optimizationSpec` | object | No | Set, change or clear Max Price; see below |

Content-Type: `application/json`
Schema:

```json
{
  "type": "object",
  "properties": {
    "components": {
      "type": "string",
      "description": "array · optional — The new component array (replaces the whole thing)"
    },
    "category": {
      "type": "string",
      "description": "MARKETING | UTILITY | AUTHENTICATION · optional — The new category"
    },
    "parameterFormat": {
      "type": "string",
      "description": "positional | named · optional — The parameter placeholder style"
    },
    "allowCategoryChange": {
      "type": "string",
      "description": "boolean · optional — Allow Meta to reclassify the category during review (avoids rejection over a category mismatch)"
    },
    "messageSendTtlSeconds": {
      "type": "string",
      "description": "integer · optional — The TTL for messages sent with this template"
    },
    "optimizationSpec": {
      "type": "string",
      "description": "object · optional — Max Price (MARKETING only): `{ bidAmount, bidStrategy: LOWEST_COST_WITH_BID_CAP, bidCountryMultiplierOverrides? }`. bidAmount is the maximum price per 1,000 deliveries in the smallest unit of the Messaging account currency ($0.05 per delivery = 5000). It may be below, equal to, or above the rate card; Meta charges no more than the effective bid. When editing, pass null for both bid fields to clear Max Price and return to rate-card billing."
    }
  }
}
```

## Response

| Status | Description |
| --- | --- |
| `200` | OK |
| `4xx` | Client error |

### 200 response schema

```json
{
  "$ref": "#/components/schemas/MessageTemplate"
}
```

For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md).

## Notes

#### Only APPROVED / REJECTED templates can be edited
A PENDING template is currently under review, and editing it would be rejected by Meta — the platform blocks it locally first and returns 409, so you see "wait for the review outcome" rather than an opaque upstream error.

#### Content edits return to PENDING; bid-only edits do not
Changing `components`, `category`, `parameterFormat` or `messageSendTtlSeconds` makes Meta review the template again, so the local status returns to `PENDING` and the previous rejection reason is cleared. The review outcome is filled in by the `message_template_status_update` webhook.

Changing **only** `optimizationSpec` keeps the current status, so an `APPROVED` template does not become temporarily unsendable just because its bid changed. A new bid can take up to one hour to take effect.

#### Updating or clearing Max Price

- Omitting `optimizationSpec` leaves the bid unchanged.
- To set or change it, provide both `bidAmount` and `bidStrategy`. Omitting `bidCountryMultiplierOverrides` preserves the existing country map; `{}` clears it; a non-empty map replaces it as a whole.
- To return to rate-card billing, send exactly `{ "bidAmount": null, "bidStrategy": null }`. Do not include country overrides in a clear request.
- A template with Max Price cannot be moved out of `MARKETING` directly; clear the bid first.

#### No local content-difference check
The platform does not compare the submitted fields with the currently stored template content. An empty request body is rejected with `400 nothing to update`; otherwise, the supplied fields are forwarded to Meta even if their values appear unchanged. If Meta accepts a content edit, the local status changes to `PENDING`; a bid-only edit follows the rule above. If Meta rejects the request, the API returns that error and the local template is not changed to `PENDING`. There is no separate "resubmit unchanged content" endpoint, so do not call this endpoint merely to force another review unless an actual edit is required.

#### `name` and `language` cannot be changed
Meta's edit endpoint has no fields for either — to change the name, create a new template instead. The request body is `.strict()`: sending them returns 400 rather than being silently ignored.

A template with no Meta template id locally (never synced) returns 409; call `POST /v1/templates/sync` first.
