# Functions

Functions are units of execution in the AssemblyLift framework. They are grouped into services, and are themselves structured according to the chosen language (e.g with Rust each function is a Cargo crate).

Each function is compiled to a WebAssembly module, compatible with the AssemblyLift ABI.

## Overview

An AssemblyLift Function is an executable containing a *handler*, which is the entrypoint of the Function (similar to a *main* method in a regular application). A Function usually receives some input which is passed to the handler as an argument; the shape of this input will depend on the Function. The Function should return by indicating either success or an error to the runtime, though the Function is not required to return any specific data.

Functions which are invoked by an HTTP API for example, will receive input data in the shape of an [API Gateway Event](https://github.com/awsdocs/aws-lambda-developer-guide/blob/main/sample-apps/nodejs-apig/event.json) (assuming you are using the default AWS provider).

The input payload received by a Function **must** be represented as [JSON](https://www.json.org/json-en.html).

## Make a New Function

You can create a new function in an existing service with the `make` command:

```
$ asml make function myservice.myfunction
```

where `myservice` is the name of the service in which you would like to make the function named `myfunction`.


---

# 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.assemblylift.akkoro.io/learn-assemblylift/functions.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.
