# Delete dataset

`DELETE https://stylor.ai/api/v1/datasets/{datasetId}`

- Authentication: private API key, sent as `Authorization: Bearer sgpt-sk-…::…`
- Rate-limit resource: `api.v1.datasets.delete`
- Demo key: not accepted
- Web page: https://stylor.ai/guides/rest/v1/delete-dataset

Permanently deletes a dataset together with everything inside it: processed
items, their embeddings, queued ingest rows, the data sources that feed it
and any pending sync jobs. Sync history logs are removed shortly afterwards.

The dataset, items, embeddings, queue rows, sources and sync jobs are
removed in a single transaction — if any step fails, nothing is deleted.

> **This cannot be undone.** If you only want to take a dataset out of
> rotation, use *Archive dataset* instead; it keeps the data and can be
> reversed.

The response reports how many records of each kind were removed. Counts
for embeddings and sync logs are not included.

## Example request

```bash
curl -X DELETE "https://stylor.ai/api/v1/datasets/YOUR_DATASET_ID" \
  -H "Authorization: Bearer $STYLOR_API_KEY"
```

## Path parameters

- `datasetId` (string (uuid), required): The dataset to delete.

## Responses

### 200

The dataset and its contents were deleted.

Content type `application/json`:

- `deleted` (boolean, required): Always `true` on success.
- `deletedCount` (integer, required): Dataset records removed. Always `1` on success.
- `itemsDeletedCount` (integer, required): Processed items the dataset held. The dataset is gone at once; its items, their photos and search entries are removed in the background, usually within seconds.
- `queuedDeletedCount` (integer, required): Ingest-queue rows the dataset held, removed with its items.
- `sourcesDeletedCount` (integer, required): Data sources removed.
- `syncJobsDeletedCount` (integer, required): Pending sync jobs removed.

Example:

```json
{
  "deleted": true,
  "deletedCount": 1,
  "itemsDeletedCount": 1296,
  "queuedDeletedCount": 5,
  "sourcesDeletedCount": 1,
  "syncJobsDeletedCount": 0
}
```

## Errors

Every error is a JSON object with an `error` string. Match on the status code; the message is written for people.

| Status | Message | When |
| --- | --- | --- |
| 401 | Organization '<organizationId>' not found. | The organization that owns the key no longer exists. |
| 404 | Dataset '<datasetId>' not found for organization '<organizationId>'. | No dataset with that id belongs to your organization, or it vanished while the transaction ran. Nothing was deleted. |
| 422 | Invalid 'datasetId': expected a non-empty string. | `datasetId` is empty. |

### Shared authentication, quota and rate-limit errors

| Status | Message | When |
| --- | --- | --- |
| 401 | API key missing. | The `Authorization` header is absent, is not `Bearer <key>`, or the key does not have three dash-separated segments. |
| 401 | Authentication failed: public key is invalid or not recognized. | A public-key endpoint was called with a key that does not exist. |
| 401 | Authentication failed: private key provided instead of a public key. | A public-key endpoint was called with an `sgpt-sk-…` key. |
| 401 | Authentication failed: token is not recognized. | A private-key endpoint was called with a key whose lookup segment does not exist. |
| 401 | Authentication failed: private key is invalid. | A private-key endpoint was called with a key whose secret does not match. |
| 401 | Authentication failed: public key provided instead of a private key. | A private-key endpoint was called with an `sgpt-pk-…` key. |
| 401 | Authentication failed: bearer token format is invalid. | A private key was sent without its `::` lookup segment. |
| 401 | Authentication failed: API key could not be read. Regenerate the key. | The key's embedded organization data could not be decrypted or parsed. |
| 403 | Demo mode is not available for private-key routes. Demos are only supported with public API keys. | The demo key was sent to a private-key endpoint. |
| 403 | Demo mode is not supported on this API route. Check the documentation for available demo endpoints. | The demo key was sent to a public-key endpoint that opts out of demo mode. |
| 403 | No active subscription for this organization. | The organization that owns the key has no active subscription. |
| 403 | No quota found for organization "<organizationId>". | The organization has no quota record for the current billing period. |
| 403 | No entitlement for "<resource>". | The plan's quota template has no entry for this endpoint. |
| 403 | Access denied to "<resource>". | The plan's quota template turns this endpoint off. |
| 429 | Monthly quota exceeded for "<resource>" (<quota>/<quota> used). | The billing-period quota for this endpoint is exhausted. `Retry-After` gives the seconds until the period resets. |
| 429 | RPM limit exceeded for "<resource>" (<used>/<limit> used). | More than the allowed requests per minute were sent. `Retry-After` is 60. |
| 500 | Internal server error. | An unexpected failure on the server. The message is always this string; details are logged, never returned. Quota consumed by the request is refunded, as it is for every 5xx response. |
