> For the complete documentation index, see [llms.txt](https://doc.evalytics.nl/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.evalytics.nl/onderdelen/automatic-report-generation.md).

# Automatic report generation

### Webhook settings page

On the webhook settings page you can configure the webhook. These settings include:

* A field where you can configure the webhook
* A method to configure the report settings. This will mirror the report download window.
* A field where you set the api user. To use this function you need to set an api user that has permissions over the entire organisation (on all suborganisations) and is at least functional admin. You have to use this api user to retrieve all the generated reports. For more info an api users see [Authenticatie](/algemeen/authenticatie.md#api-key-aanmaken).
* A field where you can set the moment when report should be created. This can be set to
  * **End evaluation period**: This is when the evaluation closes for the students.&#x20;
  * **End feedback period**: After the users have filled in their feedback.
  * **Start results period**: After the "result are available" notifications have been sent.
    * Please note: When this field is set to **feedback period end** or **start results period,** for any evaluations without these periods no reports will be generated.

### Webhook callback

```json
{
    "reportId": (number),
    "nameReport": (string), 
    "fileType": ("pdf" | "doc" | "xlsx" | "spss" | "zip"),
    "evaluation": {
        "id": (number),
        "externalId": (string),
        "name": (string),
        "type": ("subject" | "exam" | "teacher" | "generic"),
        "topic": {
            "id": (number),
            "name": (string),
            "code": (string),
            "externalId": (string)
        }
    }
}
```

When the `externalId` is turned off, the `externalId` fields will be set to `null`.

### Downloading the report

When the webhook callback has been received the report is ready to be downloaded. This can be done by calling the following API call.&#x20;

## Fetch a report from the webhook&#x20;

<mark style="color:blue;">`GET`</mark> `https://api-portal.evalytics.nl/storedReport/:id/downloadApi`

The file type can be parsed from the Content-Disposition and Content-Type fields in the response header.

#### Path Parameters

| Name                                 | Type   | Description                                                                |
| ------------------------------------ | ------ | -------------------------------------------------------------------------- |
| id<mark style="color:red;">\*</mark> | number | This should be the reportId that has been received in the webhook callback |

{% tabs %}
{% tab title="200: OK The response will contain the file data" %}

{% endtab %}

{% tab title="400: Bad Request The report cannot be found or accessed" %}

{% endtab %}
{% endtabs %}

### Roles

The `downloadApi` call can only be called by api key users who have been granted the role of atleast functional admin for the entire organisation.

### Report expiration

After the report has been created, it will be available for 3 days. After which it will be deleted and will no longer be available.
