> For the complete documentation index, see [llms.txt](https://docs.whitespots.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.whitespots.io/appsec-portal/features/scanners/importing-reports-from-scanners-to-appsec-portal/importing-reports-via-lambda-function-using-a-report-file.md).

# Importing reports via Lambda Function using a Report File

You have the capability to import reports into the AppSec Portal using the provided function below.

<pre class="language-python"><code class="lang-python">import json
import urllib.request
import urllib3


def import_report(&#x3C;<a data-footnote-ref href="#user-content-fn-1">event</a>>):
    
    appsec_portal_api_token = "Token " + &#x3C;<a data-footnote-ref href="#user-content-fn-2">appsec portal api_key></a>
    
    while True:
        try:
            url = 'https://&#x3C;<a data-footnote-ref href="#user-content-fn-2">portal_address</a>>/api/v1/scan/import/'
            body = {
                "file": ("&#x3C;<a data-footnote-ref href="#user-content-fn-1">event</a>>.json", json.dumps(&#x3C;<a data-footnote-ref href="#user-content-fn-1">event</a>>)),
                "product_name": "&#x3C;<a data-footnote-ref href="#user-content-fn-1">product name</a>>",
                "product_type": "&#x3C;<a data-footnote-ref href="#user-content-fn-1">product_type</a>>",
                "scanner_name": "&#x3C;<a data-footnote-ref href="#user-content-fn-1">scanner name</a>>",
                "branch": "<a data-footnote-ref href="#user-content-fn-1">&#x3C;branch_name></a>", 
                "repository": "&#x3C;<a data-footnote-ref href="#user-content-fn-1">repository SSH URL</a>>",
                "docker_image": "&#x3C;<a data-footnote-ref href="#user-content-fn-1">registry address</a>>", 
                "domain": "&#x3C;<a data-footnote-ref href="#user-content-fn-1">domain</a>>", 
                "host": "&#x3C;<a data-footnote-ref href="#user-content-fn-1">host</a>>"
            }
            data, header = urllib3.encode_multipart_formdata(body)
            r = urllib.request.Request(url, data=data)
            r.add_header('Authorization', appsec_portal_api_token)
            r.add_header('Content-Type', header)
            response = urllib.request.urlopen(r)
            print(response.getcode())
        except Exception as e:
            raise e
        break
    return {
        'statusCode': 200,
        'body': json.dumps('Event successfully imported')
    }
</code></pre>

Replace the following parameters:

* ***\<event>*** with the name of your file containing report
* ***\<appsec portal api key>*** with the key of your [**authorization token**](/appsec-portal/features/scanners/importing-reports-from-scanners-to-appsec-portal.md#authorization-token)
* &#x20;**\<portal address>** with the address of your AppSec Portal
* **\<product name>** with the name of your product
* &#x20;**\<product\_type>** with the name of your product type
* &#x20;**\<scanner name>** with the [**name of your scanner**](/appsec-portal/features/scanners/scanner-description.md)
* **\<branch>** (*optional*) with the the name of the branch in the source code repository (if applicable) This parameter is particularly useful when you want to associate the scan results with a specific branch in your repository. If not provided, the scan will be associated with the default branch

Asset information, if an [auditor ](/auditor.md)is used

* **\<repository>**&#x49;f your product is **code** in a repository enter the address of your **repository** in a specific format, for example: <git@gitlab.com>:whitespots-public/appsec-portal.git
* **\<docker\_image>** If your product is **image** enter the address of the **registry** where your product is located, for example: registry.gitlab.com/whitespots-public/appsec-portal/back/auto\_validator:latest
* **\<domain>** If your product is **web** enter the **domain name** of your product, for example: whitespots.io
* **\<host>** If your product is **web** enter the **IP address** of your product, for example: 0.0.0.0

Congratulations!🎉  Your function is now ready to send reports to AppSec Portal

[^1]: replace

[^2]: replace&#x20;


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.whitespots.io/appsec-portal/features/scanners/importing-reports-from-scanners-to-appsec-portal/importing-reports-via-lambda-function-using-a-report-file.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
