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

# Create Table

> # Description

Create a new pivot table

# Payload

```json
{
    "projectId": string,
    "name": string,
    "selectedChart": string,
    "values": array,
    "alphaValue": number
}
```

where:

* `projectId`: Project identifier. __(Required)__.
* `name`: Selected name for the pivot table.
* `selectedChart`: Type of table selected.
* `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.

### Values
Array of objects, each one representing a value format to present in each cell in the table. They have 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
{
  "_id": string,
  "projectId": string,
  "name": string,
  "selectedChart": string,
  "rows": array,
  "columns": array,
  "values": array,
  "alphaValue": number,
  "updatedAt": string,
  "createdAt": string,
  "createdBy": string,
  "updatedBy": string,
}
```

## 401 Unauthorized
> Invalid authorization.

## 404 Not Found
> Resource not found.

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

# Description

Create a new pivot table

# Payload

```json theme={null}
{
    "projectId": string,
    "name": string,
    "selectedChart": string,
    "values": array,
    "alphaValue": number
}
```

where:

* `projectId`: Project identifier. **(Required)**.
* `name`: Selected name for the pivot table.
* `selectedChart`: Type of table selected.
* `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.

### Values

Array of objects, each one representing a value format to present in each cell in the table. They have 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}
{
  "_id": string,
  "projectId": string,
  "name": string,
  "selectedChart": string,
  "rows": array,
  "columns": array,
  "values": array,
  "alphaValue": number,
  "updatedAt": string,
  "createdAt": string,
  "createdBy": string,
  "updatedBy": string,
}
```

## 401 Unauthorized

> Invalid authorization.

## 404 Not Found

> Resource not found.

## 500 Internal Server Error

> Error occurred in the service.


## OpenAPI

````yaml POST /v1/pivotTable/create
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/create:
    post:
      summary: Create Table
      description: >-
        # Description


        Create a new pivot table


        # Payload


        ```json

        {
            "projectId": string,
            "name": string,
            "selectedChart": string,
            "values": array,
            "alphaValue": number
        }

        ```


        where:


        * `projectId`: Project identifier. __(Required)__.

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

        * `selectedChart`: Type of table selected.

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


        ### Values

        Array of objects, each one representing a value format to present in
        each cell in the table. They have 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

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

        ```


        ## 401 Unauthorized

        > Invalid authorization.


        ## 404 Not Found

        > Resource not found.


        ## 500 Internal Server Error

        > Error occurred in the service.
      operationId: create-table-post-v1-pivottable-create
      parameters:
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
            example:
              projectId: '{{projectId}}'
              name: Test
              selectedChart: BANNER_CROSSTAB
              rows: []
              columns: []
              values:
                - frontendId: 1628716597272
                  aggregationType: 1
                  valueType: count
                  formatType: both
                  color: black
              alphaValue: 5
      responses:
        '200':
          description: Create Table
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
              example:
                _id: 6137ecaa37cb8f00aebb13cd
                projectId: 60de2ba329a7230061e209f6
                name: Test
                selectedChart: BANNER_CROSSTAB
                rows: []
                columns: []
                values:
                  - frontendId: 1628716597272
                    aggregationType: 1
                    valueType: count
                    formatType: both
                    color: black
                alphaValue: 5
                updatedAt: '2021-09-07T22:50:18.655Z'
                createdAt: '2021-09-07T22:50:18.655Z'
                createdBy: 5e1155a9091833000f274bbd
                updatedBy: 5e1155a9091833000f274bbd
                __v: 0
        '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.

````