> For the complete documentation index, see [llms.txt](https://docs.middle.app/middle-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.middle.app/middle-docs/product/apps/code-packages.md).

# Code packages

Add code packages to Middle to streamline your coding

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.

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.

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

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).

<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 with a `python` folder at its root. 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
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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.middle.app/middle-docs/product/apps/code-packages.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
