> For the complete documentation index, see [llms.txt](https://codemash.gitbook.io/codemash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codemash.gitbook.io/codemash/cloud/code/functions/new.md).

# Create a custom function

The Add New Function form — it opens, but Save does not create a function.

**Where:** Code → Functions → **Add New** · `/projects/<project>/code/functions/custom/new`

{% hint style="warning" %}
Cloud has no working screen for this yet. The **Add New Function** form opens and you can fill it in, but **Save** does nothing: the server no longer has standalone functions, and no API, SDK or CLI call creates one. Use a [marketplace function](/codemash/cloud/code/marketplace/function.md) instead, or keep your function in your own AWS, Azure or Google account and [connect that provider](/codemash/cloud/code/integrations/providers.md).
{% endhint %}

## Before you start

* The Code module is on — see [Enable the module](/codemash/cloud/code.md#enable-the-module).
* For a real function you would first [connect a provider](/codemash/cloud/code/integrations/providers.md); the form offers it as **Cloud provider**.

## Steps

1. On **Code Functions**, press **Add New**. **Add New Function** opens with two **Options**: **AWS SAM CLI** and **Manual upload**.

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-9f9878b64913166bdd00766833228ff17b5c8f19%2Fnew-1.png?alt=media" alt="Add New Function with the options AWS SAM CLI and Manual upload"><figcaption><p>Add New Function.</p></figcaption></figure>
2. **AWS SAM CLI** shows a guide, not a form: a `sam init` line per language (NodeJs, NodeJs + TS, Python, .NET, Go, Ruby, Java), a `template.yaml` and a `samconfig.toml` filled with the project id, then `sam build` and `sam deploy`. The starter repositories it names belong to the old product, and the box at the top talks about file integrations — it is old text.

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-ee1b1b4f50f2b15eba8cee595f6f301e3a7d490f%2Fnew-2.png?alt=media" alt="The AWS SAM CLI option: an old box about file integrations, then Create function with language tabs and a sam init line, template.yaml and samconfig.toml"><figcaption><p>The AWS SAM CLI guide.</p></figcaption></figure>
3. **Manual upload** shows the form:

   | Field                        | Required | What it does                                                                          | Example                       |
   | ---------------------------- | -------- | ------------------------------------------------------------------------------------- | ----------------------------- |
   | Cloud provider               | yes      | The provider integration to deploy to (shown when one is connected).                  | `Bookshop Lambda`             |
   | Runtime                      | yes      | An AWS Lambda runtime; **Include previous generation runtimes** lists older ones too. | `nodejs20.x`                  |
   | Handler                      | yes      | The entry point of the code.                                                          | `index.handler`               |
   | Memory in MB                 | yes      | Memory of the function.                                                               | `128`                         |
   | Timeout in minutes / seconds | yes      | How long one run may take.                                                            | `0` / `15`                    |
   | Environment variables        | no       | Key–value pairs for the function (**+ Add Variable**).                                | `STAGE` = `production`        |
   | Code package                 | yes      | A `.zip` file, at most 10 MB (**Download** gives a NodeJS 20.x starter).              | `find-books.zip`              |
   | Impersonate Service Account  | no       | Run the function as a service user.                                                   | —                             |
   | Display name                 | no       | The name in the list.                                                                 | `Find books`                  |
   | Function description         | no       | A note for your team.                                                                 | `Lists the books in the shop` |
   | Tags                         | no       | Free labels.                                                                          | `books`                       |

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-6146414afc47fac602b3bac505cef190a8cfdfa0%2Fnew-3.png?alt=media" alt="The Manual upload form: Runtime, Handler, Memory, Timeout, Environment variables, the zip upload, Impersonate Service Account, Display name, Function description and Tags"><figcaption><p>The Manual upload form.</p></figcaption></figure>
4. Press **Save**. Cloud checks the required fields, but its save call is a placeholder that sends nothing to the server, so no function is created.

## Result

No function is saved. The **Code Functions** list stays empty.

## Change or remove it later

* **Edit** and **Delete** have no screen either — see [Edit a function](/codemash/cloud/code/functions/edit.md) and [Delete a function](/codemash/cloud/code/functions/delete.md).
* **Cancel** goes back to the [Functions list](/codemash/cloud/code/functions.md).

## Do it from code

There is no endpoint for standalone functions. The nearest thing that works is adding a marketplace function to an installed connection (the connection id comes from [Enable a connection](/codemash/cloud/code/marketplace/connection.md)):

```ts
await norbix.hub.code.saveMarketplaceFunction({
  integrationViewId: 'int_1Zz9o3jI1LJyWcRByuLduz',
  function: {
    integrationViewId: 'int_1Zz9o3jI1LJyWcRByuLduz',
    functionKey: 'web.readUrl',
    displayName: 'Read a page',
    isEnabled: true,
    requestTemplate: '{}',
  },
});
```

```sh
norbix hub code marketplace function save --integrationViewId int_1GwJEFn6leCTq8OBJPr1M6 --function:json '{"integrationViewId":"int_1GwJEFn6leCTq8OBJPr1M6","functionKey":"db.find","displayName":"Find reports","isEnabled":true,"requestTemplate":"{}"}'
```

API: [Save Marketplace Function](/codemash/api-reference/code/marketplace/save-marketplace-function.md)
