# Set Primary Keys

```
POST 
/v1/datasets/:dataset_id/set-primary-keys
```

Set primary keys on an Iceberg dataset and trigger compaction to enforce uniqueness.

This will:

1. Validate pk\_columns exist in the dataset schema
2. Acquire an exclusive lock on the dataset
3. Dispatch an async DATASET\_COMPACT\_PK event
4. Return immediately with jobId and status="queued"

The actual deduplication runs asynchronously. Poll processingStatus to track progress. Returns 409 if the dataset is already locked/processing.

## Request[​](#request "Direkter Link zur request")

## Responses[​](#responses "Direkter Link zur Responses")

* 200
* 404
* 422

Successful Response

Not found

Validation Error
