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

# Delete a data stream

> Permanently deletes a data stream and all associated records and property definitions.

**Sync vs async:** Streams with at most 10,000 records are deleted synchronously and return 204. Streams above that threshold *must* be deleted asynchronously by passing `?async=true`; otherwise the request fails with 409. Callers may also opt into the async path explicitly for any size. The async path returns 202 with a `DataStreamOperation` payload; poll `GET /data_streams/{key}/operations/{id}` for progress.



## OpenAPI

````yaml /openapi.json delete /data_streams/{key}
openapi: 3.1.0
info:
  title: End Close API
  description: REST API is used to interact with the End Close platform.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.endclose.com/v1
security:
  - ApiKeyAuth: []
paths:
  /data_streams/{key}:
    delete:
      summary: Delete a data stream
      description: >-
        Permanently deletes a data stream and all associated records and
        property definitions.


        **Sync vs async:** Streams with at most 10,000 records are deleted
        synchronously and return 204. Streams above that threshold *must* be
        deleted asynchronously by passing `?async=true`; otherwise the request
        fails with 409. Callers may also opt into the async path explicitly for
        any size. The async path returns 202 with a `DataStreamOperation`
        payload; poll `GET /data_streams/{key}/operations/{id}` for progress.
      parameters:
        - in: path
          name: key
          required: true
          schema:
            type: string
          description: The immutable data stream key
        - in: query
          name: async
          required: false
          schema:
            type: string
            enum:
              - 'true'
              - 'false'
          description: >-
            When `"true"`, run the delete asynchronously and return 202 + a
            `DataStreamOperation`. Required for streams with more than 10,000
            records.
      responses:
        '202':
          description: >-
            Async delete accepted. Poll `GET
            /data_streams/{key}/operations/{id}` (also set in the `Location`
            header) until `status` is `completed` or `failed`.
          headers:
            Location:
              description: URL of the operation to poll
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataStreamOperation'
        '204':
          description: >-
            Data stream deleted synchronously (record count ≤ 10,000 and `async`
            not requested)
        '401':
          description: Unauthorized
        '404':
          description: Data stream not found
        '409':
          description: >-
            Either (a) the stream is linked to reconciliations and cannot be
            deleted, or (b) it has more than 10,000 records and `?async=true`
            was not provided.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
components:
  schemas:
    DataStreamOperation:
      type: object
      description: >-
        Async operation against a data stream (delete or reset). Poll via GET
        /data_streams/{key}/operations/{id}.
      properties:
        id:
          type: integer
        data_stream_id:
          type: integer
        data_stream_key:
          type: string
        kind:
          type: string
          enum:
            - delete
            - reset
        status:
          type: string
          enum:
            - pending
            - running
            - completed
            - failed
        progress:
          type: integer
          description: Percentage 0-100
        error_message:
          type: string
          nullable: true
        started_at:
          type: string
          format: date-time
          nullable: true
        completed_at:
          type: string
          format: date-time
          nullable: true
        created_at:
          type: string
          format: date-time
        requested_by_user_id:
          type: integer
          nullable: true
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````