---
title: "Update a source"
method: PATCH
path: "/sources/{id}"
---

# Update a source

`PATCH /sources/{id}`

## Request

- Base URL: `https://www.merchkit.com/api/v1`
- URL: `https://www.merchkit.com/api/v1/sources/{id}`
- Auth: HTTP bearer

THE one write path: set attribute values and/or move the parent in a single call (provide `parent_id`, `attributes`, or both). Writes are symmetric with reads — a GET response's `attributes` re-sent verbatim is valid (`{id, type, label}` stubs are accepted; extra stub fields ignored). `null` or `""` clears a value (the key then disappears from reads); list-reference writes REPLACE the current set. Returns the full updated resource.

Scope: `write:sources`.

## Request body

- object
  - `parent_id` string, uuid, nullable: New parent id, or null to detach.
  - `attributes` AttributeWriteMap: Map of attribute key → new value (sparse — only keys being written). Scalars set the value; `null` OR `""` clears it (the key then disappears from reads). A single-reference key accepts a bare UUID string or an `{id}` object; a list-reference key accepts an array of either — list writes REPLACE the current set. Read stubs re-sent verbatim are valid writes (extra stub fields like `type`/`label` are ignored). Unknown keys are a 400; select values must be one of the attribute's `acceptable_values`.

## Response `200`

The updated source (full resource).

- object
  - `data` EntityResource: The one shape for every entity read and mutation response. System fields live at the top level; every customer-defined key lives in `attributes`, so customer keys can never collide with system ones.
    - `id` string, uuid, required
    - `type` 'product' | 'image' | 'vendor' | 'category' | 'source', required: The entity type discriminator.
    - `label` string, nullable, required: The workspace's primary-attribute value for this entity; null when no primary attribute is configured or it is unset (never a UUID posing as a name). Render `label ?? id`.
    - `parent_id` string, uuid, nullable, required: Parent entity id (products: the variant parent).
    - `created_at` string, date-time, nullable, required
    - `updated_at` string, date-time, nullable, required
    - `attributes` object, required: SPARSE map of customer-defined keys — only keys with values appear; a missing key means unset or not-applicable (read `attributes[key] ?? null`; never contains null or ""). Scalars are bare values; a single reference is a labeled stub; a list reference is a COMPLETE ordered stub array (no cap, array order = position order). Inverse-reference keys never appear — traverse them via filters or `/products/{id}/references`. The full key list comes from `GET /attributes`.

## Other responses

- `400`: Validation failed (unknown key, bad value, self-parenting).
- `404`: Not found.

---

[API](https://skmtc.dev/merchkit/apis/merchkit-api.md) - [All operations](https://skmtc.dev/merchkit/apis/merchkit-api/llms.txt) - [OpenAPI document](https://skmtc.dev/merchkit/apis/merchkit-api/revisions/3062ca814757?raw)
