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

# Duplicate Template

> Create a copy of an existing extraction template.

## Authentication & Scope

Requires the `templates-write` ability.

## Request

```http theme={null}
POST /extractions/templates/550e8400-e29b-41d4-a716-446655440000/duplicate HTTP/1.1
Host: api.raydocs.com
Authorization: Bearer <token>
Content-Type: application/json

{
  "name": "Invoice Extraction (Copy)"
}
```

### Path Parameters

| Parameter    | Type | Required | Description                  |
| ------------ | ---- | -------- | ---------------------------- |
| `templateId` | uuid | Yes      | The template ID to duplicate |

### Body Parameters

| Parameter | Type   | Required | Description                                                                |
| --------- | ------ | -------- | -------------------------------------------------------------------------- |
| `name`    | string | No       | Name for the new template. Defaults to original name with " (Copy)" suffix |

## Response

`201 Created` – The newly created template copy.

```json theme={null}
{
  "id": "660e8400-e29b-41d4-a716-446655440001",
  "name": "Invoice Extraction (Copy)",
  "description": "Extract key fields from invoices",
  "schema_json": { ... },
  "settings": { ... },
  "workspace_id": 1,
  "created_at": "2024-01-16T10:30:00Z",
  "updated_at": "2024-01-16T10:30:00Z"
}
```

<Tip>
  Duplicating a template is useful for creating variations or testing schema changes without affecting the original.
</Tip>


## OpenAPI

````yaml post /extractions/templates/{templateId}/duplicate
openapi: 3.0.1
info:
  title: Raydocs API
  description: REST API for document extraction with AI-powered data parsing
  version: 1.0.0
servers:
  - url: https://api.raydocs.com
security:
  - bearerAuth: []
tags:
  - name: Workspaces
    description: Create and manage workspaces.
  - name: Workspace Users
    description: Manage users within a workspace.
  - name: Extraction Templates
    description: Define extraction schemas and settings.
  - name: Extraction Sessions
    description: Manage extraction jobs and documents.
  - name: Batch Operations
    description: Bulk operations on sessions.
  - name: Documents
    description: Upload and manage source documents.
  - name: Workflows
    description: Discover workflow runs and read their public outputs.
  - name: Results
    description: Access extraction results.
paths:
  /extractions/templates/{templateId}/duplicate:
    post:
      tags:
        - Extraction Templates
      summary: Duplicate Template
      description: Create a copy of an existing template. Requires `templates-write`.
      operationId: duplicateTemplate
      parameters:
        - name: templateId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '201':
          description: Duplicated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExtractionTemplate'
        '403':
          description: Forbidden
components:
  schemas:
    ExtractionTemplate:
      type: object
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        name:
          type: string
        description:
          type: string
        schema_json:
          $ref: '#/components/schemas/ExtractionSchema'
        settings:
          type: object
          properties:
            parsing:
              type: object
              properties:
                contextual_embedding:
                  type: boolean
        workspace_id:
          type: integer
        created_at:
          type: string
          format: date-time
          readOnly: true
        updated_at:
          type: string
          format: date-time
          readOnly: true
    ExtractionSchema:
      type: object
      description: JSON schema defining extraction fields and groups
      properties:
        config:
          type: object
          properties:
            reasoning_enabled:
              type: boolean
            system_message:
              type: string
        definitions:
          type: object
          additionalProperties: true
        groups:
          type: object
          additionalProperties:
            type: object
            properties:
              search_query:
                type: string
              extraction_prompt:
                type: string
              fields:
                type: object
                additionalProperties: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >
        Personal Access Token created from the Raydocs dashboard.

        Include in the Authorization header: `Bearer <your_token>`

        See [API Keys](/api-reference/api-keys) for token creation and
        management.

````