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

# List Folders

> Retrieve a paginated list of the folders in a project, so a template can be filed into the right one.

Folder IDs are what `folder_id` on `POST /templates` expects. Folders belong to a module: a `transactional` folder holds the templates you send single emails with, a `campaign` folder holds the ones the campaign builder can pick. A template's folder must belong to the same module as its `purpose`.

Lists the folders templates are filed into, with each folder's mode and how many templates it holds.

This is the only endpoint that returns folder IDs. Without it, `folder_id` on [Create Template](https://docs.lettr.com/api-reference/templates/create-template.md) can only be omitted — letting the API pick a folder — or guessed from an integer read out of an app URL.

## Modes

Folders are mode-scoped, matching the [transactional / marketing split](https://docs.lettr.com/learn/templates/projects.md#transactional-vs-marketing-templates). Filter with `purpose` to get just one side:

```bash theme={null}
curl "https://app.lettr.com/api/folders?purpose=campaign" \
  -H "Authorization: Bearer $LETTR_API_KEY"
```

A template's `folder_id` must name a folder of the same mode as its `purpose`. [Create Template](https://docs.lettr.com/api-reference/templates/create-template.md) rejects a folder of the other mode with `422`, and when you leave `folder_id` out, the template goes to the main folder of its mode.

You can also pass `folder_id` to [List Templates](https://docs.lettr.com/api-reference/templates/list-templates.md) to list only the templates in one folder.

## Read-only

Folders are created and managed in the app. There is no API to create, rename or delete one, because deleting a folder moves or deletes the templates inside it.


## OpenAPI

````yaml GET /folders
openapi: 3.1.0
info:
  title: Lettr API
  version: 1.0.0
  description: >-
    Lettr Email API - Send transactional emails with tracking, attachments, and
    personalization.
  contact:
    name: Lettr Support
    url: https://lettr.com
  license:
    name: Proprietary
    url: https://lettr.com/terms
servers:
  - url: https://app.lettr.com/api
    description: Production
security: []
tags:
  - name: Emails
    description: Email sending operations
  - name: Templates
    description: Email template management operations
  - name: Domains
    description: Domain management operations
  - name: Webhooks
    description: Webhook management operations
  - name: Audience
    description: 'Audience management: lists, contacts, topics, properties, and segments'
  - name: Campaigns
    description: >-
      Campaign operations: listing, stats, engagement events, and
      dispatch/scheduling
paths:
  /folders:
    get:
      tags:
        - Templates
      summary: List Folders
      description: >-
        Retrieve a paginated list of the folders in a project, so a template can
        be filed into the right one.


        Folder IDs are what `folder_id` on `POST /templates` expects. Folders
        belong to a module: a `transactional` folder holds the templates you
        send single emails with, a `campaign` folder holds the ones the campaign
        builder can pick. A template's folder must belong to the same module as
        its `purpose`.
      operationId: listFolders
      parameters:
        - name: project_id
          in: query
          description: >-
            Project ID to retrieve folders from. If not provided, uses the
            team's default project.
          schema:
            type: integer
            minimum: 1
        - name: purpose
          in: query
          description: >-
            Return only the folders of one module. If not provided, folders of
            both modules are returned.
          schema:
            type: string
            enum:
              - transactional
              - campaign
            example: campaign
        - name: per_page
          in: query
          description: Number of results per page (1-100)
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 25
        - name: page
          in: query
          description: Page number
          schema:
            type: integer
            minimum: 1
            default: 1
      responses:
        '200':
          description: Folders retrieved successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListFoldersResponse'
              example:
                message: Folders retrieved successfully.
                data:
                  folders:
                    - id: 10
                      name: Emails
                      project_id: 5
                      purpose: transactional
                      templates_count: 8
                      created_at: '2025-01-15T10:00:00+00:00'
                      updated_at: '2025-01-20T14:30:00+00:00'
                    - id: 11
                      name: Campaigns
                      project_id: 5
                      purpose: campaign
                      templates_count: 12
                      created_at: '2025-01-15T10:00:00+00:00'
                      updated_at: '2025-02-02T09:12:00+00:00'
                  pagination:
                    total: 2
                    per_page: 25
                    current_page: 1
                    last_page: 1
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedResponse'
        '404':
          description: Project not found or no default project configured
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                project_not_found:
                  summary: Project not found
                  value:
                    message: >-
                      Project with ID '123' was not found or you don't have
                      access to it.
                    error_code: not_found
                no_default_project:
                  summary: No default project configured
                  value:
                    message: No default project is configured for this team.
                    error_code: not_found
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
              example:
                message: Validation failed.
                error_code: validation_error
                errors:
                  purpose:
                    - The purpose must be either transactional or campaign.
        '503':
          $ref: '#/components/responses/ServiceUnavailableError'
      security:
        - bearerAuth: []
components:
  schemas:
    ListFoldersResponse:
      type: object
      description: Response containing a paginated list of folders
      required:
        - message
        - data
      properties:
        message:
          type: string
          description: Human-readable response message
          example: Folders retrieved successfully.
        data:
          type: object
          required:
            - folders
            - pagination
          properties:
            folders:
              type: array
              description: List of folders
              items:
                $ref: '#/components/schemas/FolderView'
            pagination:
              $ref: '#/components/schemas/FoldersPagination'
    UnauthorizedResponse:
      type: object
      required:
        - message
      description: Error response for authentication failures (401).
      properties:
        message:
          type: string
          description: Human-readable error message
          example: API key is required.
    ErrorResponse:
      type: object
      required:
        - message
        - error_code
      description: Error response for non-validation errors (400, 409, 500, 502).
      properties:
        message:
          type: string
          description: Human-readable error message
          example: The sender domain could not be determined from the email address.
        error_code:
          $ref: '#/components/schemas/ErrorCode'
    ValidationErrorResponse:
      type: object
      required:
        - message
        - error_code
        - errors
      properties:
        message:
          type: string
          description: Human-readable error message
          example: Validation failed.
        error_code:
          type: string
          description: Error code (always `validation_error` for 422 responses)
          const: validation_error
          example: validation_error
        errors:
          type: object
          description: Field-specific validation errors
          additionalProperties:
            type: array
            items:
              type: string
          example:
            from:
              - The sender email address is required.
            to:
              - At least one recipient email address is required.
    FolderView:
      type: object
      description: View of a folder templates are filed into
      required:
        - id
        - name
        - project_id
        - purpose
        - templates_count
        - created_at
        - updated_at
      properties:
        id:
          type: integer
          description: >-
            Unique identifier for the folder. This is what `folder_id` on `POST
            /templates` expects.
          example: 10
        name:
          type: string
          description: Name of the folder
          example: Campaigns
        project_id:
          type: integer
          description: ID of the project containing this folder
          example: 5
        purpose:
          type: string
          enum:
            - transactional
            - campaign
          description: >-
            Module the folder belongs to. A template can only be filed into a
            folder of its own module.
          example: campaign
        templates_count:
          type: integer
          minimum: 0
          description: Number of templates in this folder
          example: 12
        created_at:
          type: string
          format: date-time
          description: When the folder was created
          example: '2025-01-15T10:00:00+00:00'
        updated_at:
          type: string
          format: date-time
          description: When the folder was last updated
          example: '2025-01-20T14:30:00+00:00'
    FoldersPagination:
      type: object
      description: Pagination information for folders list
      required:
        - total
        - per_page
        - current_page
        - last_page
      properties:
        total:
          type: integer
          minimum: 0
          description: Total number of folders
          example: 2
        per_page:
          type: integer
          minimum: 1
          description: Number of folders per page
          example: 25
        current_page:
          type: integer
          minimum: 1
          description: Current page number
          example: 1
        last_page:
          type: integer
          minimum: 1
          description: Last page number
          example: 1
    ErrorCode:
      type: string
      description: >-
        Error codes returned by the API.


        | Code | HTTP Status | Description |

        |------|-------------|-------------|

        | `validation_error` | 422 | Request validation failed. Check the
        `errors` object for field-specific messages. |

        | `invalid_domain` | 400 | The sender domain could not be determined
        from the email address. |

        | `unconfigured_domain` | 400 | The sender domain is not configured or
        approved for sending. |

        | `send_error` | 400, 500 | General error during email send preparation
        or domain registration. |

        | `retrieval_error` | 400, 500 | Failed to retrieve resources (e.g.,
        sandbox key without associated user, upstream error). |

        | `internal_error` | 500 | An unexpected error on our side. The
        `message` names what failed; retry later. |

        | `transmission_failed` | 502 | Email transmission to the upstream
        provider failed. |

        | `resource_already_exists` | 409 | The resource (e.g., domain) already
        exists. |

        | `not_found` | 404 | The specified resource was not found. |

        | `template_not_found` | 404 | The specified template, project, or
        template version was not found. |

        | `insufficient_scope` | 403 | The API key does not have the required
        scope for this endpoint. |

        | `domain_not_allowed` | 403 | The sender domain is not in the API key's
        allowed sender domains. |

        | `schedule_cancellation_failed` | 409, 500 | The scheduled email can no
        longer be cancelled (already sent, already cancelled, or being injected
        right now), or the cancellation itself failed. |

        | `quota_exceeded` | 429 | Monthly sending quota exceeded. Upgrade your
        plan to continue sending. |

        | `daily_quota_exceeded` | 429 | Daily sending quota exceeded. Try again
        tomorrow. |

        | `campaign_not_sendable` | 422 | The campaign cannot be sent in its
        current state (not a draft, or missing subject/sender/content). |

        | `campaign_not_scheduled` | 422 | The campaign is not scheduled, so it
        cannot be unscheduled. |
      enum:
        - validation_error
        - idempotency_key_conflict
        - idempotency_in_progress
        - invalid_domain
        - unconfigured_domain
        - send_error
        - retrieval_error
        - internal_error
        - transmission_failed
        - resource_already_exists
        - not_found
        - template_not_found
        - insufficient_scope
        - domain_not_allowed
        - schedule_cancellation_failed
        - quota_exceeded
        - daily_quota_exceeded
        - campaign_not_sendable
        - campaign_not_scheduled
      example: invalid_domain
  responses:
    ServiceUnavailableError:
      description: >-
        Service unavailable - the API key could not be verified, so the request
        was not processed. This does not mean the key is invalid; retry after
        the delay given in the Retry-After header.
      headers:
        Retry-After:
          description: Seconds to wait before retrying.
          schema:
            type: integer
            example: 5
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            message: Unable to verify your API key right now. Please retry shortly.
            error_code: auth_unavailable
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key for authentication

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.