> ## Documentation Index
> Fetch the complete documentation index at: https://docs.repdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Pivot Table

> # Description

Update a pivot table

# Payload

```json
{
    "_id": string,
    "projectId": string,
    "name": string,
    "selectedChart": string,
    "rows": array,
    "columns": array,
    "values": array,
    "alphaValue": number,
    "displayNullData": boolean
}
```

where:

* `_id`: Id of the table to update __(Required)__.
* `projectId`: Project identifier to which the pivot table was created. __(Required)__.
* `name`: Selected name for the pivot table.
* `selectedChart`: Type of table selected.
* `rows`: Array of objects, each one representing a question selected as row for the table.
* `columns`: Array of objects, each one representing a question selected as column for the table.
* `values`: Array of objects, each one representing a value format to present in each cell in the table.
* `alphaValue`: Alpha value used for significance testing.
* `displayNullData`: Whether to display or hide null data from the table

### Rows
Array of objects, each one representing a question selected as row for the table.
Has the following structure:

```json
{
  "frontendId": number,
  "questionId": string
}
```
where:
* `frontendId`: An id to identify the question in the frontend
* `questionId`: Id of the question in the server

### Columns
Array of objects, each one representing a question selected as column for the table.
Has the following structure:

```json
{
  "frontendId": number,
  "questionId": string
}
```
where:
* `frontendId`: An id to identify the question in the frontend
* `questionId`: Id of the question in the server

### Values
Array of objects, each one representing a value format to present in each cell in the table
Has the following structure:

```json
{
  "frontendId": number,
  "aggregationType": number,
  "valueType": string,
  "formatType": string,
  "color": string
}
```
where:
* `frontendId`: An id to identify the question in the frontend
* `aggregationType`: Type of aggregator format for the value. Could be:
  * 1: count
  * 2: min
  * 3: max
  * 4: sum
  * 5: average
* `valueType`: Could be count or byQuestion
* `formatType`: Represents the format in which the value will be presented on the table. Could be:
  * frecuency
  * percentage
  * both
* `color`: Color of the value on the table.


# Response 

## 200 OK

```json
{
    "nModified": number,
}
```

where:

* `nModified`: Number of records modified.


## 401 Unauthorized
> Invalid authorization.

## 404 Not Found
> Resource not found.

## 500 Internal Server Error
> Error occurred in the service.

# Description

Update a pivot table

# Payload

```json theme={null}
{
    "_id": string,
    "projectId": string,
    "name": string,
    "selectedChart": string,
    "rows": array,
    "columns": array,
    "values": array,
    "alphaValue": number,
    "displayNullData": boolean
}
```

where:

* `_id`: Id of the table to update **(Required)**.
* `projectId`: Project identifier to which the pivot table was created. **(Required)**.
* `name`: Selected name for the pivot table.
* `selectedChart`: Type of table selected.
* `rows`: Array of objects, each one representing a question selected as row for the table.
* `columns`: Array of objects, each one representing a question selected as column for the table.
* `values`: Array of objects, each one representing a value format to present in each cell in the table.
* `alphaValue`: Alpha value used for significance testing.
* `displayNullData`: Whether to display or hide null data from the table

### Rows

Array of objects, each one representing a question selected as row for the table.
Has the following structure:

```json theme={null}
{
  "frontendId": number,
  "questionId": string
}
```

where:

* `frontendId`: An id to identify the question in the frontend
* `questionId`: Id of the question in the server

### Columns

Array of objects, each one representing a question selected as column for the table.
Has the following structure:

```json theme={null}
{
  "frontendId": number,
  "questionId": string
}
```

where:

* `frontendId`: An id to identify the question in the frontend
* `questionId`: Id of the question in the server

### Values

Array of objects, each one representing a value format to present in each cell in the table
Has the following structure:

```json theme={null}
{
  "frontendId": number,
  "aggregationType": number,
  "valueType": string,
  "formatType": string,
  "color": string
}
```

where:

* `frontendId`: An id to identify the question in the frontend
* `aggregationType`: Type of aggregator format for the value. Could be:
  * 1: count
  * 2: min
  * 3: max
  * 4: sum
  * 5: average
* `valueType`: Could be count or byQuestion
* `formatType`: Represents the format in which the value will be presented on the table. Could be:
  * frecuency
  * percentage
  * both
* `color`: Color of the value on the table.

# Response

## 200 OK

```json theme={null}
{
    "nModified": number,
}
```

where:

* `nModified`: Number of records modified.

## 401 Unauthorized

> Invalid authorization.

## 404 Not Found

> Resource not found.

## 500 Internal Server Error

> Error occurred in the service.


## OpenAPI

````yaml POST /v1/pivotTable/update/{pivotTableId}
openapi: 3.0.3
info:
  title: SightX API
  version: 1.0.0
  description: >-
    SightX REST API documentation. Most responses are JSON; some export
    endpoints return files. API access is a paid add-on — contact
    sales@sightx.io for details.
servers:
  - url: https://auth.admin.sightx.io
    description: Authentication (Production)
  - url: https://auth.staging-admin.sightx.io
    description: Authentication (Staging)
security:
  - AuthorizationHeader: []
paths:
  /v1/pivotTable/update/{pivotTableId}:
    post:
      summary: Update Pivot Table
      description: >-
        # Description


        Update a pivot table


        # Payload


        ```json

        {
            "_id": string,
            "projectId": string,
            "name": string,
            "selectedChart": string,
            "rows": array,
            "columns": array,
            "values": array,
            "alphaValue": number,
            "displayNullData": boolean
        }

        ```


        where:


        * `_id`: Id of the table to update __(Required)__.

        * `projectId`: Project identifier to which the pivot table was created.
        __(Required)__.

        * `name`: Selected name for the pivot table.

        * `selectedChart`: Type of table selected.

        * `rows`: Array of objects, each one representing a question selected as
        row for the table.

        * `columns`: Array of objects, each one representing a question selected
        as column for the table.

        * `values`: Array of objects, each one representing a value format to
        present in each cell in the table.

        * `alphaValue`: Alpha value used for significance testing.

        * `displayNullData`: Whether to display or hide null data from the table


        ### Rows

        Array of objects, each one representing a question selected as row for
        the table.

        Has the following structure:


        ```json

        {
          "frontendId": number,
          "questionId": string
        }

        ```

        where:

        * `frontendId`: An id to identify the question in the frontend

        * `questionId`: Id of the question in the server


        ### Columns

        Array of objects, each one representing a question selected as column
        for the table.

        Has the following structure:


        ```json

        {
          "frontendId": number,
          "questionId": string
        }

        ```

        where:

        * `frontendId`: An id to identify the question in the frontend

        * `questionId`: Id of the question in the server


        ### Values

        Array of objects, each one representing a value format to present in
        each cell in the table

        Has the following structure:


        ```json

        {
          "frontendId": number,
          "aggregationType": number,
          "valueType": string,
          "formatType": string,
          "color": string
        }

        ```

        where:

        * `frontendId`: An id to identify the question in the frontend

        * `aggregationType`: Type of aggregator format for the value. Could be:
          * 1: count
          * 2: min
          * 3: max
          * 4: sum
          * 5: average
        * `valueType`: Could be count or byQuestion

        * `formatType`: Represents the format in which the value will be
        presented on the table. Could be:
          * frecuency
          * percentage
          * both
        * `color`: Color of the value on the table.



        # Response 


        ## 200 OK


        ```json

        {
            "nModified": number,
        }

        ```


        where:


        * `nModified`: Number of records modified.



        ## 401 Unauthorized

        > Invalid authorization.


        ## 404 Not Found

        > Resource not found.


        ## 500 Internal Server Error

        > Error occurred in the service.
      operationId: update-pivot-table-post-v1-pivottable-update-pivottableid
      parameters:
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
            example:
              _id: '{{pivotTableId}}'
              projectId: '{{projectId}}'
              name: ''
              selectedChart: ''
              rows:
                - frontendId: 1
                  questionId: ''
              columns:
                - frontendId: 1
                  questionId: ''
              values:
                - frontendId: 1
                  aggregationType: 1
                  valueType: ''
                  formatType: ''
                  color: ''
              alphaValue: 1
              displayNullData: true
      responses:
        '200':
          description: Update Pivot Table
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
              example:
                'n': 1
                nModified: 1
                opTime:
                  ts: '7005328587351916545'
                  t: 41
                electionId: 7fffffff0000000000000029
                ok: 1
                operationTime: '7005328587351916545'
                $clusterTime:
                  clusterTime: '7005328587351916545'
                  signature:
                    hash: JZUvHcXyDqv1ebSOmtluGvL/6EI=
                    keyId: '6972714809024315400'
        '400':
          description: Bad request
        '401':
          description: Unauthorized
        '500':
          description: Internal server error
      servers:
        - url: https://pivot-table.sightx.io
components:
  securitySchemes:
    AuthorizationHeader:
      type: apiKey
      in: header
      name: Authorization
      description: Access token obtained from the m2m-token endpoint.

````