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

# Delete Session

> Delete a session (appointment) by its public id, scoped to the authenticated organization. A frozen session — one with a non-archived encounter, a non-archived note, or a completed cancellation — cannot be deleted and returns 400. On success, dependent overrides, cancellations and history are removed together with the session.

## Delete Session

Delete a single session (appointment) by its public id. The session must belong to the organization that owns the API key.

### Headers

```
Authorization: Bearer <your-api-key>
```

### Deletion rules

A session can only be deleted when it is not frozen — that is, when it has no recorded clinical work:

* **Encounters** — if the session has any non-archived encounter, deletion is blocked.
* **Notes (activities)** — if the session has any non-archived activity, deletion is blocked.
* **Completed cancellations** — if the session has a completed cancellation, deletion is blocked. Cancellations still mid-workflow (pending, searching, etc.) do not block it.

When deletion is allowed, the session's dependent records (overrides, cancellations and history) are removed together with the session in a single transaction.

### Success Response (200)

```json theme={null}
{
  "message": "Session deleted successfully"
}
```

### Error Responses

#### 400 - Bad Request

Returned when the session is frozen and cannot be deleted because it has recorded clinical work.

```json theme={null}
{
  "error": "Cannot modify or delete a session that has encounters.",
  "statusCode": 400
}
```

For a session with notes the message is `Cannot modify or delete a session that has notes.`, and for a completed cancellation it is `Cannot modify or delete a session that has a completed cancellation.`

An invalid `sessionId` (for example one containing a null byte) is instead returned as a validation list, where each `path` is an array of segments:

```json theme={null}
{
  "message": "Validation Error",
  "statusCode": 400,
  "validationErrors": [
    {
      "code": "custom",
      "path": ["sessionId"],
      "message": "sessionId is invalid"
    }
  ]
}
```

#### 401 - Unauthorized

```json theme={null}
{
  "error": "API key required",
  "statusCode": 401
}
```

#### 403 - Forbidden

```json theme={null}
{
  "error": "Access denied",
  "statusCode": 403
}
```

#### 404 - Not Found

Returned when no session with the given id exists in the organization.

```json theme={null}
{
  "error": "Session not found",
  "statusCode": 404
}
```

## Examples

### cURL

```bash theme={null}
curl -X DELETE "https://app.hipp.health/api/v1/sessions/apt_1a2b3c4d5e" \
  -H "Authorization: Bearer your-api-key"
```

### JavaScript

```javascript theme={null}
const deleteSession = async (sessionId) => {
  const response = await fetch(
    `https://app.hipp.health/api/v1/sessions/${sessionId}`,
    {
      method: "DELETE",
      headers: {
        Authorization: "Bearer your-api-key",
      },
    }
  );

  if (!response.ok) {
    const error = await response.json();
    throw new Error(error.error || error.message || "Failed to delete session");
  }

  return response.json();
};

// Usage
try {
  const result = await deleteSession("apt_1a2b3c4d5e");
  console.log(result.message);
} catch (error) {
  console.error("Error deleting session:", error.message);
}
```


## OpenAPI

````yaml DELETE /v1/sessions/{sessionId}
openapi: 3.0.0
info:
  title: Hipp Health API
  version: 1.0.0
  description: API for managing users and resources within your Hipp Health organization
servers:
  - url: https://app.hipp.health/api
    description: Production Server
security: []
paths:
  /v1/sessions/{sessionId}:
    delete:
      tags:
        - V1
      summary: Delete session by id
      description: >-
        Delete a session (appointment) by its public id, scoped to the
        authenticated organization. A frozen session — one with a non-archived
        encounter, a non-archived note, or a completed cancellation — cannot be
        deleted and returns 400. On success, dependent overrides, cancellations
        and history are removed together with the session.
      parameters:
        - name: sessionId
          in: path
          description: Session public identifier
          required: true
          schema:
            type: string
            minLength: 1
      responses:
        '200':
          description: Session deleted successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Session deleted successfully
        '400':
          description: >-
            Deletion blocked because the session is frozen (it has a
            non-archived encounter, a non-archived note, or a completed
            cancellation).
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Cannot modify or delete a session that has encounters.
                  statusCode:
                    type: integer
                    example: 400
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Session not found
                  statusCode:
                    type: integer
                    example: 404
        '405':
          $ref: '#/components/responses/405'
      security:
        - BearerAuth: []
components:
  responses:
    '401':
      description: Unauthorized - API key required
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorResponse'
          example:
            error: API key required
            statusCode: 401
    '403':
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorResponse'
          example:
            error: Access denied
            statusCode: 403
    '405':
      description: Method Not Allowed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorResponse'
          example:
            error: Method not allowed
            statusCode: 405
  schemas:
    ApiErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message
          example: User not found
        statusCode:
          type: integer
          example: 404
      required:
        - error
        - statusCode
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        API key authentication. Include your API key in the Authorization header
        as 'Bearer <your-api-key>'

````