# Recalculate report

- Operation ID: `analytics2-recalculate-report`
- HTTP method: `POST`
- Path: `/analytics/analytics/v4/reports/{AnalysisId}/recalculate`
- [Human-readable API reference](https://hub.synerise.com/api-reference/analytics-suite#tag/Analytics:-Reports/operation/analytics2-recalculate-report)

## 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:
  /analytics/analytics/v4/reports/{AnalysisId}/recalculate:
    post:
      tags:
        - "Analytics: Reports"
      summary: Recalculate report
      description: |
        Retrieve the results of a previously-created report.

        ---

        **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:** `ANALYTICS_BACKEND_REPORT_READ`

        **User role permission required:** `analytics: read`
      operationId: analytics2-recalculate-report
      parameters:
        - name: AnalysisId
          in: path
          description: UUID of the analysis
          required: true
          style: simple
          explode: false
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Report calculation result
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    description: Calculation results. Each object in this array corresponds to one metric included in the report. The Synerise Web UI currently only supports single-metric reports.
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: Unique ID of the resource
                        columnName:
                          type: string
                          description: |
                            Column header for this metric. Uses the per-metric `columnName` from the report
                            definition when set; otherwise falls back to the underlying metric's title.
                        values:
                          type: array
                          description: |
                            
                            An array of results for each grouping.

                            Note that `values` is a single-item array of arrays.

                            **Example**: if the dimensions of your report are _firstname_ and _title_ in a page visit event, this may be the result:

                            ```json
                            "values": [
                              [
                                {
                                  "name": [
                                    "John",
                                    "Discounted Product Page"
                                  ],
                                  "value": 26.0
                                },
                                {
                                  "name": [
                                    "Steve",
                                    "Discounted Product Page"
                                  ],
                                  "value": 12.0
                                },
                                {
                                  "name": [
                                    "Steve",
                                    "New product pre-order"
                                  ],
                                  "value": 117.0
                                }
                              ]
                            ]
                            ```

                            This means that 26 profiles named John visited a page titled "Discounted Product Page". The same page was visited by 12 profiles named Steve. Profiles named Steve visited "New product pre-order" page 117 times.
                          items:
                            type: array
                            items:
                              type: object
                              properties:
                                name:
                                  type: array
                                  description: Parameter values
                                  items:
                                    anyOf:
                                      - type: string
                                      - type: number
                                value:
                                  type: number
                                  description: The number of occurrences of the combination defined in `name`
                                  format: double
                              required:
                                - name
                                - value
                        groups:
                          type: array
                          description: A list of parameters that were used for creating dimensions (grouping)
                          items:
                            type: string
                      required:
                        - columnName
                        - groups
                        - id
                        - values
                required:
                  - data
        4XX:
          description: See error message for details
          content:
            application/json:
              schema:
                allOf:
                  - type: object
                    properties:
                      source:
                        type: object
                        nullable: true
                        description: Information about a parameter that caused the error, if applicable.
                        properties:
                          pointer:
                            type: string
                            description: Information about a parameter
                          value:
                            type: string
                            nullable: true
                            description: Currently unused
                      errors:
                        type: array
                        description: An array of errors, if applicable
                        items:
                          type: object
                          properties:
                            timestamp:
                              type: string
                              format: date-time
                              description: Time when the error occurred
                            errorCode:
                              type: string
                              description: Code of the error, needed for troubleshooting. See [https://developers.synerise.com/errors.html](https://developers.synerise.com/errors.html).
                            httpStatus:
                              type: integer
                              description: HTTP status code
                            message:
                              type: string
                              description: Description of the problem
                            traceId:
                              type: string
                              description: Currently unused
                              nullable: true
                            help:
                              type: string
                              nullable: true
                              description: Currently unused
                  - type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Time when the error occurred
                      errorCode:
                        type: string
                        description: Code of the error, needed for troubleshooting. See [https://developers.synerise.com/errors.html](https://developers.synerise.com/errors.html).
                      httpStatus:
                        type: integer
                        description: HTTP status code
                      message:
                        type: string
                        description: Description of the problem
                      traceId:
                        type: string
                        description: Currently unused
                        nullable: true
                      help:
                        type: string
                        nullable: true
                        description: Currently unused
        5XX:
          description: See error message for details
          content:
            application/json:
              schema:
                allOf:
                  - type: object
                    properties:
                      source:
                        type: object
                        nullable: true
                        description: Information about a parameter that caused the error, if applicable.
                        properties:
                          pointer:
                            type: string
                            description: Information about a parameter
                          value:
                            type: string
                            nullable: true
                            description: Currently unused
                      errors:
                        type: array
                        description: An array of errors, if applicable
                        items:
                          type: object
                          properties:
                            timestamp:
                              type: string
                              format: date-time
                              description: Time when the error occurred
                            errorCode:
                              type: string
                              description: Code of the error, needed for troubleshooting. See [https://developers.synerise.com/errors.html](https://developers.synerise.com/errors.html).
                            httpStatus:
                              type: integer
                              description: HTTP status code
                            message:
                              type: string
                              description: Description of the problem
                            traceId:
                              type: string
                              description: Currently unused
                              nullable: true
                            help:
                              type: string
                              nullable: true
                              description: Currently unused
                  - type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Time when the error occurred
                      errorCode:
                        type: string
                        description: Code of the error, needed for troubleshooting. See [https://developers.synerise.com/errors.html](https://developers.synerise.com/errors.html).
                      httpStatus:
                        type: integer
                        description: HTTP status code
                      message:
                        type: string
                        description: Description of the problem
                      traceId:
                        type: string
                        description: Currently unused
                        nullable: true
                      help:
                        type: string
                        nullable: true
                        description: Currently unused
      security:
        - JWT: []
      x-snr-doc-urls:
        - /api-reference/analytics-suite#tag/Analytics:-Reports/operation/analytics2-recalculate-report
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: |-
            curl --request POST \
              --url https://api.synerise.com/analytics/analytics/v4/reports/%7BAnalysisId%7D/recalculate \
              --header 'Authorization: Bearer REPLACE_BEARER_TOKEN'
        - lang: Python
          label: Python
          source: |-
            import http.client

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

            headers = { 'Authorization': "Bearer REPLACE_BEARER_TOKEN" }

            conn.request("POST", "/analytics/analytics/v4/reports/%7BAnalysisId%7D/recalculate", headers=headers)

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

            print(data.decode("utf-8"))
        - lang: JavaScript
          label: JavaScript
          source: |-
            const data = 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/analytics/analytics/v4/reports/%7BAnalysisId%7D/recalculate");
            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": "/analytics/analytics/v4/reports/%7BAnalysisId%7D/recalculate",
              "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.end();
        - lang: PHP
          label: PHP
          source: |-
            <?php

            $request = new HttpRequest();
            $request->setUrl('https://api.synerise.com/analytics/analytics/v4/reports/%7BAnalysisId%7D/recalculate');
            $request->setMethod(HTTP_METH_POST);

            $request->setHeaders([
              'Authorization' => 'Bearer REPLACE_BEARER_TOKEN'
            ]);

            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/analytics/analytics/v4/reports/%7BAnalysisId%7D/recalculate")
              .header("Authorization", "Bearer REPLACE_BEARER_TOKEN")
              .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: "Analytics: Reports"
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.
````
