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

# Update an appointment

> Changes one of your appointments. The body carries **exactly one** named change: `cancel`, `reschedule`, `complete`, or `reopen`. Two together is a `400` (`conflicting-patch`); none is a `400` (`empty-patch`).

**Cancel** — `{ "cancel": { "reason": "..." } }` closes the appointment and frees the slot. The response carries `cancelled_at` and `cancel_reason`. `reason` is optional, so `{ "cancel": {} }` is a valid cancel.

**Reschedule** — `{ "reschedule": { "slot_token": "..." } }` moves it to the window sealed by a token from a slot search. `start` and `end` are not settable directly: the token is what proves the new window is bookable, and the provider is re-selected from the set it seals. The appointment id does not change.

**Complete** — `{ "complete": {} }` records that the visit happened; `{ "complete": { "no_show": true } }` that the patient did not attend. One arm settles both, because closing the appointment out and saying whether the patient turned up is one action.

**Reopen** — `{ "reopen": {} }` re-opens a closed appointment, a cancelled one included. Cancelling freed the slot, so this is best-effort: the response is `{ appointment, mechanism }` rather than the appointment alone. `mechanism` is `original-provider` (the window came back), `substitute-provider` (another provider took it; `original_provider_id` names who held it before), or `unresolved` (nobody could take the window, so the appointment stays closed — but with the outcome you disputed replaced by `unresolved`, from which `reschedule` and `cancel` both work). The arm takes no fields: the substitute search reads the appointment's own type and state.

Every arm is attributed to the access token's subject, so the appointment's status history names who acted.



## OpenAPI

````yaml /openapi.json patch /appointments/{id}
openapi: 3.1.0
info:
  title: OpenLoop API
  version: 0.1.0
  description: >-
    Unified reference for the OpenLoop Patient (clinical) and Payments & Revenue
    APIs.
servers:
  - url: https://api.openloophealth.com/v0.1
    description: Production partner edge
  - url: https://api-staging.openloophealth.com/v0.1
    description: Staging partner edge (sandbox credentials)
security: []
paths:
  /appointments/{id}:
    patch:
      tags:
        - Scheduling
      summary: Update an appointment
      description: >-
        Changes one of your appointments. The body carries **exactly one** named
        change: `cancel`, `reschedule`, `complete`, or `reopen`. Two together is
        a `400` (`conflicting-patch`); none is a `400` (`empty-patch`).


        **Cancel** — `{ "cancel": { "reason": "..." } }` closes the appointment
        and frees the slot. The response carries `cancelled_at` and
        `cancel_reason`. `reason` is optional, so `{ "cancel": {} }` is a valid
        cancel.


        **Reschedule** — `{ "reschedule": { "slot_token": "..." } }` moves it to
        the window sealed by a token from a slot search. `start` and `end` are
        not settable directly: the token is what proves the new window is
        bookable, and the provider is re-selected from the set it seals. The
        appointment id does not change.


        **Complete** — `{ "complete": {} }` records that the visit happened; `{
        "complete": { "no_show": true } }` that the patient did not attend. One
        arm settles both, because closing the appointment out and saying whether
        the patient turned up is one action.


        **Reopen** — `{ "reopen": {} }` re-opens a closed appointment, a
        cancelled one included. Cancelling freed the slot, so this is
        best-effort: the response is `{ appointment, mechanism }` rather than
        the appointment alone. `mechanism` is `original-provider` (the window
        came back), `substitute-provider` (another provider took it;
        `original_provider_id` names who held it before), or `unresolved`
        (nobody could take the window, so the appointment stays closed — but
        with the outcome you disputed replaced by `unresolved`, from which
        `reschedule` and `cancel` both work). The arm takes no fields: the
        substitute search reads the appointment's own type and state.


        Every arm is attributed to the access token's subject, so the
        appointment's status history names who acted.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: The appointment id.
        - name: Idempotency-Key
          in: header
          required: true
          schema:
            type: string
            minLength: 1
            maxLength: 255
          description: >-
            A key you generate, one per update attempt. A retry under the same
            key replays the stored response instead of applying the change
            twice. Omitting it is a `400` (`missing-idempotency-key`). A key is
            global to your integration, not scoped to an endpoint or an
            appointment, so mint a fresh UUID per action rather than deriving
            one from the resource — a key already spent on a booking will replay
            that booking if you send it on a later cancel or complete.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SchedulingAppointmentUpdate'
      responses:
        '200':
          description: >-
            The updated appointment — or, on the `reopen` arm, the appointment
            plus the mechanism that restored it.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/SchedulingAppointment'
                  - $ref: '#/components/schemas/SchedulingReopenResult'
        '400':
          description: >-
            Request validation failed: no arm (`empty-patch`), two arms
            (`conflicting-patch`), a missing `Idempotency-Key`
            (`missing-idempotency-key`), or an expired or malformed slot token
            (`slot_token.expired`, `slot_token.invalid`), or a slot token
            searched for a different patient than the appointment's
            (`slot_token.patient_mismatch`).
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/SchedulingProblem'
        '401':
          description: Missing or invalid bearer token.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/SchedulingProblem'
        '403':
          description: The slot token was issued for a different organization.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/SchedulingProblem'
        '404':
          description: No such appointment for your organization.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/SchedulingProblem'
        '409':
          description: >-
            The appointment cannot make this transition
            (`appointment.invalid-state`), or every eligible provider's new slot
            is gone (`appointment.reschedule-conflict`).
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/SchedulingProblem'
        '500':
          description: >-
            A transient persistence error aborted the write; retry with the same
            key.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/SchedulingProblem'
      security:
        - serviceToken: []
        - userToken: []
components:
  schemas:
    SchedulingAppointmentUpdate:
      description: >-
        Exactly one named change per request. The arms are mutually exclusive:
        sending two is a `400` (`conflicting-patch`), sending none is a `400`
        (`empty-patch`).
      oneOf:
        - title: Cancel
          type: object
          properties:
            cancel:
              type: object
              description: Cancel the appointment. Send `{}` to cancel without a reason.
              properties:
                reason:
                  type: string
                  maxLength: 500
                  description: Free text, recorded on the appointment as `cancel_reason`.
          required:
            - cancel
        - title: Reschedule
          type: object
          properties:
            reschedule:
              type: object
              description: Move the appointment to the window the token seals.
              properties:
                slot_token:
                  type: string
                  minLength: 1
                  maxLength: 8192
                  description: A `slot_token` for the new time, from a slot search.
              required:
                - slot_token
          required:
            - reschedule
        - title: Complete
          type: object
          properties:
            complete:
              type: object
              description: >-
                Settle the appointment's outcome. Send `{}` for a visit that
                happened.
              properties:
                no_show:
                  type: boolean
                  description: >-
                    `true` closes the appointment with outcome `no_show` instead
                    of `completed`. Omit it, or send `false`, for a visit that
                    happened.
          required:
            - complete
        - title: Reopen
          type: object
          properties:
            reopen:
              type: object
              description: >-
                Re-open a closed appointment. Send `{}` — the arm takes no
                fields.
              properties: {}
          required:
            - reopen
    SchedulingAppointment:
      type: object
      description: >-
        A booked appointment. Returned bare (not wrapped in a `data` envelope)
        by the single-appointment endpoints. Carries no `organization_id` — your
        org comes from the access token.
      properties:
        id:
          type: string
          format: uuid
        provider_id:
          type: string
          format: uuid
          description: The provider scheduling assigned at book time.
        patient_id:
          type: string
          format: uuid
        start:
          type: string
          format: date-time
        end:
          type: string
          format: date-time
        status:
          type: string
          enum:
            - open
            - closed
          description: >-
            Lifecycle state. `closed` is terminal; read `outcome` for how it
            closed.
        outcome:
          type: string
          enum:
            - completed
            - no_show
            - cancelled
            - unresolved
          description: Present once the appointment closes.
        state:
          type: string
          minLength: 2
          maxLength: 2
          description: Two-letter US state the visit was licensed against.
        closed_at:
          type: string
          format: date-time
          description: >-
            When the appointment closed, however it closed — completed, no-show
            or cancelled. Present once `status` is `closed`.
        cancelled_at:
          type: string
          format: date-time
        cancel_reason:
          type: string
        notes:
          type: string
          description: Pre-visit notes, when the booking set them.
        external_refs:
          type: array
          description: Identifiers this appointment carries in downstream systems.
          items:
            type: object
            properties:
              system:
                type: string
              id:
                type: string
            required:
              - system
              - id
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - id
        - provider_id
        - patient_id
        - start
        - end
        - status
        - created_at
        - updated_at
    SchedulingReopenResult:
      type: object
      description: >-
        The result of the `reopen` arm. Reopening is best-effort, so the
        appointment arrives with the mechanism that settled it.
      properties:
        appointment:
          $ref: '#/components/schemas/SchedulingAppointment'
        mechanism:
          type: string
          enum:
            - original-provider
            - substitute-provider
            - unresolved
          description: >-
            `original-provider` — the original window came back.
            `substitute-provider` — another provider took it, and
            `original_provider_id` names who held it before. `unresolved` —
            nobody could take the window, so the appointment stays closed with
            outcome `unresolved`.
        original_provider_id:
          type: string
          format: uuid
          description: >-
            Who held the appointment before it was reopened. Present only on
            `substitute-provider`.
      required:
        - appointment
        - mechanism
    SchedulingProblem:
      type: object
      description: >-
        RFC 7807 problem detail. Scheduling endpoints return errors as
        `application/problem+json`, not the platform `{ error, request_id }`
        envelope. `code` is the stable machine-readable identifier — branch on
        it, not on `detail`.
      properties:
        type:
          type: string
          description: Problem type URI. `about:blank` for the codes below.
        title:
          type: string
          description: Short human-readable summary, e.g. `Bad Request`.
        status:
          type: integer
          description: The HTTP status code, repeated in the body.
        detail:
          type: string
          description: Human-readable explanation of this occurrence.
        instance:
          type: string
        code:
          type: string
          description: >-
            Stable error identifier, e.g. `slot_search.window_too_large`,
            `appointment_list.offset_required`, `slot_token.tampered`.
          examples:
            - slot_search.window_too_large
        errors:
          type: array
          description: >-
            Field-level validation failures, when the error is a body/query
            validation failure.
          items:
            type: object
            properties:
              field:
                type: string
              message:
                type: string
              code:
                type: string
            required:
              - field
              - message
              - code
      required:
        - type
        - title
        - status
        - code
  securitySchemes:
    serviceToken:
      type: oauth2
      description: >-
        Service (M2M) access token issued by POST /auth/token using the
        client_credentials grant. Required scopes, where known, are listed on
        each operation below.
      flows:
        clientCredentials:
          tokenUrl: https://api.openloophealth.com/v0.1/auth/token
          scopes: {}
    userToken:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        User access token issued by POST /auth/token via the verification-code
        grant (after Verify a one-time code) or the refresh_token grant.

````

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