> ## 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.

# List Templates

> List edit templates.

Returns a paginated list of edit templates. Filter by `name`
(case-insensitive substring match) and order results by `sort_by`
(`created_at` or `name`). Page with `before`/`after` cursors, `limit`, and
`order`. Form fields are omitted from list items; fetch a single template to
retrieve them.

List templates registered for your organization. `form_fields` is omitted from the list response for performance — fetch a single template with `GET /v1/edits/templates/{template_id}` to see the full field list.

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

  client = Retab()
  templates = client.edits.templates.list(limit=20, order="desc")
  for template in templates.data:
      print(f"{template.id}: {template.name} ({template.field_count} fields)")
  ```

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

  const client = new Retab({ apiKey: process.env.RETAB_API_KEY });
  const templates = await client.edits.templates.list({
    limit: 20,
    order: "desc",
  });
  for (const template of templates.data) {
    console.log(`${template.id}: ${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)
  	}

  	templates, err := client.Edits.Templates.List(ctx, &retab.EditTemplatesListParams{
  		PaginationParams: retab.PaginationParams{Limit: ptr(20), Order: ptr("desc")},
  	})
  	if err != nil {
  		log.Fatal(err)
  	}
  	for _, template := range templates.Data {
  		fmt.Printf("%s: %s (%v fields)\n", template.ID, template.Name, template.FieldCount)
  	}
  }
  ```

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

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

  templates = client.edits.templates.list(limit: 20, order: 'desc')
  templates.data.each do |template|
    puts "#{template.id}: #{template.name} (#{template.field_count} fields)"
  end
  ```

  ```rust Rust theme={null}
  use retab::enums::EditTemplatesOrder;
  use retab::resources::edit_templates::ListParams;
  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 templates = client
          .edits().templates()
          .list(ListParams {
              limit: Some(20),
              order: Some(EditTemplatesOrder::Desc),
              ..Default::default()
          })
          .await?;
      for template in &templates.data {
          println!(
              "{}: {} ({} fields)",
              template.id,
              template.name,
              template.field_count.unwrap_or_default()
          );
      }
      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()->list();
  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.ListAsync(new EditTemplatesListOptions());
  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().list(null, null, 10L, null, "Invoice Processing", "created_at");
      System.out.println(result);
    }
  }
  ```

  ```curl cURL theme={null}
  curl -X GET \
    'https://api.retab.com/v1/edits/templates?limit=20&order=desc' \
    -H "Authorization: Bearer $RETAB_API_KEY"
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "data": [
      {
        "id": "edittplt_abc123",
        "name": "W-9 Form",
        "file": {
          "id": "file_6dd6eb00688ad8d1",
          "filename": "w9_empty.pdf",
          "mime_type": "application/pdf"
        },
        "form_fields": [],
        "field_count": 7,
        "created_at": "2024-03-15T10:30:00Z",
        "updated_at": "2024-03-15T10:30:00Z"
      }
    ],
    "list_metadata": {
      "before": null,
      "after": "edittplt_abc123"
    }
  }
  ```
</ResponseExample>


## OpenAPI

````yaml GET /v1/edits/templates
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.retab.com
security: []
paths:
  /v1/edits/templates:
    get:
      tags:
        - Edits
        - Edit Templates
      summary: List Templates
      description: >-
        List edit templates.


        Returns a paginated list of edit templates. Filter by `name`

        (case-insensitive substring match) and order results by `sort_by`

        (`created_at` or `name`). Page with `before`/`after` cursors, `limit`,
        and

        `order`. Form fields are omitted from list items; fetch a single
        template to

        retrieve them.
      operationId: list_templates
      parameters:
        - in: query
          name: before
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Before
          required: false
        - in: query
          name: after
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: After
          required: false
        - in: query
          name: limit
          schema:
            type: integer
            maximum: 100
            minimum: 1
            default: 10
            title: Limit
          required: false
        - in: query
          name: order
          schema:
            enum:
              - asc
              - desc
            type: string
            default: desc
            title: Order
          required: false
        - in: query
          name: name
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Name
          required: false
        - in: query
          name: sort_by
          schema:
            type: string
            default: created_at
            title: Sort By
          required: false
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EditTemplateList'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    EditTemplateList:
      description: >-
        A page of `EditTemplate` resources. `data` holds the items and
        `list_metadata` carries the `before`/`after` cursors; pass `after` to
        fetch the next page.
      properties:
        data:
          items:
            $ref: '#/components/schemas/EditTemplate'
          type: array
          title: Data
        list_metadata:
          $ref: '#/components/schemas/ListMetadata'
      type: object
      required:
        - data
        - list_metadata
      title: EditTemplateList
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
          default: []
      type: object
      title: HTTPValidationError
    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.
    ListMetadata:
      properties:
        before:
          anyOf:
            - type: string
            - type: 'null'
          title: Before
        after:
          anyOf:
            - type: string
            - type: 'null'
          title: After
      type: object
      required:
        - after
        - before
      title: ListMetadata
      description: Boundary resource IDs for page navigation.
    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
    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.
    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
    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

````