# Code packages

Code Packages and Helper Functions

When writing your scripts for Records and Actions, you may want to import certain Python libraries or helper functions. Middle can support two import methods: code packages and upload mode.&#x20;

Code Packages

The Code Packages section of your Middle app is useful when you want to upload Python code that can be accessed by all actions and scripts. You could upload your own Python file that has helper functions for your syncs, or you can upload helper libraries for the app you are integrating with.&#x20;

To create a Code Package, click **+ Create** next to **Code Packages** on the navigation bar. &#x20;

Configure a code package with a name and description to explain its purpose. The **Live** boolean should be switched on when you want your scripts to access the package (all scripts must be re-saved to access it).&#x20;

<figure><img src="https://lh3.googleusercontent.com/Dbxel2Zh9uhjSCdSXF9JyKJcoT9XK36lioYpOj9PL5JFjxeQH0_cxrzhG9gUloacgSXFR2W5IsjmH6xvBeXK6K_jrEtgvKosQ7J1Hm7zx60s-fIcVzggPpLgAI0MH5UhunKJ8YwrwzUibPg4m7yekMcLy2PfJ2kHo0y4vngXma1zQyPBzLxd3czGuRFNGw" alt=""><figcaption><p>Upload a code package to reference in your scripts</p></figcaption></figure>

A code package must be uploaded as a zip archive. The Python files within the package can be accessed by using an import statement within your action and poll sync scripts.

```python
import requests # requests library is available for use
import datetime
from index import Restart, AuthenticationChanged
from coolnewapp_middle_utils import coolnewapp_api_request
```


---

# Agent Instructions: 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:

```
GET https://docs.middle.app/middle-docs/app-development/code-packages.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
