> For the complete documentation index, see [llms.txt](https://photon-commerce.gitbook.io/photon-commerce-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://photon-commerce.gitbook.io/photon-commerce-api/update-doc-v4/update-fields.md).

# Update Fields

Update fields using a PUT request

## Update fields in the JSON document

<mark style="color:orange;">`PUT`</mark> `https://api.photoncommerce.com/api/v4/update`

One can use this request to update the field values extracted by Photon Commerce.&#x20;

#### Path Parameters

| Name        | Type   | Description                               |
| ----------- | ------ | ----------------------------------------- |
| photon\_key | string | The photon key of the json file to update |

#### Headers

| Name          | Type   | Description                                                                                 |
| ------------- | ------ | ------------------------------------------------------------------------------------------- |
| CLIENT-ID     | string | <p>Unique client-id provided during user<br>registration</p>                                |
| AUTHORIZATION | string | Pass your username and unique API key in the form 'apikey \<your-username>:\<your-api-key>' |
| SECRET-KEY    | string | Your secret key as a string                                                                 |
| PASSWORD      | string | Password used during user registration                                                      |
| Content-Type  | string | set to 'application/json'                                                                   |

#### Request Body

| Name | Type   | Description                                                                                                                  |
| ---- | ------ | ---------------------------------------------------------------------------------------------------------------------------- |
| data | string | <p>string of dictionary containing fields to be <br>updated with their corresponding values.<br>e.g '{"Total": 5454.54}'</p> |

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

```
{"message":"Updated successfully","status":"success"}
```

{% endtab %}
{% endtabs %}

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

```
curl -X PUT -H 'Content-Type: application/json' -H "CLIENT-ID:<client-id>" -H "AUTHORIZATION:apikey <username>:<api-key>" -H 'PASSWORD:<password>' -H "SECRET-KEY:<secret-key>" -d '{"Total": 1878.8, "Vendor_Name": "Einsteam"}' "https://api.photoncommerce.com/api/v4/update?photon_key=<the photon key>"
```

{% endtab %}

{% tab title="Python" %}

```
import requests

headers = {
    'Content-Type': 'application/json',
    'CLIENT-ID': '<client-id>',
    'AUTHORIZATION': 'apikey <username>:<api-key>',
    'PASSWORD': '<password>',
    'SECRET-KEY': '<secret-key>',
}

params = (
    ('photon_key', '<the photon key>'),
)

data = '{"Total": 1878.8, "Vendor_Name": "Einsteam"}'

response = requests.put('https://api.photoncommerce.com/api/v4/update', headers=headers, params=params, data=data)
```

{% endtab %}

{% tab title="NodeJS" %}

```
var request = require('request');

var headers = {
    'Content-Type': 'application/json',
    'CLIENT-ID': '<client-id>',
    'AUTHORIZATION': 'apikey <username>:<api-key>',
    'PASSWORD': '<password>',
    'SECRET-KEY': '<secret-key>'
};

var dataString = '{"Total": 1878.8, "Vendor_Name": "Einsteam"}';

var options = {
    url: 'https://api.photoncommerce.com/api/v4/update?photon_key=<the photon key>',
    method: 'PUT',
    headers: headers,
    body: dataString
};

function callback(error, response, body) {
    if (!error && response.statusCode == 200) {
        console.log(body);
    }
}

request(options, callback);
```

{% endtab %}

{% tab title="Java" %}

```
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {
		URL url = new URL("https://api.photoncommerce.com/api/v4/update?photon_key=<the photon key>");
		HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
		httpConn.setRequestMethod("PUT");

		httpConn.setRequestProperty("Content-Type", "application/json");
		httpConn.setRequestProperty("CLIENT-ID", "<client-id>");
		httpConn.setRequestProperty("AUTHORIZATION", "apikey <username>:<api-key>");
		httpConn.setRequestProperty("PASSWORD", "<password>");
		httpConn.setRequestProperty("SECRET-KEY", "<secret-key>");

		httpConn.setDoOutput(true);
		OutputStreamWriter writer = new OutputStreamWriter(httpConn.getOutputStream());
		writer.write("{\"Total\": 1878.8, \"Vendor_Name\": \"Einsteam\"}");
		writer.flush();
		writer.close();
		httpConn.getOutputStream().close();

		InputStream responseStream = httpConn.getResponseCode() / 100 == 2
				? httpConn.getInputStream()
				: httpConn.getErrorStream();
		Scanner s = new Scanner(responseStream).useDelimiter("\\A");
		String response = s.hasNext() ? s.next() : "";
		System.out.println(response);
	}
}

```

{% endtab %}
{% endtabs %}

You can update any key field present in the JSON data. While submitting the data for the PUT request, make sure that the datatype of the values are preserved.  The key fields, their description and datatype can be found above under the section 'Capture an invoice or receipt in real time'. \
\
For the example above, the updated JSON will have Total set as 1878.80 and Vendor\_Name set as 'Einsteam'. To verify if the update worked fine, you can use the GET request mentioned above to fetch the JSON and check if the changes have been successfully applied.
