Source: https://datafa.st/docs/api-delete-payment
Markdown source: https://datafa.st/docs/api-delete-payment.md
Description: Delete payments by transaction ID, visitor ID, or time range.

# Delete payments

`DELETE https://datafa.st/api/v1/payments`

Delete payments using transaction ID, visitor ID, or time range. Requires [Bearer Token](/docs/api-introduction) authentication.

## Query Parameters

### Specific Deletion (Highest Priority)

- **`transaction_id`** or **`tx_id`** (optional): Delete a specific payment by transaction ID

### Filter by Visitor (Optional)

- **`datafast_visitor_id`** (optional): Delete all payments for a specific visitor
  - Can be combined with time range to limit deletion scope

### Time Range Parameters (Optional)

- **`startAt`** (optional): ISO 8601 timestamp (e.g., `2023-01-01T00:00:00Z`)
- **`endAt`** (optional): ISO 8601 timestamp (e.g., `2023-01-31T23:59:59Z`)

**⚠️ WARNING:** When using `datafast_visitor_id` WITHOUT time range, ALL payments for that visitor across all time will be deleted.

## Deletion Behavior

- **With transaction_id:** Deletes that specific payment (ignores other parameters)
- **With visitor ID only:** Deletes all payments for that visitor (across all time)
- **With visitor ID + time range:** Deletes payments for that visitor within the time range
- **With time range only:** Deletes all payments within the time range

## Response

- **Success (200 OK):** Returns confirmation of deletion.
- **Errors:** 404 if transaction not found, 400 if parameters invalid.

## Code examples

### Example request (Delete by visitor within time range)

```bash
curl -X DELETE "https://datafa.st/api/v1/payments?datafast_visitor_id=abc123&startAt=2023-01-01T00:00:00Z&endAt=2023-01-31T23:59:59Z" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

### Success response

```json
{
  "status": "success",
  "data": [{
    "datafast_visitor_id": "abc123",
    "message": "All payments for visitor deleted successfully within time range",
    "timeRange": {
      "start": "2023-01-01T00:00:00.000Z",
      "end": "2023-01-31T23:59:59.000Z"
    }
  }]
}
```
