# Update single item by database ID

- Operation ID: `updateItem`
- HTTP method: `POST`
- Path: `/catalogs/bags/{catalogId}/items/{itemId}`
- [Human-readable API reference](https://hub.synerise.com/api-reference/data-management#tag/Catalogs/operation/updateItem)

## Self-contained OpenAPI method

The fenced document below contains this method's documentation and all of its local references. It is self-contained; no category or master specification fetch is required.

````yaml
openapi: 3.0.0
info:
  title: Synerise Public API
  version: 1.9.1
paths:
  /catalogs/bags/{catalogId}/items/{itemId}:
    post:
      tags:
        - Catalogs
      summary: Update single item by database ID
      description: |
        Update a single item from a catalog by using the ID of the entry in the Synerise database.

        Update requests are processed according to the time they reach the service.  
        This means that updates from the synchronous `/bags/{catalogId}/items/{itemId}` endpoint may overwrite asynchronous operations (see [`/v1/async/*` endpoints](#operation/updateItemAsync)) which were sent earlier and queued due to high traffic.  
        This behavior also applies to requests from Automation and AI feed synchronization, which use the asynchronous mechanism.


        ---

        **API consumers:** <a href="/api-reference/authorization?tag=Authorization&amp;operationId=userLogin" target="_blank" rel="noopener">Synerise User</a>, <a href="/api-reference/authorization?tag=Authorization&amp;operationId=profileLogin" target="_blank" rel="noopener">Workspace (Business Profile)</a>

        **API key permission required:** `CATALOGS_CATALOG_UPDATE`

        **User role permission required:** `assets_catalogs: update`
      operationId: updateItem
      security:
        - JWT: []
      parameters:
        - in: path
          name: catalogId
          description: ID of the catalog
          required: true
          schema:
            type: integer
        - in: path
          name: itemId
          description: |
            ID of the item. This is the ID of the entry in the Synerise
            database, not the unique identifier that you're using in your
            catalog. The itemId is available in the `id` field of the catalog item when you [retrieve items from a catalog](#operation/getItemsByBag):

            ```
            {
                "creationDate": "2020-09-30T11:31:16.314Z",
                "id": 73753, // this is the itemId
                "itemKey": "uniqueValue",
                "lastModified": null,
                "value": "{\"exampleKey\":\"uniqueValue\",\"exampleKey2\":\"exampleValue\"}",
                "bag": {
                    "author": "authorName",
                    "creationDate": "2020-09-30T10:52:31.264Z",
                    "id": 1053, // this is the ID of the catalog
                    "lastModified": "2020-09-30T11:41:11.808Z",
                    "name": "sampleCatalog"
                }
            },
            ```
          required: true
          schema:
            type: integer
      requestBody:
        description: JSON object with any number of key/value pairs
        content:
          application/json:
            schema:
              type: object
              additionalProperties:
                description: The properties of the catalog item
      responses:
        "200":
          description: A single item
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: Details of the item
                    properties:
                      bag:
                        type: object
                        description: Metadata of the catalog that includes the entry
                        properties:
                          id:
                            type: integer
                            format: int64
                            description: Catalog ID
                          name:
                            type: string
                            description: Catalog name
                          businessProfileId:
                            type: integer
                            description: ID of the Business Profile that contains this catalog
                          author:
                            type: string
                            description: ID of the catalog's creator
                          lastModified:
                            type: string
                            format: date-time
                            description: Last modification date
                          creationDate:
                            format: date-time
                            type: string
                            description: Creation date
                          primaryKey:
                            type: object
                            required:
                              - name
                            properties:
                              name:
                                type: string
                              description:
                                type: string
                          mappings:
                            type: array
                            items:
                              type: object
                              required:
                                - bpActionParamKey
                                - bagId
                                - itemId
                                - action
                                - paramKey
                                - enrichmentFields
                              properties:
                                bpActionParamKey:
                                  type: string
                                bagId:
                                  type: integer
                                  format: int64
                                itemId:
                                  type: integer
                                  format: int64
                                action:
                                  type: string
                                paramKey:
                                  type: string
                                enrichmentFields:
                                  type: array
                                  items:
                                    type: string
                      itemKey:
                        type: string
                        description: They unique value of the item key (for example, an SKU) that was used to upload this entry. This is the `key` query parameter used in [this endpoint](#operation/getItemByKey).
                      id:
                        type: integer
                        format: int64
                        description: ID of the entry. This is the `itemId` used in [this endpoint](#operation/getItem).
                      value:
                        type: string
                        description: Contents of the entry
                        example: '{"Name":"John","Surname":"Doe"}'
                      creationDate:
                        type: string
                        description: Creation date of the entry
                      lastModified:
                        type: string
                        description: Last modified date of the entry
                  metaData:
                    type: object
                    description: This object holds the metadata of the response.
                    properties:
                      totalCount:
                        type: integer
                        description: The total number of matching values (key-value pairs; array items; objects) in the database
                      requestTime:
                        type: string
                        description: The processing time of the request
                        example: 0.11 [s]
        "401":
          description: "Unauthorized: token missing/expired/invalid; invalid API key; etc."
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    description: Status code
                  error:
                    type: string
                    description: Error summary
                  message:
                    type: string
                    description: Error message
                  timestamp:
                    type: string
                    description: Time when the error occurred
        "403":
          description: "Forbidden: insufficient permissions; wrong consumer scope"
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    description: Status code
                  error:
                    type: string
                    description: Error summary
                  message:
                    type: string
                    description: Error message
                  timestamp:
                    type: string
                    description: Time when the error occurred
        "404":
          description: Entity not found
          content:
            text/plain:
              schema:
                type: string
      x-snr-doc-urls:
        - /api-reference/data-management#tag/Catalogs/operation/updateItem
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: |-
            curl --request POST \
              --url https://api.synerise.com/catalogs/bags/%7BcatalogId%7D/items/%7BitemId%7D \
              --header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
              --header 'content-type: application/json' \
              --data '{"property1":null,"property2":null}'
        - lang: Python
          label: Python
          source: |-
            import http.client

            conn = http.client.HTTPSConnection("api.synerise.com")

            payload = "{\"property1\":null,\"property2\":null}"

            headers = {
                'Authorization': "Bearer REPLACE_BEARER_TOKEN",
                'content-type': "application/json"
                }

            conn.request("POST", "/catalogs/bags/%7BcatalogId%7D/items/%7BitemId%7D", payload, headers)

            res = conn.getresponse()
            data = res.read()

            print(data.decode("utf-8"))
        - lang: JavaScript
          label: JavaScript
          source: |-
            const data = JSON.stringify({
              "property1": null,
              "property2": null
            });

            const xhr = new XMLHttpRequest();
            xhr.withCredentials = true;

            xhr.addEventListener("readystatechange", function () {
              if (this.readyState === this.DONE) {
                console.log(this.responseText);
              }
            });

            xhr.open("POST", "https://api.synerise.com/catalogs/bags/%7BcatalogId%7D/items/%7BitemId%7D");
            xhr.setRequestHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN");
            xhr.setRequestHeader("content-type", "application/json");

            xhr.send(data);
        - lang: Node.js
          label: Node.js
          source: |-
            const http = require("https");

            const options = {
              "method": "POST",
              "hostname": "api.synerise.com",
              "port": null,
              "path": "/catalogs/bags/%7BcatalogId%7D/items/%7BitemId%7D",
              "headers": {
                "Authorization": "Bearer REPLACE_BEARER_TOKEN",
                "content-type": "application/json"
              }
            };

            const req = http.request(options, function (res) {
              const chunks = [];

              res.on("data", function (chunk) {
                chunks.push(chunk);
              });

              res.on("end", function () {
                const body = Buffer.concat(chunks);
                console.log(body.toString());
              });
            });

            req.write(JSON.stringify({property1: null, property2: null}));
            req.end();
        - lang: PHP
          label: PHP
          source: |-
            <?php

            $request = new HttpRequest();
            $request->setUrl('https://api.synerise.com/catalogs/bags/%7BcatalogId%7D/items/%7BitemId%7D');
            $request->setMethod(HTTP_METH_POST);

            $request->setHeaders([
              'Authorization' => 'Bearer REPLACE_BEARER_TOKEN',
              'content-type' => 'application/json'
            ]);

            $request->setBody('{"property1":null,"property2":null}');

            try {
              $response = $request->send();

              echo $response->getBody();
            } catch (HttpException $ex) {
              echo $ex;
            }
        - lang: Java
          label: Java
          source: |-
            HttpResponse<String> response = Unirest.post("https://api.synerise.com/catalogs/bags/%7BcatalogId%7D/items/%7BitemId%7D")
              .header("Authorization", "Bearer REPLACE_BEARER_TOKEN")
              .header("content-type", "application/json")
              .body("{\"property1\":null,\"property2\":null}")
              .asString();
servers:
  - description: Microsoft Azure EU
    url: https://api.synerise.com
  - description: Microsoft Azure USA
    url: https://api.azu.synerise.com
  - description: Google Cloud Platform
    url: https://api.geb.synerise.com
tags:
  - name: Catalogs
components:
  securitySchemes:
    JWT:
      type: http
      scheme: bearer
      description: |-
        JWT Bearer token. The header looks like this: `Bearer {JWT}`

        Remember to include the space between 'Bearer' and the token.

        Generate a token via the **Authorization** endpoints.
````
