# Cancel Document

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /Documents/{documentNumber}/cancel:
    post:
      summary: Cancel Document
      deprecated: false
      description: >
        ยกเลิกเอกสารอิเล็กทรอนิกส์ สำหรับเอกสารที่ยังไม่ได้ถูกนำส่ง กรมสรรพากร
        (RD)
      operationId: CancelDocument
      tags:
        - eTaxGo/Document Management
        - Documents
      parameters:
        - name: documentNumber
          in: path
          description: เลขที่เอกสาร
          required: true
          example: ''
          schema:
            type: string
            examples:
              - T2024001234
        - name: Ocp-Apim-Subscription-Key
          in: header
          description: รหัส subscription key ของลูกค้า
          required: true
          example: a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6
          schema:
            type: string
        - name: Content-Type
          in: header
          description: ''
          required: true
          example: application/json
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelDocumentRequest'
            example:
              documentType: '388'
              reason: ลูกค้าขอยกเลิก
      responses:
        '200':
          description: ยกเลิกสำเร็จ — `status.isSuccess` = true
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: object
                    properties:
                      isSuccess:
                        type: boolean
                        examples:
                          - true
                    x-apidog-orders:
                      - isSuccess
                    x-apidog-ignore-properties: []
                  data:
                    type: object
                    properties:
                      documentNumber:
                        type: string
                        description: เลขที่เอกสาร
                        examples:
                          - T2024001234
                      rdSubmissionStatus:
                        type: string
                        description: สถานะการอนุมัติของกรมสรรพากร (RD)
                        examples:
                          - CANCELLED
                      cancelledAt:
                        type: string
                        description: วันเวลาที่ยกเลิก (GMT+7, ไม่มี timezone suffix)
                        examples:
                          - '2024-01-15T11:00:00'
                        nullable: true
                    x-apidog-orders:
                      - documentNumber
                      - rdSubmissionStatus
                      - cancelledAt
                    x-apidog-ignore-properties: []
                x-apidog-orders:
                  - status
                  - data
                x-apidog-ignore-properties: []
              example:
                status:
                  isSuccess: true
                data:
                  documentNumber: T2024001234
                  rdSubmissionStatus: CANCELLED
                  cancelledAt: '2024-01-15T11:00:00'
          headers: {}
          x-apidog-name: ''
        '400':
          description: >
            ล้มเหลว — `status.isSuccess` ไม่ถูก return (default false)

            ตัวอย่าง error description:

            - `"Document not found"`

            - `"Document 'RCT202605270040' cannot be cancelled in status
            'CANCELLED'."`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
              example:
                status:
                  code: '4001'
                  description: Business error with more than 1 errors
                data:
                  errors:
                    - subCode: E1102
                      description: >-
                        Document 'RCT202605270040' cannot be cancelled in status
                        'CANCELLED'.
          headers: {}
          x-apidog-name: ''
        '401':
          description: Unauthorized
          headers: {}
          x-apidog-name: ''
      security:
        - bearer: []
      x-apidog-folder: eTaxGo/Document Management
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/351895/apis/api-36769214-run
components:
  schemas:
    CancelDocumentRequest:
      type: object
      required:
        - documentType
      properties:
        documentType:
          type: string
          description: |
            รหัสประเภทเอกสาร:
            380=Invoice, 388=Tax Invoice, 80=Debit Note, 81=Credit Note,
            T01=Receipt, T02=Invoice/Tax Invoice, T03=Receipt/Tax Invoice,
            T04=Delivery Order/Tax Invoice, T05=Abbreviated Tax Invoice,
            T06=Receipt/Abbreviated Tax Invoice, T07=Cancellation Note
          enum:
            - '380'
            - '388'
            - '80'
            - '81'
            - T01
            - T02
            - T03
            - T04
            - T05
            - T06
            - T07
          examples:
            - '388'
        reason:
          type: string
          description: เหตุผลการยกเลิก (ไม่บังคับ)
          examples:
            - ลูกค้าขอยกเลิก
          nullable: true
      x-apidog-orders:
        - documentType
        - reason
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
    ErrorEnvelope:
      type: object
      description: |
        HTTP 400 — business error
        `isSuccess` ไม่ถูก serialize (default false ถูก omit)
      properties:
        status:
          type: object
          properties:
            code:
              type: string
              description: '"4001" = 1 error, "4002" = หลาย errors'
              examples:
                - '4001'
            description:
              type: string
              examples:
                - Business error with more than 1 errors
          x-apidog-orders:
            - code
            - description
          x-apidog-ignore-properties: []
        data:
          type: object
          properties:
            errors:
              type: array
              items:
                type: object
                properties:
                  subCode:
                    type: string
                    description: >-
                      "E1102" = business error, "EXT9999" = internal server
                      error
                    examples:
                      - E1102
                  description:
                    type: string
                    description: ข้อความ error (free-text)
                    examples:
                      - Document not found
                x-apidog-orders:
                  - subCode
                  - description
                x-apidog-ignore-properties: []
          x-apidog-orders:
            - errors
          x-apidog-ignore-properties: []
      x-apidog-orders:
        - status
        - data
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
  securitySchemes:
    bearerAuth:
      type: jwt
      scheme: bearer
      bearerFormat: JWT
      description: ใส่ JWT Token ในรูปแบบ Bearer {token}
    bearer:
      type: http
      scheme: bearer
servers:
  - url: https://api.gofive.co.th
    description: Production
security:
  - bearerAuth: []
    x-apidog:
      schemeGroups:
        - id: uyL_cJmK7q60QJZRTi5ot
          schemeIds:
            - bearerAuth
      required: true
      use:
        id: uyL_cJmK7q60QJZRTi5ot
      scopes:
        uyL_cJmK7q60QJZRTi5ot:
          bearerAuth: []

```
