Source: https://datafa.st/docs/api/website/goals/delete
Markdown source: https://datafa.st/docs/api/website/goals/delete.md
Description: Delete custom goal events by visitor, name, or time range.

# Delete goals

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

Delete custom goal events by visitor, name, or time range.

## Request

### Authentication

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


### Query parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `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. |
| `name` | string | No | Human-readable name for the resource or event. The exact meaning depends on the endpoint. Delete goals by name. Lowercased and spaces become underscores. |
| `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 `datafast_visitor_id` or `name`. |
| `start / end` | string | No | Optional time range when using visitor or name filters. |

## 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[].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[].goal_name` | string | Present when deleting by goal name. |
| `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/goals?name=signup&start=2026-05-01T00:00:00Z&end=2026-05-19T23:59:59Z" \
  -H "Authorization: Bearer df_xxx"
```

### Success response

```json
{
  "status": "success",
  "data": [{
    "message": "Goal events deleted successfully within time range",
    "goal_name": "signup",
    "timeRange": {
      "start": "2026-05-01T00:00:00.000Z",
      "end": "2026-05-19T23:59:59.000Z"
    }
  }]
}
```
