# Update Link Record §

{% hint style="info" %}
This does not actually update a linked record on the blockchain. Blockchain records cannot be changed. Instead, it creates a new linked record that prevents any further updates to the previous linked record, although it can still be queried for its status and content. Each linked record can only be updated once. To update the new linked record, a further new linked record must be created using the returned location of this linked record.
{% endhint %}

{% hint style="warning" %}
The record will be submitted to the blockchain asynchronously. You should use GET Location Status to find out whether the record has been confirmed before performing any other operations on the returned location.
{% endhint %}

<figure><img src="/files/XfRzaW7NRLiV9Y5RRUoF" alt="" width="375"><figcaption></figcaption></figure>

## Update **Encoded** Link

1. The record owner selects any encoders (usually the same ones as previously used) and salt to use
2. The record owner updates a link record via Event
3. Event encodes the record as specified to produce a fingerprint
4. The fingerprint is written to the blockchain, updating the previous link location
5. The result is the new fingerprint and its new link location on the blockchain
6. The record owner stores the new salt, fingerprint and location for later processing
7. Any number of updates can be performed

#### Example code:

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X POST "$URL/api/v1/linkedrecords/$LOC/update?encode=SHA256(01-02T13.14.15)|Base64" \
     -H "x-api-key: $KEY" \
     -H "accept: text/plain" \
     -H "Content-Type: application/octet-stream" \
     --data-binary "hello world"
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const response = await fetch('${url}/api/v1/linkedrecords/${loc}/update?encode=SHA256(01-02T13.14.15)|Base64', {
  method: 'POST',
  headers: {
    'x-api-key': '${key}',
    'accept': 'text/plain',
    'Content-Type': 'application/octet-stream'
  },
  body: 'hello world'
});
```

{% endtab %}
{% endtabs %}

#### Example cURL response:

```json
{
  "txId": "7a22816fb63eff1....2377922ab58bdc2c2c13",
  "encoding" : [ 
    { "content-type": "…|Base64", "output" : "GDa1G3wEWsx4....y3RufuSXsARdiK8Wg=" }
  ]
  ...
}
```

The final "output" shows the record that was written to the blockchain.

## Update **Unencoded** Link ‡

1. The record owner updates the previous link location with a new record via Event
2. The result is the new link Location of the new record on the blockchain
3. The record owner stores the new link Location for later processing&#x20;
4. Any number of updates may be performed&#x20;
5. Ideally, the record owner should check the status of the new link location

#### **Example** **code:**

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X POST $URL/api/v1/linkedrecords/$LOC/update \
     -H "x-api-key: $KEY" \
     -H "accept: text/plain" \
     -H "Content-Type: application/octet-stream" \
     --data-binary "hello world"
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const response = await fetch('${url}/api/v1/linkedrecords/${loc}/update', {
  method: 'POST',
  headers: {
    'x-api-key': '${key}',
    'accept': 'text/plain',
    'Content-Type': 'application/octet-stream'
  },
  body: 'hello world'
});
```

{% endtab %}
{% endtabs %}

#### **Example** cURL **response:**

```json
{
  "txId": "4674e3fc20a708dc....c32b37c76b724db48",
  ...
}
```

## **Extract Location**

At least the location (shown as "txId") should be stored for subsequent operations:

{% tabs %}
{% tab title="cURL" %}

```bash
LOC1=$LOC
LOC=4674e3fc20a708dc....c32b37c76b724db848
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const data = await response.json();
const loc1 = data.txId;
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.teranode.group/nchain-event/linked-records/api-workflow/update-link-record.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
