# Add items from CSV

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

## 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/upload:
    post:
      tags:
        - Catalogs
      summary: Add items from CSV
      description: |
        Upload items to a catalog from a CSV file

        ---

        **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: uploadItems
      security:
        - JWT: []
      parameters:
        - in: path
          name: catalogId
          description: ID of the catalog
          required: true
          schema:
            type: integer
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                itemKey:
                  description: The name of the CSV column that contains unique identifiers. Slashes (`/`) are not allowed in the identifier values.
                  type: string
                file:
                  description: CSV file
                  type: string
                  format: binary
              required:
                - itemKey
                - file
      responses:
        "200":
          description: Upload status
          content:
            application/json:
              schema:
                type: boolean
                description: "`true` when successful"
        "400":
          description: Invalid or insufficient data
          content:
            text/plain:
              schema:
                type: string
        "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/uploadItems
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: |-
            curl --request POST \
              --url https://api.synerise.com/catalogs/bags/%7BcatalogId%7D/items/upload \
              --header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
              --header 'content-type: multipart/form-data' \
              --form itemKey=string \
              --form file=string
        - lang: Python
          label: Python
          source: |-
            import http.client

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

            payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"itemKey\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\nstring\r\n-----011000010111000001101001--\r\n"

            headers = {
                'Authorization': "Bearer REPLACE_BEARER_TOKEN",
                'content-type': "multipart/form-data"
                }

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

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

            print(data.decode("utf-8"))
        - lang: JavaScript
          label: JavaScript
          source: |-
            const data = new FormData();
            data.append("itemKey", "string");
            data.append("file", "string");

            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/upload");
            xhr.setRequestHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN");

            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/upload",
              "headers": {
                "Authorization": "Bearer REPLACE_BEARER_TOKEN"
              }
            };

            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("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"itemKey\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\nstring\r\n-----011000010111000001101001--\r\n");
            req.end();
        - lang: PHP
          label: PHP
          source: "<?php


            $request = new HttpRequest();

            $request->setUrl('https://api.synerise.com/catalogs/bags/%7BcatalogId%7D/items/upload');

            $request->setMethod(HTTP_METH_POST);


            $request->setHeaders([

            \  'Authorization' => 'Bearer REPLACE_BEARER_TOKEN',

            \  'content-type' => 'multipart/form-data'

            ]);


            $request->setBody('-----011000010111000001101001\r

            Content-Disposition: form-data; name=\"itemKey\"\r

            \r

            string\r

            -----011000010111000001101001\r

            Content-Disposition: form-data; name=\"file\"\r

            \r

            string\r

            -----011000010111000001101001--\r

            ');


            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/upload")
              .header("Authorization", "Bearer REPLACE_BEARER_TOKEN")
              .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"itemKey\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\nstring\r\n-----011000010111000001101001--\r\n")
              .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.
```
