> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.meshapi.ai/api-reference/mesh-api/templates/llms.txt.
> For full documentation content, see https://developers.meshapi.ai/api-reference/mesh-api/templates/llms-full.txt.

# Update a template

PATCH https://api.meshapi.ai/v1/templates/{template_id}
Content-Type: application/json

Partially updates a template owned by the authenticated owner.

Fields omitted from the request remain unchanged. Optional fields may be
set to `null` to clear them, except for `name`.


Reference: https://developers.meshapi.ai/api-reference/mesh-api/templates/update-template

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: openapi
  version: 1.0.0
paths:
  /v1/templates/{template_id}:
    patch:
      operationId: update-template
      summary: Update a template
      description: |
        Partially updates a template owned by the authenticated owner.

        Fields omitted from the request remain unchanged. Optional fields may be
        set to `null` to clear them, except for `name`.
      tags:
        - subpackage_templates
      parameters:
        - name: template_id
          in: path
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Updated template.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TemplateSummary'
        '401':
          description: Missing, malformed, or invalid bearer token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '403':
          description: The bearer token is valid but not currently active.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '404':
          description: The requested resource was not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '409':
          description: Resource conflict, usually a duplicate template name.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '422':
          description: The request body failed validation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateTemplateRequest'
servers:
  - url: https://api.meshapi.ai
components:
  schemas:
    ChatMessageRole:
      type: string
      enum:
        - system
        - user
        - assistant
        - tool
      title: ChatMessageRole
    TextContentPart:
      type: object
      properties:
        type:
          type: string
          enum:
            - text
        text:
          type: string
      required:
        - type
        - text
      title: TextContentPart
    ImageUrlDetail:
      type: string
      enum:
        - auto
        - low
        - high
      default: auto
      title: ImageUrlDetail
    ImageUrl:
      type: object
      properties:
        url:
          type: string
          description: Remote URL or `data:` URI.
        detail:
          $ref: '#/components/schemas/ImageUrlDetail'
      required:
        - url
      title: ImageUrl
    ImageContentPart:
      type: object
      properties:
        type:
          type: string
          enum:
            - image_url
        image_url:
          $ref: '#/components/schemas/ImageUrl'
      required:
        - type
        - image_url
      title: ImageContentPart
    ContentPart:
      oneOf:
        - $ref: '#/components/schemas/TextContentPart'
        - $ref: '#/components/schemas/ImageContentPart'
      title: ContentPart
    ChatMessageContent1:
      type: array
      items:
        $ref: '#/components/schemas/ContentPart'
      title: ChatMessageContent1
    ChatMessageContent:
      oneOf:
        - type: string
        - $ref: '#/components/schemas/ChatMessageContent1'
      title: ChatMessageContent
    ToolCallFunction:
      type: object
      properties:
        name:
          type: string
        arguments:
          type: string
          description: JSON-encoded argument object.
      required:
        - name
        - arguments
      title: ToolCallFunction
    ToolCall:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
          enum:
            - function
        function:
          $ref: '#/components/schemas/ToolCallFunction'
      required:
        - id
        - type
        - function
      title: ToolCall
    ChatMessage:
      type: object
      properties:
        role:
          $ref: '#/components/schemas/ChatMessageRole'
        content:
          oneOf:
            - $ref: '#/components/schemas/ChatMessageContent'
            - type: 'null'
        name:
          type:
            - string
            - 'null'
        tool_call_id:
          type:
            - string
            - 'null'
        tool_calls:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/ToolCall'
      required:
        - role
      title: ChatMessage
    TemplateDefaultsStop:
      oneOf:
        - type: string
        - type: array
          items:
            type: string
      description: One or more stop sequences that end generation when encountered.
      title: TemplateDefaultsStop
    TemplateDefaults:
      type: object
      properties:
        temperature:
          type:
            - number
            - 'null'
          format: double
          description: >-
            Sampling temperature used for token selection. Lower values make
            output more deterministic; higher values increase randomness and
            variation.
        max_tokens:
          type:
            - integer
            - 'null'
          description: Maximum number of completion tokens to generate.
        top_p:
          type:
            - number
            - 'null'
          format: double
          description: >-
            Nucleus sampling threshold. The model samples from the smallest set
            of tokens whose cumulative probability reaches `top_p`.
        frequency_penalty:
          type:
            - number
            - 'null'
          format: double
          description: >-
            Penalizes tokens that have already appeared in the generated output,
            reducing repeated phrasing.
        presence_penalty:
          type:
            - number
            - 'null'
          format: double
          description: >-
            Penalizes tokens that have already appeared at least once, nudging
            the model toward introducing new topics.
        stop:
          oneOf:
            - $ref: '#/components/schemas/TemplateDefaultsStop'
            - type: 'null'
          description: One or more stop sequences that end generation when encountered.
        seed:
          type:
            - integer
            - 'null'
          description: >-
            Optional seed for best-effort deterministic sampling across repeated
            requests with the same parameters.
      title: TemplateDefaults
    UpdateTemplateRequest:
      type: object
      properties:
        name:
          type: string
        description:
          type:
            - string
            - 'null'
        system:
          type:
            - string
            - 'null'
        messages:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/ChatMessage'
        model:
          type:
            - string
            - 'null'
        params:
          oneOf:
            - $ref: '#/components/schemas/TemplateDefaults'
            - type: 'null'
        variables:
          type:
            - array
            - 'null'
          items:
            type: string
      title: UpdateTemplateRequest
    TemplateSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        owner:
          type:
            - string
            - 'null'
        is_global:
          type: boolean
        description:
          type:
            - string
            - 'null'
        system:
          type:
            - string
            - 'null'
        messages:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/ChatMessage'
        model:
          type:
            - string
            - 'null'
        params:
          oneOf:
            - $ref: '#/components/schemas/TemplateDefaults'
            - type: 'null'
        variables:
          type:
            - array
            - 'null'
          items:
            type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - id
        - name
        - is_global
        - created_at
        - updated_at
      title: TemplateSummary
    ErrorBodyCode:
      type: string
      enum:
        - unauthorized
        - forbidden
        - not_found
        - model_not_found
        - validation_error
        - unprocessable_entity
        - rate_limit_exceeded
        - spend_limit_exceeded
        - conflict
        - upstream_error
        - provider_not_available
        - gateway_timeout
      title: ErrorBodyCode
    ValidationErrorDetailLocItems:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorDetailLocItems
    ValidationErrorDetail:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorDetailLocItems'
        msg:
          type: string
        type:
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationErrorDetail
    ProviderError:
      type: object
      properties:
        provider:
          type: string
        status:
          type:
            - integer
            - 'null'
        message:
          type:
            - string
            - 'null'
      title: ProviderError
    ErrorBody:
      type: object
      properties:
        code:
          $ref: '#/components/schemas/ErrorBodyCode'
        message:
          type: string
        param:
          type:
            - string
            - 'null'
        details:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/ValidationErrorDetail'
        provider_error:
          oneOf:
            - $ref: '#/components/schemas/ProviderError'
            - type: 'null'
        retry_after_seconds:
          type:
            - integer
            - 'null'
      required:
        - code
        - message
      title: ErrorBody
    ErrorEnvelope:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ErrorBody'
        request_id:
          type: string
      required:
        - error
        - request_id
      title: ErrorEnvelope
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

```

## SDK Code Examples

```python Python (SDK)
from meshapi import MeshAPI, UpdateTemplateParams

client = MeshAPI(
  base_url="https://api.meshapi.ai",
  token="<dashboard-jwt-or-rsk-key>",
)

template = client.templates.update(
  "550e8400-e29b-41d4-a716-446655440000",
  UpdateTemplateParams(
    description="Updated support reply template.",
    params={"temperature": 0.1, "max_tokens": 250},
  ),
)

print(template.updated_at)

```

```typescript TypeScript (SDK)
import { MeshAPI } from "meshapi-node-sdk";

const client = new MeshAPI({
  baseUrl: "https://api.meshapi.ai",
  token: "<dashboard-jwt-or-rsk-key>",
});

const template = await client.templates.update(
  "550e8400-e29b-41d4-a716-446655440000",
  {
    description: "Updated support reply template.",
    params: { temperature: 0.1, max_tokens: 250 },
  },
);

console.log(template.updated_at);

```

```go
package main

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

func main() {

	url := "https://api.meshapi.ai/v1/templates/template_id"

	payload := strings.NewReader("{\n  \"description\": \"Updated support reply template.\",\n  \"params\": {\n    \"temperature\": 0.1,\n    \"max_tokens\": 250\n  }\n}")

	req, _ := http.NewRequest("PATCH", 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.meshapi.ai/v1/templates/template_id")

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

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"description\": \"Updated support reply template.\",\n  \"params\": {\n    \"temperature\": 0.1,\n    \"max_tokens\": 250\n  }\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.patch("https://api.meshapi.ai/v1/templates/template_id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"description\": \"Updated support reply template.\",\n  \"params\": {\n    \"temperature\": 0.1,\n    \"max_tokens\": 250\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.meshapi.ai/v1/templates/template_id', [
  'body' => '{
  "description": "Updated support reply template.",
  "params": {
    "temperature": 0.1,
    "max_tokens": 250
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.meshapi.ai/v1/templates/template_id");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"description\": \"Updated support reply template.\",\n  \"params\": {\n    \"temperature\": 0.1,\n    \"max_tokens\": 250\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "description": "Updated support reply template.",
  "params": [
    "temperature": 0.1,
    "max_tokens": 250
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.meshapi.ai/v1/templates/template_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()
```