Skip to content

Reporting (Rapportering)

The reporting module API allows you to programatically schedule reports, see the status of, or retrieve previous reports.

Reporting is done in batches, meaning that one batch can contain one or more reports. Reports are shared across an organization, so any user can access any batch, and they will appear in the the portal for all users.

The output of a generated report is a PDF file, which can be delivered either by email, through a webhook, or by visiting the portal. They can also be retrieved as a downloadable zip-file through the API.

Schedule a report

To schedule a new batch through the API, call the endpoint below with an appropriate JSON message.

POST api.lassox.com/apps/reporting/batches
POST api.lassox.com/apps/reporting/batches

{
  "batchName": "My Batch",
  "format": "{cvr}-{name}-{type}",
  "type": "Revision",
  "notificationEmail": "mail@mail.com",
  "notificationWebhookUrl": "https://myserver.com/reportwebhook",
  "authConfig": null,
  "errorAppend": "#error",
  "scheduledTime": "2018-01-01 01:00:00",
  "items": [
    {
        "cvr": 34580820,
        "format": "1234-{cvr}-{name}",
        "internalCustomerId": 1234
    },
    {
        "cvr": 34580821,
        "format": "4321-{cvr}-{name}",
        "internalCustomerId": 4321
    }
  ],

  "IsListener": false,
  "TriggerNow": false,
}
Click for descriptions of available fields
Field name Required Description Example
batchName The name of the batch My Batch
type The type of report. Choose between: Revision (0), RevisionUdvidet (3), ReelleEjere (2), Finans (1) Revision
format A string to format the name of the individual report. Can include variables: {name}, {balanceday}, {cvr}, {type}, {rundate} {cvr}-{name}-{type}
items A list of items to run reports for. See below fields (items.) for contents of objects.
items.cvr CVR of company to run report for 34580820
items.format An override for format, for instance to include custom data per report. 1234-{cvr}-{name}
items.internalCustomerId A id to include in the start of the filename. Must be an integer. 1234
scheduledTime UTC datetime of when to run the report. 2018-01-01 01:00:00
notificationEmail An email to send each report to. Note that every single item will result in an email. mail@mail.com
notificationWebhookUrl A webhook to send each report to. Note that every single item will result in a webhook call. https://myserver.com/reportwebhook
authConfig An auth configuration for the webhook. See explanation.
errorAppend A string to append to the format of failed reports #error
isListener Whether the batch is a listener batch, which will automatically trigger on changes. Only applicable to listenable reports such as ReelleEjere true
triggerNow Whether the listener batch should also generate a report immediately true

The endpoint returns a batch, which contains an id field, which can be later used to retrieve the batch.

Retrieve reports

All batches can be returned by using the endpoint:

GET api.lassox.com/apps/reporting/batches

While a single batch can be retrieved using the following endpoint:

GET api.lassox.com/apps/reporting/batches/{id}
GET api.lassox.com/apps/reporting/batches/d2e61fbf-7562-4ffb-ba33-52396c0ba12d

Each batch contains many of the fields given on creation, as well as the following:

Field name Description Possible Values
status The status of the batch. Scheduled, Executing, Finished, FinishedWithWarning, FinishedWithErrors, Initializing, Listening, ListeningStopped
batchSize The amount of items in the batch
completionPercentage A double from 0 to 1 indicating completion percentage

To retrieve a list of logs for a batch, use the following endpoint:

GET api.lassox.com/apps/reporting/batches/{id}/items
GET api.lassox.com/apps/reporting/batches/d2e61fbf-7562-4ffb-ba33-52396c0ba12d/items?status=Completed

The endpoint is paged with continuation tokens, so each request will contain a continuationToken, which can be provided to the endpoint using the query parameter cToken to obtain the next page. You can also filter by status, using the values Completed, Failed and Warning as query parameters. Note that the returned items are finished reports, not scheduled reports.

Each item contains a number of fields, most importantly:

Field name Description Possible Values
status The status of the item Completed (0), Warning (1), Failed (2)
pdfurl A direct link to the PDF file
printType Type of report Revision (0), Finans (1), ReelleEjere (2), RevisionUdvidet (3)

Download

Other than downloading each individual report using the pdfurl for each report, it is possible to download all finished reports in a batch in zip format, using the following endpoint:

GET api.lassox.com/apps/reporting/batches/{id}/download
GET api.lassox.com/apps/reporting/batches/d2e61fbf-7562-4ffb-ba33-52396c0ba12d/download

Webhooks

Not sure how webhooks work in Lasso?

This page contains information on webhooks in the reporting module. Check out our Webhook explanation to learn how we use webhooks in general.

If enabled, each finished report will lead to a webhook call containing, amongst other things, a link to the pdf and status of the report. You can receive a dummy request using the endpoints listed below.

Use this endpoint if your endpoint does not require authentication:

GET api/lassox.com/apps/reporting/webhooktest?url={webhookURL}&lassoId={lassoId}&batchId={id}&reportType={type}
GET api/lassox.com/apps/reporting/webhooktest?url=https://myserver.com&lassoId=cvr-1-3580820&batchId=d2e61fbf-7562-4ffb-ba33-52396c0ba12d&reportType=Revision

If your endpoint requires authentication, include an auth configuration, as below.

POST api/lassox.com/apps/reporting/webhooktest?url={webhookURL}&lassoId={lassoId}&batchId={id}&reportType={type}

{
    "Method": "Header",
    "Key": "MyAuthHeader",
    "Value": "AuthKey"
}
POST api/lassox.com/apps/reporting/webhooktest?url=https://myserver.com&lassoId=cvr-1-3580820&batchId=d2e61fbf-7562-4ffb-ba33-52396c0ba12d&reportType=Revision

{
    "Method": "Header",
    "Key": "X-API-KEY",
    "Value": "dm12d82mdlakd2"
}