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

# Update a Template

The **Update a Template** endpoint allows you to modify an existing template identified by `{template_id}`. You can update one or more fields of the template schema. Any field that is not provided in the request will remain unchanged.

<Note>Note that this process can also be done in the [ParDocs Console](https://www.pardocs.com)</Note>

**Request Body Parameters:**

* `document_type` (string, optional): Specifies the document type the schema applies to.
* `template_data` (object, optional): Contains the updated schema definition for the extraction.

<RequestExample>
  ```bash cURL theme={null}
  curl --request PATCH \
    --url https://api.pardocs.com/v1/templates/{template_id} \
    --header 'Content-Type: application/json' \
    --header 'x-api-key: <api-key>' \
    --data '{
    "document_type": "<string>",
    "template_data": {}
  }'
  ```

  ```python Python theme={null}
  import json
  import requests

  url = "https://api.pardocs.com/v1/templates/{template_id}"
  headers = {
      "x-api-key": "<api-key>",
      "Content-Type": "application/json"
  }
  data = {
      "document_type": "<string>",
      "template_data": {}
  }

  response = requests.patch(url, headers=headers, data=json.dumps(data))

  print(response.json())
  ```
</RequestExample>


## OpenAPI

````yaml openapi-templates PATCH /v1/templates/{template_id}
openapi: 3.1.0
info:
  title: Template API
  version: 1.0.1
servers:
  - url: https://api.pardocs.com
security:
  - ApiKeyAuth: []
paths:
  /v1/templates/{template_id}:
    patch:
      parameters:
        - name: template_id
          in: path
          required: true
          schema:
            type: string
          description: The ID of template to update.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TemplateRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TemplateResponse'
        4XX:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    TemplateRequest:
      type: object
      properties:
        document_type:
          type: string
          description: The type of the document.
        template_data:
          type: object
          description: The key-value pairs of information extracted from the document.
    TemplateResponse:
      type: object
      properties:
        template_id:
          type: string
          description: ''
        document_type:
          type: string
          description: The type of the document.
        template_data:
          type: object
          description: The key-value pairs of information extracted from the document.
        template_created_at:
          type: integer
          description: ''
        template_updated_at:
          type: integer
          description: ''
    Error:
      required:
        - detail
      type: object
      properties:
        detail:
          type: string
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````