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

# POST /v1/scheduling/appointments/:id/cancel

> Cancel an appointment with an optional reason. Marks status as cancelled and records cancelled_at.

Marks the appointment as cancelled. Persists `cancelled_at: <now>` and `cancellation_reason` if provided. Freeing the calendar slot is automatic: from this point on the time slot shows up as available again.

## Endpoint

```
POST https://api.keebai.com/v1/scheduling/appointments/:id/cancel
```

## Required scope

`scheduling:appointments:cancel`

## Path params

| Param | Type     | Description     |
| ----- | -------- | --------------- |
| `id`  | `string` | Appointment id. |

## Headers

| Header          | Required                | Value                    |
| --------------- | ----------------------- | ------------------------ |
| `Authorization` | Yes                     | `Bearer kbai_pk_<token>` |
| `Content-Type`  | Yes (if sending a body) | `application/json`       |

## Body

| Field    | Type     | Required | Description                                                                   |
| -------- | -------- | -------- | ----------------------------------------------------------------------------- |
| `reason` | `string` | No       | Cancellation reason (max 500 characters). Persisted in `cancellation_reason`. |

## Example request

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://api.keebai.com/v1/scheduling/appointments/9d5b1f4e-7c2a-4a4d-9d3e-9f1b1f8c7a3a/cancel \
    -H "Authorization: Bearer kbai_pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
    -H "Content-Type: application/json" \
    -d '{ "reason": "Cliente no puede asistir" }'
  ```

  ```python Python theme={null}
  import os, requests

  resp = requests.post(
      f"https://api.keebai.com/v1/scheduling/appointments/{appointment_id}/cancel",
      headers={"Authorization": f"Bearer {os.environ['KEEBAI_API_TOKEN']}"},
      json={"reason": "Cliente no puede asistir"},
      timeout=10,
  )
  resp.raise_for_status()
  ```
</CodeGroup>

## Response

### 200 OK

Returns the appointment with `status: "cancelled"`, `cancelled_at`, and `cancellation_reason` populated.

### 404 Not Found

The appointment doesn't exist or belongs to another company.

### 409 Conflict

```json theme={null}
{
  "error": {
    "code": "INVALID_APPOINTMENT_STATE",
    "message": "La cita ya está cancelada"
  }
}
```

Other states (such as `completed`) also return 409 if they don't allow cancellation.

### 401 Unauthorized · 403 Forbidden

Same semantics as the rest of the public API.


## OpenAPI

````yaml POST /v1/scheduling/appointments/{id}/cancel
openapi: 3.0.0
info:
  title: Keebai Public API
  description: Superficie pública REST autenticada con Personal Access Tokens (PAT).
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.keebai.com
    description: Production
security: []
tags: []
paths:
  /v1/scheduling/appointments/{id}/cancel:
    post:
      tags:
        - scheduling-appointments
      summary: Suspender (cancelar) una cita
      description: Marca la cita como cancelada con la razón opcional indicada.
      operationId: PublicAppointmentsController_cancel
      parameters:
        - name: id
          required: true
          in: path
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelAppointmentDto'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicAppointmentResponseDto'
      security:
        - PAT: []
components:
  schemas:
    CancelAppointmentDto:
      type: object
      properties:
        reason:
          type: string
          description: Motivo de cancelación
    PublicAppointmentResponseDto:
      type: object
      properties:
        _id:
          type: string
          description: Id de la cita
        appointment_number:
          type: number
          description: Correlativo legible de la cita
        branch:
          $ref: '#/components/schemas/PublicAppointmentRefDto'
        service:
          $ref: '#/components/schemas/PublicAppointmentRefDto'
        professional:
          $ref: '#/components/schemas/PublicAppointmentProfessionalDto'
        customer:
          $ref: '#/components/schemas/PublicAppointmentCustomerDto'
        dates:
          $ref: '#/components/schemas/PublicAppointmentDatesDto'
        appointment_type:
          type: string
          description: online | in-person
        status:
          type: string
          description: pending | confirmed | cancelled | …
        payment_status:
          type: string
          description: Estado del pago
        notes:
          type: string
        price:
          type: number
        currency:
          type: string
          description: Moneda ISO 4217
        paid:
          type: boolean
        cancelled_at:
          type: string
          format: date-time
        cancellation_reason:
          type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - _id
        - branch
        - dates
        - status
    PublicAppointmentRefDto:
      type: object
      properties:
        id:
          type: string
        display_name:
          type: string
      required:
        - id
    PublicAppointmentProfessionalDto:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        last_name:
          type: string
        specialty:
          type: string
      required:
        - id
    PublicAppointmentCustomerDto:
      type: object
      properties:
        name:
          type: string
        last_name:
          type: string
        email:
          type: string
        phone:
          type: string
      required:
        - name
    PublicAppointmentDatesDto:
      type: object
      properties:
        start:
          type: string
          format: date-time
        end:
          type: string
          format: date-time
        time_zone:
          type: string
          description: IANA, ej. America/Santiago
      required:
        - start
        - end
  securitySchemes:
    PAT:
      scheme: bearer
      bearerFormat: kbai_pk_<hex>
      type: http
      description: >-
        Personal Access Token con prefijo `kbai_pk_`. Generar desde el portal
        con permiso `developer.manage_tokens`.

````