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

# Delete events

> Hard-deletes ingested events and the meter usage they produced for the named customers and period, optionally narrowed by feature or by exact event id. Refused when anything in scope has already been invoiced. Irreversible.



## OpenAPI

````yaml https://swagger.flexprice.io post /events/delete
openapi: 3.0.1
info:
  title: Flexprice API
  description: Flexprice API Service
  contact:
    name: API Support
  license:
    name: AGPL-3.0
    url: https://www.gnu.org/licenses/agpl-3.0.html
  version: '1.0'
servers:
  - url: https://us.api.flexprice.io/v1
    description: US Region
  - url: https://api.cloud.flexprice.io/v1
    description: India Region
security: []
paths:
  /events/delete:
    post:
      tags:
        - Events
      summary: Delete events
      description: >-
        Hard-deletes ingested events and the meter usage they produced for the
        named customers and period, optionally narrowed by feature or by exact
        event id. Refused when anything in scope has already been invoiced.
        Irreversible.
      operationId: deleteEvents
      requestBody:
        description: Deletion scope
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeleteEventsRequest'
        required: true
      responses:
        '200':
          description: OK
          headers:
            X-Request-ID:
              description: Identifies this deletion in deleted_events_logs
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeleteEventsResponse'
        '400':
          description: Invalid request, or a guard refused the deletion
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
        '403':
          description: Caller lacks the capability, or is a service account
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
        '409':
          description: A deletion is already in progress for a customer in this request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: python
          label: Python
          source: |-
            from flexprice import Flexprice
            from flexprice.utils import parse_datetime


            with Flexprice(
                api_key_auth="<YOUR_API_KEY_HERE>",
            ) as f_client:

                res = f_client.events.delete_events(external_customer_ids=[
                    "<value 1>",
                    "<value 2>",
                ], period_end=parse_datetime("2026-03-28T00:00:00Z"), period_start=parse_datetime("2026-03-01T00:00:00Z"))

                # Handle response
                print(res)
        - lang: typescript
          label: TypeScript
          source: |-
            import { Flexprice } from "@flexprice/sdk";

            const flexprice = new Flexprice({
              apiKeyAuth: "<YOUR_API_KEY_HERE>",
            });

            async function run() {
              const result = await flexprice.events.deleteEvents({
                externalCustomerIds: [
                  "<value 1>",
                  "<value 2>",
                ],
                periodEnd: new Date("2026-03-28T00:00:00Z"),
                periodStart: new Date("2026-03-01T00:00:00Z"),
              });

              console.log(result);
            }

            run();
        - lang: go
          label: Go
          source: "package main\n\nimport(\n\t\"context\"\n\tflexprice \"github.com/flexprice/go-sdk/v2\"\n\t\"github.com/flexprice/go-sdk/v2/types\"\n\t\"github.com/flexprice/go-sdk/v2/models/types\"\n\t\"log\"\n)\n\nfunc main() {\n    ctx := context.Background()\n\n    s := flexprice.New(\n        flexprice.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n    )\n\n    res, err := s.Events.DeleteEvents(ctx, types.DeleteEventsRequest{\n        ExternalCustomerIds: []string{\n            \"<value 1>\",\n            \"<value 2>\",\n        },\n        PeriodEnd: types.MustTimeFromString(\"2026-03-28T00:00:00Z\"),\n        PeriodStart: types.MustTimeFromString(\"2026-03-01T00:00:00Z\"),\n    })\n    if err != nil {\n        log.Fatal(err)\n    }\n    if res.DeleteEventsResponse != nil {\n        // handle response\n    }\n}"
components:
  schemas:
    DeleteEventsRequest:
      required:
        - external_customer_ids
        - period_end
        - period_start
      type: object
      properties:
        event_ids:
          maxItems: 1000
          type: array
          description: >-
            EventIDs narrows the deletion to exact event ids. Requires exactly
            one

            customer and no feature_ids.
          items:
            type: string
        external_customer_ids:
          maxItems: 100
          minItems: 1
          type: array
          items:
            type: string
        feature_ids:
          maxItems: 100
          type: array
          description: >-
            FeatureIDs narrows the deletion to the meters these features resolve
            to.
          items:
            type: string
        period_end:
          type: string
          example: '2026-03-28T00:00:00Z'
          format: date-time
        period_start:
          type: string
          example: '2026-03-01T00:00:00Z'
          format: date-time
        skip_payload:
          type: boolean
          description: >-
            SkipPayload stores the audit row's properties as '' so the deletion
            leaves

            no payload copy. Defaults to true: a deletion is usually an erasure,
            and

            keeping the payload would defeat it. Send false to retain it.
    DeleteEventsResponse:
      type: object
      properties:
        deleted_events:
          type: integer
        deleted_meter_usage_rows:
          type: integer
    errors.ErrorResponse:
      type: object
      properties:
        code:
          $ref: '#/components/schemas/errors.ErrorCode'
        http_status_code:
          type: integer
        message:
          type: string
      x-speakeasy-name-override: ErrorResponse
    errors.ErrorCode:
      type: string
      enum:
        - http_client_error
        - system_error
        - internal_error
        - not_found
        - already_exists
        - version_conflict
        - validation_error
        - invalid_operation
        - permission_denied
        - database_error
        - service_unavailable
        - too_many_requests
        - not_implemented
      x-enum-varnames:
        - ErrCodeHTTPClient
        - ErrCodeSystemError
        - ErrCodeInternalError
        - ErrCodeNotFound
        - ErrCodeAlreadyExists
        - ErrCodeVersionConflict
        - ErrCodeValidation
        - ErrCodeInvalidOperation
        - ErrCodePermissionDenied
        - ErrCodeDatabase
        - ErrCodeServiceUnavailable
        - ErrCodeTooManyRequests
        - ErrCodeNotImplemented
      x-speakeasy-name-override: ErrorCode
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      description: Enter your API key in the format *x-api-key &lt;api-key&gt;**
      name: x-api-key
      in: header

````

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