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

# Liệt kê template

> Trả về template của workspace kèm đúng bộ tham số Zalo yêu cầu. Gọi endpoint này TRƯỚC khi viết code gửi — đừng đoán tên tham số.

Scope: `templates:read`



## OpenAPI

````yaml https://business.adflex.vn/openapi.json get /api/v1/templates
openapi: 3.1.0
info:
  title: AdFlex ZNS API
  version: 1.0.0
  description: >-
    API gửi tin Zalo ZNS của AdFlex.


    API vận hành ở chế độ production, không có môi trường sandbox. Mỗi request
    thành công tạo một tin thật và trừ phí theo giá template.
  contact:
    name: AdFlex for Business
    url: https://business.adflex.vn
servers:
  - url: https://business.adflex.vn
    description: Production
security:
  - bearerAuth: []
  - apiKeyAuth: []
tags:
  - name: Template
    description: Khám phá template và OA khả dụng
  - name: Gửi tin
    description: Gửi một tin, gửi lô, gửi mã hoá đầu-cuối
  - name: Tra cứu
    description: Trạng thái tin và huỷ tin chưa gửi
paths:
  /api/v1/templates:
    get:
      tags:
        - Template
      summary: Liệt kê template
      description: >-
        Trả về template của workspace kèm đúng bộ tham số Zalo yêu cầu. Gọi
        endpoint này TRƯỚC khi viết code gửi — đừng đoán tên tham số.


        Scope: `templates:read`
      operationId: listTemplates
      parameters:
        - name: status
          in: query
          required: false
          schema:
            type: string
            enum:
              - ENABLE
              - PENDING_REVIEW
              - REJECT
              - DISABLE
              - DELETE
          description: Lọc theo trạng thái duyệt. Chỉ ENABLE mới gửi được.
        - name: oa_id
          in: query
          required: false
          schema:
            type: string
          description: Lọc theo một OA cụ thể
      responses:
        '200':
          description: Danh sách template
          content:
            application/json:
              schema:
                type: object
                properties:
                  templates:
                    type: array
                    items:
                      $ref: '#/components/schemas/Template'
                  count:
                    type: integer
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  schemas:
    Template:
      type: object
      properties:
        template_id:
          type: string
          example: '123456'
          description: Dùng giá trị này cho trường template_id khi gửi
        name:
          type: string
          example: Mã xác thực OTP
        status:
          type: string
          enum:
            - ENABLE
            - PENDING_REVIEW
            - REJECT
            - DISABLE
            - DELETE
          description: Chỉ ENABLE mới gửi được
        template_type:
          type:
            - integer
            - 'null'
        oa_id:
          type: string
          example: '1234567890123456789'
        oa_name:
          type: string
          example: AdFlex
        preview_url:
          type:
            - string
            - 'null'
        params:
          type: array
          items:
            $ref: '#/components/schemas/TemplateParam'
    TemplateParam:
      type: object
      description: Một tham số của template. Phải điền đủ mọi tham số required.
      properties:
        name:
          type: string
          example: otp
        type:
          type: string
          example: STRING
        required:
          type: boolean
          example: true
        max_length:
          type: integer
          example: 10
        min_length:
          type: integer
          example: 0
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: integer
              example: 401
            message:
              type: string
              example: API key không hợp lệ hoặc đã bị thu hồi
  responses:
    BadRequest:
      description: Body sai hoặc thiếu trường bắt buộc
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Thiếu API key, key sai hoặc đã bị thu hồi
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: Key thiếu scope, hoặc workspace đang tạm dừng
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Authorization: Bearer ak_live_…'
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: Cách thay thế cho Bearer. Dùng một trong hai là đủ.

````