> ## 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.

# Get All By Project

> # Description

Get a list of all pivot tables related to the selected project.

# Payload

```json
{
    "projectId": string
}
```

where:

* `projectId`: Project identifier to search for its pivot tables. __(Required)__.

# Response 

## 200 OK

```json
{
  "docs": array,
  "total": number,
  "limit": number,
  "page": number,
  "pages": number
}
```
where:

* `docs`: Array of objects, each representing a pivot table instance.
* `total`: Total amount of pivot tables the project has.
* `limit`: Number of pivot tables shown per page.
* `page`: Current page for fetching the pivot tables.
* `pages`: Total number of pages.

### Docs
Array of objects, each one represents an instance of a pivot table with the following structure:

```json
{
  "_id": string,
  "projectId": string,
  "name": string,
  "selectedChart": string,
  "rows": array,
  "columns": array,
  "values": array,
  "alphaValue": number,
  "updatedAt": string,
  "createdAt": string,
  "createdBy": string,
  "updatedBy": string,
}
```
where:

* `_id`: Id of the pivot table.
* `projectId`: Id of the project this pivot table instance belongs to.
* `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.
* `updatedAt`: Date of the last update.
* `createdAt`: Date of creation of the pivot table.
* `createdBy`: Id of the user who created the table.
* `updatedBy`: Id of the last user to update 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.

## 401 Unauthorized
> Invalid authorization.

## 404 Not Found
> Resource not found.

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

# Description

Get a list of all pivot tables related to the selected project.

# Payload

```json theme={null}
{
    "projectId": string
}
```

where:

* `projectId`: Project identifier to search for its pivot tables. **(Required)**.

# Response

## 200 OK

```json theme={null}
{
  "docs": array,
  "total": number,
  "limit": number,
  "page": number,
  "pages": number
}
```

where:

* `docs`: Array of objects, each representing a pivot table instance.
* `total`: Total amount of pivot tables the project has.
* `limit`: Number of pivot tables shown per page.
* `page`: Current page for fetching the pivot tables.
* `pages`: Total number of pages.

### Docs

Array of objects, each one represents an instance of a pivot table with the following structure:

```json theme={null}
{
  "_id": string,
  "projectId": string,
  "name": string,
  "selectedChart": string,
  "rows": array,
  "columns": array,
  "values": array,
  "alphaValue": number,
  "updatedAt": string,
  "createdAt": string,
  "createdBy": string,
  "updatedBy": string,
}
```

where:

* `_id`: Id of the pivot table.
* `projectId`: Id of the project this pivot table instance belongs to.
* `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.
* `updatedAt`: Date of the last update.
* `createdAt`: Date of creation of the pivot table.
* `createdBy`: Id of the user who created the table.
* `updatedBy`: Id of the last user to update 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.

## 401 Unauthorized

> Invalid authorization.

## 404 Not Found

> Resource not found.

## 500 Internal Server Error

> Error occurred in the service.


## OpenAPI

````yaml POST /v1/pivotTable/getAllByProject
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/getAllByProject:
    post:
      summary: Get All By Project
      description: >-
        # Description


        Get a list of all pivot tables related to the selected project.


        # Payload


        ```json

        {
            "projectId": string
        }

        ```


        where:


        * `projectId`: Project identifier to search for its pivot tables.
        __(Required)__.


        # Response 


        ## 200 OK


        ```json

        {
          "docs": array,
          "total": number,
          "limit": number,
          "page": number,
          "pages": number
        }

        ```

        where:


        * `docs`: Array of objects, each representing a pivot table instance.

        * `total`: Total amount of pivot tables the project has.

        * `limit`: Number of pivot tables shown per page.

        * `page`: Current page for fetching the pivot tables.

        * `pages`: Total number of pages.


        ### Docs

        Array of objects, each one represents an instance of a pivot table with
        the following structure:


        ```json

        {
          "_id": string,
          "projectId": string,
          "name": string,
          "selectedChart": string,
          "rows": array,
          "columns": array,
          "values": array,
          "alphaValue": number,
          "updatedAt": string,
          "createdAt": string,
          "createdBy": string,
          "updatedBy": string,
        }

        ```

        where:


        * `_id`: Id of the pivot table.

        * `projectId`: Id of the project this pivot table instance belongs to.

        * `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.

        * `updatedAt`: Date of the last update.

        * `createdAt`: Date of creation of the pivot table.

        * `createdBy`: Id of the user who created the table.

        * `updatedBy`: Id of the last user to update 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.


        ## 401 Unauthorized

        > Invalid authorization.


        ## 404 Not Found

        > Resource not found.


        ## 500 Internal Server Error

        > Error occurred in the service.
      operationId: get-all-by-project-post-v1-pivottable-getallbyproject
      parameters:
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
            example:
              projectId: '{{projectId}}'
      responses:
        '200':
          description: Get All By Project
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
              example:
                docs:
                  - _id: 60df6eb0e6d9b501986730e8
                    projectId: 60de2ba329a7230061e209f6
                    name: Mi primera pivot
                    selectedChart: BANNER_CROSSTAB
                    rows: []
                    columns: []
                    values:
                      - frontendId: 1625255600208
                        aggregationType: 1
                        valueType: count
                        formatType: both
                        color: black
                    alphaValue: 5
                    updatedAt: '2021-07-02T19:53:20.541Z'
                    createdAt: '2021-07-02T19:53:20.541Z'
                    createdBy: 6086f6f00eda0e001cbe6987
                    updatedBy: 6086f6f00eda0e001cbe6987
                    __v: 0
                total: 1
                limit: 100
                page: 1
                pages: 1
        '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.

````