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

# Delete payments

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

Delete payment and free-trial records by transaction, visitor, or time range.

## Request

### Authentication

- `df_` website API key for one website.
- `dft_` account token with `payments:write`. Pass `websiteId` as a query parameter.


### Query parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `transaction_id / tx_id` | string | No | Unique transaction ID from your payment provider. Used for idempotency and deletion. Delete one payment or free trial by transaction ID. Highest priority. |
| `datafast_visitor_id` | string | No | DataFast visitor UUID from the browser cookie or client SDK. Used to attach server-side events to a visitor journey. Delete all payments/free trials for one visitor. |
| `startAt / endAt` | string | Required for bulk delete | Start of the reporting window. Use it with `endAt` to query a specific date range instead of the endpoint default. Required when deleting without transaction or visitor. |
| `start / end` | string | No | Optional range for visitor-based deletes. |

## Response

Returns a JSON object with `status` and endpoint-specific fields.

### Response fields

| Field | Type | Description |
| --- | --- | --- |
| `status` | string | `success`. |
| `data[].message` | string | Human-readable confirmation or status message for the operation. |
| `data[].transaction_id` | string | Unique transaction ID from your payment provider. Used for idempotency and deletion. |
| `data[].datafast_visitor_id` | string | DataFast visitor UUID from the browser cookie or client SDK. Used to attach server-side events to a visitor journey. |
| `data[].timeRange.start` | string | Present for time range deletes. |
| `data[].timeRange.end` | string | Present for time range deletes. |

### Errors

Common errors include `400` for invalid input, `401` for missing or invalid tokens, `403` for missing permission or suspended tracking, `404` for missing resources, and `500` for server errors.

## Code examples

### Example request

```bash
curl -X DELETE "https://datafa.st/api/v1/payments?transaction_id=payment_456" \
  -H "Authorization: Bearer df_xxx"
```

### Success response

```json
{
  "status": "success",
  "data": [{
    "transaction_id": "payment_456",
    "message": "Payment deleted successfully"
  }]
}
```
