---
updatedAt: 2025-10-03T13:07:40.000Z
agentTools:
  projectIndex: https://docs.quable.com/llms.txt
---

# Documents - Change Unique Code

> 👍 Objective
>
> This cookbook explains how to change a document's unique identifier in Quable PIM.

<table>
  <tr>
    <td style={{ border: "1px solid white", padding: "0", width: "70%" }}>
      Documents display all of the attributes that describe your products. <br /><br />You may have several different types of documents within your Quable PIM classifications, so it's important to understand your hierarchy.
    </td>
    <td style={{ border: "1px solid white", textAlign: "center" }}>
      <Image title="document.png" alt={150} width="auto" src="https://files.readme.io/fe01a45-document.png" />
    </td>
  </tr>
</table>

## Process Overview

It may become necessary at some point to change a document's unique identifier in Quable PIM (e.g., to synchronize with a change in your ERP). To do so, all you need to do is make a simple <code>PUT</code> call to Quable PIM API.

## Push the new code

To change a document's unique code, you must identify its current unique code.

<HTMLBlock>{`
<table>
	<tr>
		<td colspan="4" style="background: #F8F8F8">
      <strong>URL Parameters</strong>
    </td>
	</tr>
	<tr>
		<td style="text-align:right;width:15%">Endpoint</td>
		<td colspan="2" style="width:30%">
      <a href="https://docs.quable.com/reference/put_documents-code"><code>/documents/{{code}}</code></a><br /><br /><strong>Note</strong>: <code>{{code}}</code> is the current unique code of the document to update.
    </td>
		<td>API v4 endpoint</td>
	</tr>
	<tr>
		<td style="text-align:right">HTTP Method</td>
		<td colspan="2"><code>PUT</code></td>
		<td> </td>
	</tr>
	<tr>
		<td colspan="4" style="background: #F8F8F8">
      <strong>Request Body</strong>
    </td>
	</tr>
	<tr>
		<td style="text-align:right;width:15%">Required Attributes</td>
		<td style="width:30%"><code>code</code></td>
		<td>string </td>
		<td>The new unique code of the document to be set.</td>
	</tr>
</table>
`}</HTMLBlock>

#### Example

Here's an example where the document's unique code is changed from *foo* to *bar*.

```python Update code
import requests
url= "https://{{YOUR-PIM}}.quable.com.quable.com/api_1.php/documents/foo"
payload={
    "code" : "bar"
}
headers= {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer ...'
}
response= requests.request("PUT", url, headers=headers, data=payload)
```

The JSON response to a successful request includes:

<HTMLBlock>{`
<table>
	<tr>
		<td colspan="4" style="background: #F8F8F8">
      <strong>Response Header</strong>
    </td>
	</tr>
	<tr>
		<td><a href="https://docs.quable.com/reference/error-codes#2xx-codes">HTTP Response Code</a></td>
		<td><code>200</code> </td>
		<td>integer</td>
		<td>The request was successful.</td>
	</tr>
	<tr>
		<td colspan="4" style="background: #F8F8F8">
      <strong>Response Body</strong>
    </td>
	</tr>
	<tr>
		<td></td>
		<td><code>location</code></td>
		<td>string</td>
		<td>The API URL of the document.</td>
	</tr>
	<tr>
		<td></td>
		<td><code>code</code></td>
		<td>string</td>
		<td> The new unique code of the document.</td>
	</tr>
	<tr>
		<td></td>
		<td><code>document_type_code</code> </td>
		<td>string</td>
		<td> The code of the document's type.</td>
	</tr>
	<tr>
		<td></td>
		<td><code>success</code> </td>
		<td>boolean</td>
		<td><em>True</em> if everything is ok, else <em>False</em>.</td>
	</tr>
	<tr>
		<td></td>
		<td><code>warnings</code> </td>
		<td>array(string)</td>
		<td> An array of warnings about the request payload.</td>
	</tr>
</table>
`}</HTMLBlock>

#### Example

```json
{
    "success": true,
    "code": "bar",
    "active": true,
    "attribute_set_code": null,
    "document_type_code": "postman_automation",
    "location": "/documents/bar",
    "warnings": []
}
```