---
title: "Set Primary Keys"
method: PUT
path: "/api/connections/{connection_id}/schemas/{schema_id}/primary_keys"
tags: ["Schemas"]
---

# Set Primary Keys

`PUT /api/connections/{connection_id}/schemas/{schema_id}/primary_keys`

Overrides the primary key detected on a schema.

This is a full replacement: the keys you supply become the complete override
set, replacing any previously configured overrides. Omitting a key that was
previously set removes it.

Primary key overrides are useful when the source does not expose a primary
key or when the source-detected key is not the correct deduplication
identifier for your use case.

> 📘 To revert to the source-detected primary keys and remove all overrides,
> use [`DELETE /api/connections/{connection_id}/schemas/{schema_id}/primary_keys`](../../../../../../api-reference/schemas/reset-primary-keys).

## Path parameters

- `connection_id` string, uuid, required — Unique identifier of the connection.
- `schema_id` string, required — Identifier of the schema whose primary keys are being overridden.

## Headers

- `X-Polytomic-Version` string

## Request body

- SetPrimaryKeysRequest
  - `fields` SchemaPrimaryKeyOverrideInput[], nullable — Ordered list of source fields that together form the primary key. Replaces any existing override; supply an empty list to clear.
    - `field_id` string, required
    - `is_primary_key` boolean, required

## Response `202`

Accepted

## Other responses

- `400` — Bad Request
- `404` — Not Found
- `500` — Internal Server Error

---

[API](https://skmtc.dev/polytomic/apis/polytomic-api.md) · [All operations](https://skmtc.dev/polytomic/apis/polytomic-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/polytomic/polytomic-api/revisions/c2ce0e16e0e7/schema)
