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

# Huỷ tin chưa gửi

> Chỉ huỷ được tin còn ở trạng thái `queued` — thường là tin đã đặt lịch.

**Huỷ thành công thì bản ghi bị xoá hẳn**, tra lại msg_id đó sẽ ra 404.

Scope: `messages:send`



## OpenAPI

````yaml https://business.adflex.vn/openapi.json post /api/v1/messages/{id}/cancel
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/messages/{id}/cancel:
    post:
      tags:
        - Tra cứu
      summary: Huỷ tin chưa gửi
      description: |-
        Chỉ huỷ được tin còn ở trạng thái `queued` — thường là tin đã đặt lịch.

        **Huỷ thành công thì bản ghi bị xoá hẳn**, tra lại msg_id đó sẽ ra 404.

        Scope: `messages:send`
      operationId: cancelMessage
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Đã huỷ
          content:
            application/json:
              schema:
                type: object
                properties:
                  cancelled:
                    type: boolean
                  msg_id:
                    type: string
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: Tin không còn ở trạng thái queued, hoặc đang được gửi
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  responses:
    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'
    NotFound:
      description: Không tìm thấy tài nguyên trong workspace của key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    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
  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à đủ.

````