# List templates

- Operation ID: `list-templates`
- HTTP method: `GET`
- Path: `/template-backend/template`
- [Human-readable API reference](https://hub.synerise.com/api-reference/campaigns#tag/Templates/operation/list-templates)

## Self-contained OpenAPI method

The fenced document below contains this method's documentation and all of its local references. It is self-contained; no category or master specification fetch is required.

```yaml
openapi: 3.0.0
info:
  title: Synerise Public API
  version: 1.9.1
paths:
  /template-backend/template:
    get:
      summary: List templates
      operationId: list-templates
      tags:
        - Templates
      description: |
        Returns all templates from a Workspace, with an option to filter by type.

        ---

        **API consumer:** <a href="/api-reference/authorization?tag=Authorization&amp;operationId=userLogin" target="_blank" rel="noopener">Synerise User</a>

        **User role permission required:** `templates: read`
      parameters:
        - in: query
          name: type
          schema:
            type: string
            enum:
              - SMS
              - MOBILE_PUSH
              - WEB_PUSH
              - DYNAMIC_CONTENT
              - LANDING_PAGE
              - EMAIL
              - SOCIAL_MEDIA
              - IN_APP
          description: The type of templates to return
          required: false
        - in: query
          name: search
          schema:
            type: string
          description: Searched phrase
          required: false
        - in: query
          name: limit
          schema:
            type: number
          required: false
        - in: query
          name: offset
          schema:
            type: number
          required: false
        - in: query
          name: approved
          required: false
          schema:
            type: boolean
            default: false
          description: When approval-service enabled it filters for approved templates
      responses:
        "200":
          description: An array of templates
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  required:
                    - id
                    - hashId
                    - name
                    - businessProfileId
                    - type
                    - subtype
                    - contentType
                    - createdAt
                    - updatedAt
                    - directory
                    - thumbnailUrl
                    - author
                    - status
                    - source
                  properties:
                    id:
                      type: integer
                      format: int64
                      description: Template ID
                    hashId:
                      type: string
                      description: Template hashId (UUID)
                      example: e0326a2d-7697-4ae9-b490-31f97041adcb
                    name:
                      type: string
                      description: Name of the template
                      default: null
                      nullable: true
                    businessProfileId:
                      type: integer
                      description: Workspace ID
                      example: 594
                    type:
                      type: string
                      description: Template type
                      example: EMAIL
                      default: null
                      nullable: true
                      enum:
                        - SMS
                        - MOBILE_PUSH
                        - WEB_PUSH
                        - DYNAMIC_CONTENT
                        - LANDING_PAGE
                        - EMAIL
                        - SOCIAL_MEDIA
                        - IN_APP
                        - null
                    subtype:
                      type: string
                      description: |
                        Template subtype. Currently accepted subtypes are
                        - `BANNER` (can be used with mobile push)
                        - `TOP_BAR`, `BOTTOM_BAR`, `MODAL` (can be used with in app notifications)
                        - `null`.
                      example: BANNER
                      nullable: true
                      default: null
                      enum:
                        - BANNER
                        - TOP_BAR
                        - BOTTOM_BAR
                        - MODAL
                        - null
                    contentType:
                      type: string
                      enum:
                        - TEMPLATE
                        - BLOCK
                      example: TEMPLATE
                    createdAt:
                      type: string
                      description: Time of creation
                      format: date-time
                      example: 2019-03-21T12:31:26Z
                    updatedAt:
                      type: string
                      description: Time of last update
                      example: 2019-03-21T12:31:26Z
                    directory:
                      type: object
                      description: Details of the directory that includes this template
                      required:
                        - hashId
                        - name
                        - readOnly
                        - createdAt
                        - default
                        - type
                      properties:
                        hashId:
                          type: string
                          format: uuid
                          example: e0326a2d-7697-4ae9-b490-31f97041adcb
                          description: Directory hashId (UUID)
                        name:
                          type: string
                          description: Name of the directory
                        readOnly:
                          type: boolean
                          example: true
                          description: "`true` when the directory is read-only"
                        createdAt:
                          type: string
                          description: Time of creation
                          format: date-time
                          example: 2019-03-21T12:31:26Z
                        type:
                          nullable: true
                          type: string
                          description: Directory type
                          example: EMAIL
                        contentType:
                          type: string
                          enum:
                            - TEMPLATE
                            - BLOCK
                          example: TEMPLATE
                        default:
                          type: boolean
                          example: true
                          description: When `true`, this template belongs to one of the default folders
                        predefined:
                          type: boolean
                          example: true
                    thumbnailUrl:
                      type: string
                      description: URL of the template's thumbnail
                      example: https://foo.bar
                    author:
                      type: integer
                      format: int64
                      description: Author ID
                      example: 123
                    status:
                      type: string
                      description: Approval status of the template. If approvals are disabled, the status is null.
                      nullable: true
                      enum:
                        - DRAFT
                        - REVIEW
                        - APPROVED
                        - REJECTED
                    source:
                      type: integer
                      format: int64
                      description: |
                        Information about used editor. Currently accepted builder are
                        - `LACK_OF_INFORMATION` = 0
                        - `BEE_FREE_EDITOR` = 1
                        - `DYNAMIC_CONTENT_CODE_EDITOR` = 2
                        - `MAIL_EDITOR` = 3
                        - `SMS_EDITOR` = 4
                        - `WEB_PUSH_EDITOR` = 5
                        - `MOBILE_SIMPLE_PUSH_VISUAL_EDITOR` = 6
                        - `MOBILE_SILENT_PUSH_CODE_EDITOR` = 7
                        - `FACEBOOK_POST_EDITOR` = 13
                        - `IMPORT_FROM_ZIP` = 14
                        - `IMPORT_FROM_URL` = 15
                        - `GRAPES_EDITOR` = 16
                        - `VISUAL_BUILDER` = 17
                        - `LANDING_PAGE_ADVANCED_DRAG_AND_DROP` = 18
                        - `WEB_BEE_FREE_EDITOR` = 19
                        - `MOBILE_SIMPLE_PUSH_CODE_EDITOR` = 20
                        - `LANDING_PAGE_CODE_EDITOR` = 21
                        - `LANDING_PAGE_BASIC_DRAG_AND_DROP` = 22
      security:
        - JWT: []
      x-snr-doc-urls:
        - /api-reference/campaigns#tag/Templates/operation/list-templates
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: |-
            curl --request GET \
              --url 'https://api.synerise.com/template-backend/template?type=SOME_STRING_VALUE&search=SOME_STRING_VALUE&limit=SOME_NUMBER_VALUE&offset=SOME_NUMBER_VALUE&approved=SOME_BOOLEAN_VALUE' \
              --header 'Authorization: Bearer REPLACE_BEARER_TOKEN'
        - lang: Python
          label: Python
          source: |-
            import http.client

            conn = http.client.HTTPSConnection("api.synerise.com")

            headers = { 'Authorization': "Bearer REPLACE_BEARER_TOKEN" }

            conn.request("GET", "/template-backend/template?type=SOME_STRING_VALUE&search=SOME_STRING_VALUE&limit=SOME_NUMBER_VALUE&offset=SOME_NUMBER_VALUE&approved=SOME_BOOLEAN_VALUE", headers=headers)

            res = conn.getresponse()
            data = res.read()

            print(data.decode("utf-8"))
        - lang: JavaScript
          label: JavaScript
          source: |-
            const data = null;

            const xhr = new XMLHttpRequest();
            xhr.withCredentials = true;

            xhr.addEventListener("readystatechange", function () {
              if (this.readyState === this.DONE) {
                console.log(this.responseText);
              }
            });

            xhr.open("GET", "https://api.synerise.com/template-backend/template?type=SOME_STRING_VALUE&search=SOME_STRING_VALUE&limit=SOME_NUMBER_VALUE&offset=SOME_NUMBER_VALUE&approved=SOME_BOOLEAN_VALUE");
            xhr.setRequestHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN");

            xhr.send(data);
        - lang: Node.js
          label: Node.js
          source: |-
            const http = require("https");

            const options = {
              "method": "GET",
              "hostname": "api.synerise.com",
              "port": null,
              "path": "/template-backend/template?type=SOME_STRING_VALUE&search=SOME_STRING_VALUE&limit=SOME_NUMBER_VALUE&offset=SOME_NUMBER_VALUE&approved=SOME_BOOLEAN_VALUE",
              "headers": {
                "Authorization": "Bearer REPLACE_BEARER_TOKEN"
              }
            };

            const req = http.request(options, function (res) {
              const chunks = [];

              res.on("data", function (chunk) {
                chunks.push(chunk);
              });

              res.on("end", function () {
                const body = Buffer.concat(chunks);
                console.log(body.toString());
              });
            });

            req.end();
        - lang: PHP
          label: PHP
          source: |-
            <?php

            $request = new HttpRequest();
            $request->setUrl('https://api.synerise.com/template-backend/template');
            $request->setMethod(HTTP_METH_GET);

            $request->setQueryData([
              'type' => 'SOME_STRING_VALUE',
              'search' => 'SOME_STRING_VALUE',
              'limit' => 'SOME_NUMBER_VALUE',
              'offset' => 'SOME_NUMBER_VALUE',
              'approved' => 'SOME_BOOLEAN_VALUE'
            ]);

            $request->setHeaders([
              'Authorization' => 'Bearer REPLACE_BEARER_TOKEN'
            ]);

            try {
              $response = $request->send();

              echo $response->getBody();
            } catch (HttpException $ex) {
              echo $ex;
            }
        - lang: Java
          label: Java
          source: |-
            HttpResponse<String> response = Unirest.get("https://api.synerise.com/template-backend/template?type=SOME_STRING_VALUE&search=SOME_STRING_VALUE&limit=SOME_NUMBER_VALUE&offset=SOME_NUMBER_VALUE&approved=SOME_BOOLEAN_VALUE")
              .header("Authorization", "Bearer REPLACE_BEARER_TOKEN")
              .asString();
servers:
  - description: Microsoft Azure EU
    url: https://api.synerise.com
  - description: Microsoft Azure USA
    url: https://api.azu.synerise.com
  - description: Google Cloud Platform
    url: https://api.geb.synerise.com
tags:
  - name: Templates
components:
  securitySchemes:
    JWT:
      type: http
      scheme: bearer
      description: |-
        JWT Bearer token. The header looks like this: `Bearer {JWT}`

        Remember to include the space between 'Bearer' and the token.

        Generate a token via the **Authorization** endpoints.
```
