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

# Update Template

> Update an edit template.

Applies a partial update to the template identified by `template_id`. Set
`name` to rename it and/or `form_fields` to replace its field list; omitted
fields are left unchanged. Returns the updated template, or `404` if no
template with that id exists.

Update the name and/or the form fields of an existing template. Both fields are optional; only supplied values are overwritten. Supplying `form_fields` replaces the entire list.

<RequestExample>
  ```python Python theme={null}
  from retab import Retab

  client = Retab()

  template = client.edits.templates.update(
      "edittplt_abc123",
      name="W-9 Form (2024)",
  )
  print(template.name)
  ```

  ```typescript TypeScript theme={null}
  import { Retab } from "@retab/node";

  const client = new Retab({ apiKey: process.env.RETAB_API_KEY });
  const template = await client.edits.templates.update("edittplt_abc123", "W-9 Form (2024)");
  console.log(template.name);
  ```

  ```go Go theme={null}
  package main

  import (
  	"context"
  	"fmt"
  	"log"

  	retab "github.com/retab-dev/retab/clients/go"
  )

  func ptr[T any](v T) *T { return &v }

  func main() {
  	ctx := context.Background()

  	client, err := retab.NewClient("")
  	if err != nil {
  		log.Fatal(err)
  	}

  	name := "W-9 Form (2024)"
  	template, err := client.Edits.Templates.Update(ctx, "edittplt_abc123", &retab.EditTemplatesUpdateParams{
  		Name: &name,
  	})
  	if err != nil {
  		log.Fatal(err)
  	}
  	fmt.Println(template.Name)
  }
  ```

  ```ruby Ruby theme={null}
  require 'retab'

  client = Retab::Client.new(api_key: ENV['RETAB_API_KEY'])

  template = client.edits.templates.update(
    template_id: 'edittplt_abc123',
    name: 'W-9 Form (2024)',
  )
  puts template.name
  ```

  ```rust Rust theme={null}
  use retab::models::UpdateEditTemplateRequest;
  use retab::resources::edit_templates::UpdateParams;
  use retab::Retab;

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      let client = Retab::new(std::env::var("RETAB_API_KEY")?);

      let template = client
          .edits().templates()
          .update(
              "edittplt_abc123",
              UpdateParams {
                  body: UpdateEditTemplateRequest {
                      name: Some("W-9 Form (2024)".into()),
                      form_fields: None,
                  },
              },
          )
          .await?;
      println!("{}", template.name);
      Ok(())
  }
  ```

  ```php PHP theme={null}
  <?php
  require 'vendor/autoload.php';

  use Retab\Client;

  $client = new Client(apiKey: getenv('RETAB_API_KEY'));

  $result = $client->edits()->templates()->update(
      templateId: 'tmpl_abc123',
  );
  print_r($result);
  ```

  ```csharp C# theme={null}
  using Retab;
  using RetabClient = Retab.Retab;

  var apiKey = Environment.GetEnvironmentVariable("RETAB_API_KEY")!;
  var client = new RetabClient(apiKey);

  var result = await client.Edits.Templates.UpdateAsync("tmpl_abc123", new EditTemplatesUpdateOptions());
  Console.WriteLine(result);
  ```

  ```java Java theme={null}
  import com.retab.RetabClient;

  public final class Example {
    public static void main(String[] args) throws Exception {
      RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY"));

      var result = client.edits().templates().update("tmpl_abc123", "Invoice Processing", null);
      System.out.println(result);
    }
  }
  ```

  ```curl cURL theme={null}
  curl -X PATCH \
    'https://api.retab.com/v1/edits/templates/edittplt_abc123' \
    -H "Authorization: Bearer $RETAB_API_KEY" \
    -H 'Content-Type: application/json' \
    -d '{"name": "W-9 Form (2024)"}'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "edittplt_abc123",
    "name": "W-9 Form (2024)",
    "file": {
      "id": "file_6dd6eb00688ad8d1",
      "filename": "w9_empty.pdf",
      "mime_type": "application/pdf"
    },
    "form_fields": [
      {
        "key": "full_name",
        "description": "Full legal name",
        "type": "text",
        "bbox": {
          "left": 0.15,
          "top": 0.2,
          "width": 0.35,
          "height": 0.03,
          "page": 1
        }
      }
    ],
    "field_count": 1,
    "created_at": "2024-03-15T10:30:00Z",
    "updated_at": "2024-03-15T11:15:00Z"
  }
  ```

  ```json 404 theme={null}
  {
    "detail": "Template edittplt_abc123 not found"
  }
  ```
</ResponseExample>


## OpenAPI

````yaml PATCH /v1/edits/templates/{template_id}
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.retab.com
security: []
paths:
  /v1/edits/templates/{template_id}:
    patch:
      tags:
        - Edits
        - Edit Templates
      summary: Update Template
      description: >-
        Update an edit template.


        Applies a partial update to the template identified by `template_id`.
        Set

        `name` to rename it and/or `form_fields` to replace its field list;
        omitted

        fields are left unchanged. Returns the updated template, or `404` if no

        template with that id exists.
      operationId: update_template
      parameters:
        - in: path
          name: template_id
          required: true
          schema:
            type: string
            title: Template Id
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateEditTemplateRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EditTemplate'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    UpdateEditTemplateRequest:
      properties:
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: New name for the template.
        form_fields:
          anyOf:
            - items:
                $ref: '#/components/schemas/FormField'
              type: array
            - type: 'null'
          title: Form Fields
          description: Replacement list of form fields.
      type: object
      title: UpdateEditTemplateRequest
      description: >-
        Body for updating an edit template. Only the supplied fields (`name`,
        `form_fields`) are changed.
    EditTemplate:
      properties:
        id:
          type: string
          title: Id
          description: Unique identifier of the template.
        name:
          type: string
          title: Name
          description: Name of the template.
        file:
          $ref: '#/components/schemas/FileRef'
          description: File information for the empty PDF template.
        form_fields:
          anyOf:
            - items:
                $ref: '#/components/schemas/FormField'
              type: array
            - type: 'null'
          title: Form Fields
          description: Form fields attached to the template.
        field_count:
          anyOf:
            - type: integer
            - type: 'null'
          title: Field Count
          description: Number of form fields in the template.
          default: 0
        created_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created At
          description: Timestamp of creation.
        updated_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Updated At
          description: Timestamp of last update.
      type: object
      required:
        - file
        - id
        - name
      title: EditTemplate
      description: >-
        A reusable edit template: an empty PDF and the `form_fields` defined on
        it.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
          default: []
      type: object
      title: HTTPValidationError
    FormField:
      properties:
        bbox:
          $ref: '#/components/schemas/BBox'
          description: Position and size of this field on the page.
        description:
          type: string
          title: Description
          description: >-
            Human-readable description of the field, including label and
            instructions.
        type:
          $ref: '#/components/schemas/FieldType'
          description: 'Type of field. Currently supported: ''text'' and ''checkbox''.'
        key:
          type: string
          title: Key
          description: Stable key identifying the field in the form data.
        value:
          anyOf:
            - type: string
            - type: 'null'
          title: Value
          description: Filled value of the field as text. Null when no filled value is set.
      type: object
      required:
        - bbox
        - description
        - key
        - type
      title: FormField
    FileRef:
      properties:
        id:
          type: string
          title: Id
          description: ID of the file
        filename:
          type: string
          title: Filename
          description: Filename of the file
        mime_type:
          type: string
          title: Mime Type
          description: MIME type of the file
      type: object
      required:
        - filename
        - id
        - mime_type
      title: FileRef
      description: Public/shared file reference used across SDK and customer-facing APIs.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
          default: null
        ctx:
          type: object
          title: Context
          default: {}
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    BBox:
      properties:
        left:
          type: number
          title: Left
          description: >-
            Left coordinate of the bounding box, relative to page width (0.0 =
            left edge, 1.0 = right edge).
        top:
          type: number
          title: Top
          description: >-
            Top coordinate of the bounding box, relative to page height (0.0 =
            top edge, 1.0 = bottom edge).
        width:
          type: number
          title: Width
          description: Width of the bounding box, relative to page width (0.0–1.0).
        height:
          type: number
          title: Height
          description: Height of the bounding box, relative to page height (0.0–1.0).
        page:
          type: integer
          title: Page
          description: 1-based index of the page where this field appears.
      type: object
      required:
        - height
        - left
        - page
        - top
        - width
      title: BBox
    FieldType:
      type: string
      enum:
        - text
        - checkbox
      title: FieldType
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````