# Get template by ID

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

## 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/getById/{id}:
    get:
      summary: Get template by ID
      operationId: get-id-template
      description: |
        Retrieve a template identified by ID.

        ---

        **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`
      tags:
        - Templates
      parameters:
        - in: path
          name: id
          schema:
            type: integer
            format: int64
            example: 12
          description: Template ID
          required: true
      responses:
        "200":
          description: Template details
          content:
            application/json:
              schema:
                type: object
                required:
                  - id
                  - hashId
                  - businessProfileId
                  - name
                  - templateContent
                  - type
                  - subtype
                  - thumbnailUrl
                  - directory
                  - createdAt
                  - updatedAt
                  - parsedData
                  - parsedContent
                  - functionType
                  - 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
                  businessProfileId:
                    type: integer
                    description: Workspace ID
                    example: 594
                  name:
                    type: string
                    description: Name of the template
                    default: null
                    nullable: true
                  templateContent:
                    type: string
                    description: |
                      Template content as a **stringified, escaped object**.

                      This includes HTML, JS, CSS, and other data, depending on the template type.
                    example: '{"json":"","html":"<p>some text</p>","css":"p {\n    font-weight: bold\n}","js":"console.log(\"test\")","raw":"<html><head><style type=\"text/css\">p {\n    font-weight: bold\n}</style></head><body><p>some text</p></body></html>","source":2}'
                  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
                  thumbnailUrl:
                    type: string
                    description: URL of the template's thumbnail
                    example: https://foo.bar
                  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
                  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
                  parsedData:
                    type: object
                    properties:
                      links:
                        type: object
                  parsedContent:
                    type: string
                  functionType:
                    type: string
                    description: Function type
                    example: Password Change
                  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
                  includeSafeArea:
                    type: boolean
                    description: Define if in_app template should include safe area
                    default: false
                    nullable: true
      security:
        - JWT: []
      x-snr-doc-urls:
        - /api-reference/campaigns#tag/Templates/operation/get-id-template
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: |-
            curl --request GET \
              --url https://api.synerise.com/template-backend/template/getById/12 \
              --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/getById/12", 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/getById/12");
            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/getById/12",
              "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/getById/12');
            $request->setMethod(HTTP_METH_GET);

            $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/getById/12")
              .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.
```
