Skip to main content

Interacting with forms and files

Within Easy PV and Heatpunk, users complete forms and generate PDF reports. In your application you may want to view the completed files and forms associated with a project, and fetch completed form data and PDF documents.

To list forms for a project:

To get a list completed forms for a project, use the /api/v1/projects/forms/list endpoint. Provide projectId and ownerEmail as GET parameters. ownerEmail is necessary as the API key is shared amongst all members of your team, but projects aren't necessarily shared with all members of the team. When we receive the request we will check if the given email has the right to access the project.

curl -X 'GET' \
      'https://sandbox.heatpunk.co.uk/api/v1/projects/forms/list?projectId=872034&ownerEmail=sales%40midsummerenergy.co.uk' \
      -H 'accept: application/json' \ 
      -H 'X-API-KEY: ---KEY---'

This should return an object with completed forms and surveys.

{
    "forms": [
        {
            "id": "customerProposal"
        },
        {
            "id": "enaConnect"
        },
        {
            "id": "f08_v2"
        },
        {
            "id": "g99_50kw"
        },
        {
            "id": "scaffoldingRequest"
        },
        {
            "id": "g98"
        },
        {
            "id": "g99_A1_1"
        },
        {
            "id": "g99_A1_2"
        },
        {
            "id": "letterOfConsent"
        },
        {
            "id": "install_record"
        },
        {
            "id": "g99_A3_1"
        },
        {
            "id": "g99_A3_2"
        }
    ],
    "surveys": [
        {
            "id": "survey"
        }
    ]
}

To retrieve form fields:

Use /api/v1/projects/forms/form.

You will need to provide the ID of the project, ID of the form (from the response above), and the ownerEmail. Here's an example:

curl -X 'GET' \
    'https://sandbox.heatpunk.co.uk/api/v1/projects/forms/form?projectId=872034&form=letterOfConsent&ownerEmail=andy%40midsummerenergy.co.uk&formCategory=forms' \
    -H 'accept: application/json' \
    -H 'X-API-KEY:  ---KEY---'
To list files saved to a project:

Use /api/v1/projects/files/list. Set the type property to projects, and provide the ID of the project and the ownerEmail as before. Files saved within Easy-PV are listed within the fileRegistry.uploads array of the response.

curl -X 'GET' \
    'https://sandbox.heatpunk.co.uk/api/v1/files/list?type=projects&id=872034&ownerEmail=andy%40midsummerenergy.co.uk' \
    -H 'accept: application/json' \
    -H 'X-API-KEY: ---KEY---'
To download a file:

Use /api/v1/files/file.

Provide the same details as the previous request, plus the file category (uploads) and the file name.

curl -X 'GET' \
    'https://sandbox.heatpunk.co.uk/api/v1/files/file?type=projects&id=872034&ownerEmail=andy%40midsummerenergy.co.uk&fileCategory=uploads&file=test%20project%20%20letter%20of%20consent~Letter%20of%20Consent.pdf&responseFormat=b64' \
    -H 'accept: application/json' \
    -H 'X-API-KEY: ---KEY---'

Setting responseFormat to either b64 or meta will include a meta object in the response. This includes a datetime string for when the file was created and last updated. b64 will also return the document as a base64-encoded string in the response. raw will just return the file as stored.