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

# Cancel an appointment

> Needs only Cancel:Appointment, unlike `PUT /appointments/{id}` which needs Update:Appointment as
well. Cancelling an already cancelled appointment is 409 `APPOINTMENT_ALREADY_CANCELLED`.



## OpenAPI

````yaml /api-referansi/openapi.json post /v1/appointments/{id}/cancel
openapi: 3.1.0
info:
  title: Flextell API
  version: 0.0.1
  description: >-
    Flextell REST API referansı. Kimlik doğrulama, scope ve istek kuralları için
    API sekmesindeki rehberlere bakın.
servers:
  - url: https://app.flextell.ai/api
    description: Üretim
security:
  - oauth2: []
  - bearer: []
paths:
  /v1/appointments/{id}/cancel:
    post:
      tags:
        - Appointment
      summary: Cancel an appointment
      description: >-
        Needs only Cancel:Appointment, unlike `PUT /appointments/{id}` which
        needs Update:Appointment as

        well. Cancelling an already cancelled appointment is 409
        `APPOINTMENT_ALREADY_CANCELLED`.
      operationId: appointment.cancel
      parameters:
        - name: id
          in: path
          required: true
          description: The appointment identifier
          schema:
            type: integer
        - name: X-Tenant
          in: header
          required: true
          description: >-
            Tenant identifier. Send the Tenant ID in the `X-Tenant` header to
            scope API requests to a specific tenant.
          schema:
            type: number
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AppointmentCancelRequest'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: string
                  data:
                    $ref: '#/components/schemas/AppointmentResource'
                required:
                  - success
                  - data
        '401':
          $ref: '#/components/responses/AuthenticationException'
        '403':
          $ref: '#/components/responses/AuthorizationException'
        '404':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  error_code:
                    type: string
                    const: RESOURCE_NOT_FOUND
                  message:
                    type: string
                  errors:
                    type: 'null'
                  data:
                    type: 'null'
                required:
                  - success
                  - error_code
                  - message
                  - errors
                  - data
        '409':
          $ref: '#/components/responses/CustomerErasedException'
        '422':
          $ref: '#/components/responses/ValidationException'
        '428':
          description: >-
            Mandatory setup is incomplete. Finish the setup wizard first;
            `data.next_step` names the step to continue with.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    examples:
                      - false
                  error_code:
                    type: string
                    enum:
                      - SETUP_REQUIRED
                    examples:
                      - SETUP_REQUIRED
                  message:
                    type: string
                    examples:
                      - Complete the required setup steps to continue.
                  data:
                    type: object
                    properties:
                      next_step:
                        type:
                          - string
                          - 'null'
                        examples:
                          - clinic_info
                    required:
                      - next_step
                required:
                  - success
                  - error_code
                  - message
                  - data
components:
  schemas:
    AppointmentCancelRequest:
      type: object
      properties:
        cancellation_reason:
          type:
            - string
            - 'null'
          description: Why the appointment is cancelled.
          maxLength: 1000
      title: AppointmentCancelRequest
    AppointmentResource:
      type: object
      properties:
        id:
          type: integer
        record_state:
          $ref: '#/components/schemas/RecordStateResource'
        customer_id:
          type:
            - integer
            - 'null'
        room_id:
          type:
            - integer
            - 'null'
        channel_id:
          type:
            - integer
            - 'null'
        parent_appointment_id:
          type:
            - integer
            - 'null'
        code:
          type: string
        relation_type:
          type: string
        description:
          type:
            - string
            - 'null'
        scheduled_at:
          type: string
          format: date-time
        duration_minutes:
          type:
            - integer
            - 'null'
        status:
          type: string
        cancellation_reason:
          type:
            - string
            - 'null'
        creation_type:
          type: string
        is_control_appointment:
          type: boolean
        is_ai_generated:
          type: boolean
          description: >-
            Whether the AI assistant booked the appointment; `creation_type`
            carries the same fact as a label.
        import_source_id:
          type:
            - integer
            - 'null'
          description: >-
            The external system the appointment was imported from, or `null`
            when it was created in Flextell.
        pending_scheduled_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            The time a bulk reschedule proposed to the patient, while it awaits
            their confirmation; otherwise `null`.
        pending_expires_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            When the proposed time stops being held for the patient; `null`
            without a pending proposal.
        sale_id:
          type: integer
          description: The appointment's sale, or `null` when it has none.
        has_sale:
          type: boolean
          description: Whether the appointment has a sale; same as `sale_id !== null`.
        customer:
          $ref: '#/components/schemas/CustomerResource'
        doctor:
          $ref: '#/components/schemas/RelatedUserResource'
        room:
          $ref: '#/components/schemas/RoomResource'
        parent_appointment:
          $ref: '#/components/schemas/AppointmentResource'
        child_appointments:
          type: array
          items:
            $ref: '#/components/schemas/AppointmentResource'
        treatments:
          type: array
          items:
            $ref: '#/components/schemas/TreatmentResource'
        treatment_session_plans:
          type: array
          items:
            $ref: '#/components/schemas/AppointmentTreatmentPlanResource'
        linked_sessions:
          type: array
          description: >-
            The treatment sessions this appointment fulfils with the products
            used on each, in session order. Only present on detail responses.
          items:
            $ref: '#/components/schemas/AppointmentLinkedSessionResource'
        assistants:
          anyOf:
            - type: array
              items:
                $ref: '#/components/schemas/RelatedUserResource'
            - type: array
              items:
                type: string
              minItems: 0
              maxItems: 0
              additionalItems: false
        tags:
          type: array
          items:
            $ref: '#/components/schemas/TagResource'
        reminders:
          type: array
          items:
            $ref: '#/components/schemas/AppointmentReminderResource'
        customer_balance:
          anyOf:
            - $ref: '#/components/schemas/AppointmentCustomerBalanceResource'
              description: >-
                The patient's balance, or `null` when their details are masked
                for the viewer. Only present on GET /appointments/{id}.
            - type: 'null'
        import_source:
          anyOf:
            - $ref: '#/components/schemas/RelatedImportSourceResource'
              description: >-
                The external system the record was imported from, or `null` when
                it was created in Flextell. Only present on detail responses.
            - type: 'null'
        created_at:
          type:
            - string
            - 'null'
          format: date-time
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - record_state
        - customer_id
        - room_id
        - channel_id
        - parent_appointment_id
        - code
        - relation_type
        - description
        - scheduled_at
        - duration_minutes
        - status
        - cancellation_reason
        - creation_type
        - is_control_appointment
        - is_ai_generated
        - import_source_id
        - pending_scheduled_at
        - pending_expires_at
        - assistants
        - created_at
        - updated_at
        - deleted_at
      title: AppointmentResource
    RecordStateResource:
      type: object
      properties:
        is_read_only:
          type: boolean
          description: >-
            True when every write on this record is refused; false does not
            imply the caller may write.
        reason_code:
          type:
            - string
            - 'null'
          description: >-
            Why the record is read-only (`CUSTOMER_ERASED`, or
            `LEAD_NOT_ASSIGNED` for a salesperson on another rep's lead), or
            null when it is not.
      required:
        - is_read_only
        - reason_code
      title: RecordStateResource
    CustomerResource:
      type: object
      properties:
        id:
          type: integer
        record_state:
          $ref: '#/components/schemas/RecordStateResource'
        first_name:
          anyOf:
            - type: string
            - type: 'null'
        last_name:
          anyOf:
            - type: string
            - type: 'null'
        phone_number:
          anyOf:
            - type: string
            - type: 'null'
        email:
          anyOf:
            - type: string
            - type: 'null'
        date_of_birth:
          type:
            - string
            - 'null'
        gender:
          anyOf:
            - $ref: '#/components/schemas/Gender'
            - type: 'null'
        country_id:
          type:
            - integer
            - 'null'
        country_name:
          type: string
        city_id:
          type:
            - integer
            - 'null'
        city_name:
          type: string
        district_id:
          type:
            - integer
            - 'null'
        district_name:
          type: string
        identity_number:
          anyOf:
            - type: string
            - type: 'null'
        passport_number:
          anyOf:
            - type: string
            - type: 'null'
        occupation_id:
          type:
            - integer
            - 'null'
        occupation_name:
          type: string
        address:
          anyOf:
            - type: string
            - type: 'null'
        default_channel_id:
          type:
            - integer
            - 'null'
        default_channel_name:
          type: string
        latest_conversation_id:
          type:
            - integer
            - 'null'
        avatar_url:
          type:
            - string
            - 'null'
        is_lead_stage:
          type: boolean
        lead_id:
          type:
            - integer
            - 'null'
        is_masked:
          type: boolean
          description: >-
            Whether the identity fields are masked because the viewer may not
            see this lead's patient.
        related_user:
          $ref: '#/components/schemas/RelatedUserResource'
        tags:
          type: array
          items:
            $ref: '#/components/schemas/TagResource'
        notification_channels:
          $ref: '#/components/schemas/CustomerNotificationChannelsResource'
        import_source:
          anyOf:
            - $ref: '#/components/schemas/RelatedImportSourceResource'
              description: >-
                The external system the record was imported from, or `null` when
                it was created in Flextell. Only present on detail responses.
            - type: 'null'
        created_at:
          type:
            - string
            - 'null'
          format: date-time
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          format: date-time
        erased_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - record_state
        - first_name
        - last_name
        - phone_number
        - email
        - date_of_birth
        - gender
        - country_id
        - country_name
        - city_id
        - city_name
        - district_id
        - district_name
        - identity_number
        - passport_number
        - occupation_id
        - occupation_name
        - address
        - default_channel_id
        - default_channel_name
        - latest_conversation_id
        - avatar_url
        - is_lead_stage
        - lead_id
        - is_masked
        - related_user
        - created_at
        - updated_at
        - deleted_at
        - erased_at
      title: CustomerResource
    RelatedUserResource:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        avatar_url:
          type:
            - string
            - 'null'
          description: >-
            A signed profile photo URL valid for a few hours, or `null` without
            a photo. Only on responses that opt in.
      required:
        - id
        - name
      title: RelatedUserResource
    RoomResource:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        status:
          type: string
        created_at:
          type:
            - string
            - 'null'
          format: date-time
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - name
        - status
        - created_at
        - updated_at
        - deleted_at
      title: RoomResource
    TreatmentResource:
      type: object
      properties:
        id:
          type: integer
        group_id:
          type:
            - integer
            - 'null'
        name:
          type: string
        invoice_name:
          type:
            - string
            - 'null'
        keywords:
          type: array
          items: {}
        price:
          type: string
        tax_rate:
          type: integer
        description:
          type:
            - string
            - 'null'
        session:
          type: integer
        is_active:
          type: string
        extra_info:
          type: object
        group:
          type:
            - object
            - 'null'
          properties:
            id:
              type: integer
            name:
              type: string
            is_active:
              type: boolean
          required:
            - id
            - name
            - is_active
        users:
          type: array
          items:
            $ref: '#/components/schemas/RelatedUserResource'
        sessions:
          type: array
          items:
            $ref: '#/components/schemas/TreatmentSessionResource'
        import_source:
          anyOf:
            - $ref: '#/components/schemas/RelatedImportSourceResource'
              description: >-
                The external system the record was imported from, or `null` when
                it was created in Flextell. Only present on detail responses.
            - type: 'null'
        created_at:
          type:
            - string
            - 'null'
          format: date-time
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - group_id
        - name
        - invoice_name
        - keywords
        - price
        - tax_rate
        - description
        - session
        - is_active
        - extra_info
        - created_at
        - updated_at
        - deleted_at
      title: TreatmentResource
    AppointmentTreatmentPlanResource:
      type: object
      properties:
        treatment_id:
          type: integer
        sessions:
          type: array
          items:
            $ref: '#/components/schemas/AppointmentTreatmentSessionResource'
      required:
        - treatment_id
      title: AppointmentTreatmentPlanResource
    AppointmentLinkedSessionResource:
      type: object
      properties:
        id:
          type: integer
        session_order:
          type: integer
        session_type:
          type:
            - string
            - 'null'
        treatment:
          type:
            - object
            - 'null'
          properties:
            id:
              type: integer
            name:
              type: string
            display_name:
              type: string
          required:
            - id
            - name
            - display_name
        products:
          type: array
          description: >-
            The products recorded as used on the session; the completion
            endpoint's prefill.
          items:
            $ref: '#/components/schemas/SessionProductResource'
      required:
        - id
        - session_order
        - session_type
        - treatment
      title: AppointmentLinkedSessionResource
    TagResource:
      type: object
      properties:
        id:
          type: integer
        tenant_id:
          type: integer
        name:
          type: string
        color:
          type: string
        created_at:
          type:
            - string
            - 'null'
          format: date-time
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - tenant_id
        - name
        - color
        - created_at
        - updated_at
        - deleted_at
      title: TagResource
    AppointmentReminderResource:
      type: object
      properties:
        id:
          type: integer
        record_state:
          $ref: '#/components/schemas/RecordStateResource'
        appointment_id:
          type: integer
        tenant_id:
          type: integer
        type:
          type: string
        offset_days:
          type: integer
        scheduled_for:
          type: string
          format: date-time
        sent_at:
          type:
            - string
            - 'null'
          format: date-time
        channel:
          type: string
        message:
          type: string
        status:
          type: string
        approval_status:
          type: string
        approved_at:
          type:
            - string
            - 'null'
          format: date-time
        approved_by:
          type:
            - integer
            - 'null'
        metadata:
          type:
            - array
            - 'null'
          items: {}
        appointment:
          $ref: '#/components/schemas/RelatedAppointmentResource'
        approver:
          anyOf:
            - $ref: '#/components/schemas/RelatedUserResource'
            - type: 'null'
        created_at:
          type:
            - string
            - 'null'
          format: date-time
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - record_state
        - appointment_id
        - tenant_id
        - type
        - offset_days
        - scheduled_for
        - sent_at
        - channel
        - message
        - status
        - approval_status
        - approved_at
        - approved_by
        - metadata
        - created_at
        - updated_at
      title: AppointmentReminderResource
    AppointmentCustomerBalanceResource:
      type: object
      properties:
        outstanding_balance:
          type: string
          description: >-
            Everything the patient owes in the clinic currency; negative is a
            credit in their favour.
        overdue_balance:
          type: string
          description: >-
            The part of the sale debt already due: cash sales and instalments
            past their due date, net of collections.
        currency_code:
          type: string
          description: The clinic currency both amounts are in.
      required:
        - outstanding_balance
        - overdue_balance
        - currency_code
      title: AppointmentCustomerBalanceResource
    RelatedImportSourceResource:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        company_logo:
          type: 'null'
      required:
        - id
        - name
        - company_logo
      title: RelatedImportSourceResource
    Gender:
      type: string
      enum:
        - male
        - female
        - other
      title: Gender
    CustomerNotificationChannelsResource:
      type: object
      properties:
        default_channel_id:
          type:
            - string
            - 'null'
        source:
          type:
            - string
            - 'null'
        channels:
          type: array
          items: {}
      required:
        - default_channel_id
        - source
        - channels
      title: CustomerNotificationChannelsResource
    TreatmentSessionResource:
      type: object
      properties:
        id:
          type: integer
        session_order:
          type: integer
        session_type:
          $ref: '#/components/schemas/AppointmentType'
        next_gap_days:
          type:
            - integer
            - 'null'
        offset_days:
          type: integer
        products:
          type: array
          items:
            $ref: '#/components/schemas/TreatmentSessionProductResource'
      required:
        - id
        - session_order
        - session_type
        - next_gap_days
        - offset_days
      title: TreatmentSessionResource
    AppointmentTreatmentSessionResource:
      type: object
      properties:
        id:
          type: integer
        record_state:
          $ref: '#/components/schemas/RecordStateResource'
        appointment_id:
          type:
            - integer
            - 'null'
        session_order:
          type: integer
        is_custom:
          type: boolean
        session_type:
          type:
            - string
            - 'null'
        offset_days:
          type: integer
        next_gap_days:
          type:
            - integer
            - 'null'
        scheduled_at:
          type:
            - string
            - 'null'
          format: date-time
        products:
          type: array
          items:
            $ref: '#/components/schemas/SessionProductResource'
      required:
        - id
        - record_state
        - appointment_id
        - session_order
        - is_custom
        - session_type
        - offset_days
        - next_gap_days
        - scheduled_at
      title: AppointmentTreatmentSessionResource
    SessionProductResource:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        full_name:
          type: string
          description: The brand-prefixed product name, e.g. `Allergan Harmonyca`.
        quantity:
          type: number
        unit_code:
          type:
            - object
            - 'null'
          properties:
            id:
              type: string
            name:
              type: string
            code:
              type: string
          required:
            - id
            - name
            - code
      required:
        - id
        - quantity
      title: SessionProductResource
    RelatedAppointmentResource:
      type: object
      properties:
        id:
          type: integer
        record_state:
          $ref: '#/components/schemas/RecordStateResource'
        code:
          type: string
        scheduled_at:
          type: string
          format: date-time
        status:
          type: string
        relation_type:
          type: string
        parent_appointment_id:
          type:
            - integer
            - 'null'
        customer:
          anyOf:
            - $ref: '#/components/schemas/RelatedCustomerResource'
            - type: 'null'
        doctor:
          anyOf:
            - $ref: '#/components/schemas/RelatedUserResource'
            - type: 'null'
        treatments:
          type: array
          items:
            $ref: '#/components/schemas/RelatedTreatmentResource'
        parent_appointment:
          anyOf:
            - $ref: '#/components/schemas/RelatedAppointmentResource'
            - type: 'null'
      required:
        - id
        - record_state
        - code
        - scheduled_at
        - status
        - relation_type
        - parent_appointment_id
      title: RelatedAppointmentResource
    AppointmentType:
      type: string
      enum:
        - control
        - operation
        - treatment
        - consultation
        - follow_up
        - emergency
        - surgery
      title: AppointmentType
    TreatmentSessionProductResource:
      type: object
      properties:
        id:
          type: integer
        product_id:
          type: integer
        min_quantity:
          type:
            - number
            - 'null'
        product:
          type: object
          properties:
            id:
              type: integer
            name:
              type: string
            full_name:
              type: string
            brand:
              type:
                - object
                - 'null'
              properties:
                id:
                  type: integer
                name:
                  type: string
              required:
                - id
                - name
            unit_code:
              type:
                - object
                - 'null'
              properties:
                id:
                  type: string
                name:
                  type: string
                code:
                  type: string
              required:
                - id
                - name
                - code
          required:
            - id
            - name
            - full_name
            - brand
            - unit_code
      required:
        - id
        - product_id
        - min_quantity
      title: TreatmentSessionProductResource
    RelatedCustomerResource:
      type: object
      properties:
        id:
          type: integer
        record_state:
          $ref: '#/components/schemas/RecordStateResource'
        first_name:
          anyOf:
            - type: string
            - type: 'null'
        last_name:
          anyOf:
            - type: string
            - type: 'null'
        phone_number:
          anyOf:
            - type: string
            - type: 'null'
        email:
          anyOf:
            - type: string
            - type: 'null'
        is_masked:
          type: boolean
          description: >-
            Whether the identity fields are masked because the viewer may not
            see this lead's patient.
        is_lead_stage:
          type: boolean
          description: >-
            Whether the person is still a lead (link to `/leads/{lead_id}`)
            rather than a patient (link to `/customers/{id}`).
        lead_id:
          type:
            - integer
            - 'null'
          description: >-
            The lead the person came from; kept after conversion, so check
            `is_lead_stage` before linking to it.
      required:
        - id
        - record_state
        - first_name
        - last_name
        - phone_number
        - email
        - is_masked
        - is_lead_stage
        - lead_id
      title: RelatedCustomerResource
    RelatedTreatmentResource:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        group:
          type:
            - object
            - 'null'
          properties:
            id:
              type: integer
            name:
              type: string
          required:
            - id
            - name
      required:
        - id
        - name
        - group
      title: RelatedTreatmentResource
  responses:
    AuthenticationException:
      description: Unauthenticated
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    AuthorizationException:
      description: Authorization error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    CustomerErasedException:
      description: The patient record has been erased and is read-only
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                description: Always false for an error.
                examples:
                  - false
              error_code:
                type: string
                description: Machine-readable error code.
                examples:
                  - CUSTOMER_ERASED
              message:
                type: string
                description: Localized error message.
            required:
              - success
              - error_code
              - message
    ValidationException:
      description: Validation error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Errors overview.
              errors:
                type: object
                description: A detailed description of each field that failed validation.
                additionalProperties:
                  type: array
                  items:
                    type: string
            required:
              - message
              - errors
  securitySchemes:
    oauth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://dev.flextell.ai/oauth/authorize
          tokenUrl: https://dev.flextell.ai/oauth/token
          scopes:
            '*': all
    bearer:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.