# Manage custom applications
URL: https://docs.datarobot.com/en/docs/workbench/nxt-registry/nxt-apps-workshop/nxt-manage-custom-app.html

> Create custom applications in DataRobot to share machine learning projects using web applications like Streamlit, Dash, and Plotly.

# Manage custom applications

The Applications page in Registry lists all custom applications available to you from the Applications page. The table below describes the elements and available actions from this page:

|  | Element | Description |
| --- | --- | --- |
| (1) | Application name | The application name. |
| (2) | Version | Lists the version number of the application or source. |
| (3) | Open | Click to open an application or source. |
| (4) | Actions menu | Shares, controls, or deletes an application. |
| (5) | Search | Use to find a specific application in the list. |
| (6) | Application tabs | Choose to view built applications or application sources. |
| (7) | Add dropdown | Use the Add dropdown to upload a custom app or create a new application source. |

## Share applications

The sharing capability allows you to manage permissions and share an application with users, groups, and organizations, as well as recipients outside of DataRobot. This is useful, for example, for allowing others to use your application without requiring them to have the expertise to create one.

> [!WARNING] Warning
> When multiple users have access to the same application, it's possible that each user can see, edit, and overwrite changes or predictions made by another user, as well as view their uploaded datasets. This behavior depends on the nature of the custom application.

To access sharing functionality from the Applications page, click the Actions menu next to the app you want to share and select Share ().

This opens the Share dialog, which lists each associated user and their role. Editors can share an application with one or more users or groups, or the entire organization. Additionally, you can share an application externally with a sharing link.

**Users:**
To add a new user, enter their username in the
Share with
field.
Choose their role from the dropdown.
Select
Send notification
to send an email notification and
Add note
to add additional details to the notification.
Click
Share
.

**Groups and organizations:**
Select either the
Groups
or
Organizations
tab in the
Share
dialog.
Enter the group or organization name in the
Share with
field.
Determine the role for permissions.
Click
Share
. The app is shared with—and the role is applied to—every member of the designated group or organization.

**External sharing:**
To share a custom app with non-DataRobot users, toggle on Enable external sharing. The link that appears beneath the toggle allows you to share custom with end-users who don't have access to DataRobot. Before you can share that link with end users, you must specify the email domains and addresses that are permitted access to the app. Email invitations expire one hour after they are sent to a user. After a user accepts authentication, the authentication token created expires after 30 days. You can revoke access to a sharing link by modifying this list. Remove the domains or addresses that you no longer want to have access to the app.

[https://docs.datarobot.com/en/docs/images/manage-app-7.png](https://docs.datarobot.com/en/docs/images/manage-app-7.png)

You can also programmatically share custom applications using the [DRApps CLI](https://docs.datarobot.com/en/docs/classic-ui/app-builder/custom-apps/custom-apps-hosting.html#external-share-command).


The following actions are also available in the Share dialog:

- To remove a user, click the X button to the right of their role.
- To re-assign a user's role, click the assigned role and assign a new one from the dropdown.

#### Application API keys

When [sharing custom applications](https://docs.datarobot.com/en/docs/wb-apps/custom-apps/manage-custom-app.html#share-applications), you may want to grant the ability for users to access and use data from within an application. An application API key grants an application the necessary access to the DataRobot Public API. Sharing roles grant control over the application as an entity within DataRobot, while application API keys grant control over the requests the app can make when a user accesses it.

When a user accesses an application, the application requests the user's consent to generate an API key. That key has a configured level of access, controlled by the application source.

Once authorized, the application API key is included in the header of the request made by the application. An application can take the API key from the web request header and, for example, look up what deployments the user has access to and use the API key to make predictions.

Follow to the steps below to configure an application API key.

An application API key is automatically created when you build a custom application. To edit the scope of access the key grants, navigate to the [application source](https://docs.datarobot.com/en/docs/wb-apps/custom-apps/upload-custom-app.html#build-a-custom-application-from-an-application-source) and create a new version. In the Resources section, click Edit.

From the Update resources modal, you can edit the degree of access for the application API key using the Required key scope level dropdown. Select a role that defines the degree of access the application has to DataRobot's public API when using the key.

The role types have the following access:

| Role | Access |
| --- | --- |
| None | No access. When you select this role, DataRobot does not create an application API key for the application user and uses the owner's instead. |
| Viewer | Read-only access. |
| User | Create, read, and write access. Can also make predictions. |
| Admin | Create, read, write, and delete access. |

After choosing a role, click Update. When you build a custom application from the source you configured, it will automatically provide an application API key with the scope of access defined by the selected role.

When a user accesses and uses an application, the application API key is included in the header of the request made by the application.

## Link to a Use Case

To link a custom application to a Workbench [Use Case](https://docs.datarobot.com/en/docs/workbench/nxt-workbench/usecases/usecase-overview.html), in the application's actions menu, click Link to Use Cases:

In the Link to Use Case modal, select one of the following options:

**Select Use Case:**
[https://docs.datarobot.com/en/docs/images/wb-select-use-case.png](https://docs.datarobot.com/en/docs/images/wb-select-use-case.png)

**Create Use Case:**
[https://docs.datarobot.com/en/docs/images/wb-create-use-case.png](https://docs.datarobot.com/en/docs/images/wb-create-use-case.png)

**Managed linked Use Cases:**
[https://docs.datarobot.com/en/docs/images/wb-manage-use-case.png](https://docs.datarobot.com/en/docs/images/wb-manage-use-case.png)


| Option | Description |
| --- | --- |
| Select Use Case | Click the Use Case name dropdown list to select an existing Use Case, then click Link to Use Case. |
| Create Use Case | Enter a new Use Case name and an optional Description, then click Create Use Case to create a new Use Case in Workbench. |
| Managed linked Use Cases | Click the minus icon next to a Use Case to unlink it from the asset, then click Unlink selected. |

## Delete an application

If you have the appropriate permissions, you can delete an application by opening the Actions menu and clicking Delete ().

## Application sources

An application source contains the files, dependencies, and environment from which a custom app can be built. On the Applications page, select the Application sources tab to view all the sources that you can build custom applications from.

To view the application source for a specific application, select the application's actions menu and click Navigate to source.

### Add an application source

To create a new application source from the Applications page, click Add > New application source.

The new application source is immediately added to the page. Select the new application source to begin configuring it.

### Configure an application source

After selecting an application source, you can choose its base environment, upload files to the source, and create runtime parameters.

Whenever you edit any of these components of an application source, you create a new version of the source. You can select any version of a source from the Version dropdown.

To view the history of changes made to an application version, choose a version of the application from the list in the left-hand column. Then, expand the right-hand column next to the history icon () to view the history of changes made.

#### Environment

Custom apps run inside of environments (Docker containers). Environments include the packages, language, and system libraries used by the custom app. Select a DataRobot-provided environment for the application source from the dropdown under the Environment header. DataRobot offers a predefined base environment named `[Experimental] Python 3.9 Streamlit`.

#### Files

In the Files section, you can assemble the files that make up the custom application source. Drag files into the box, or use the options in this section to create or upload the files required to assemble a custom job:

| Option | Description |
| --- | --- |
| Choose from source / Upload | Upload existing custom job files (run.sh, metadata.yaml, etc.) as Local Files or a Local Folder. |
| Create | Create a new file, empty or containing a template, and save it to the custom job: Create metadata.yaml: Creates a basic, editable example of a runtime parameters file.Create README.md: Creates a basic, editable README file.Create start-app.sh: Creates a basic, editable example of an entry point file.Create demo-streamlit.py: Creates a basic, editable Python file.Create example job: Combines all template files to create a basic, editable app. You can quickly configure the runtime parameters and run this example app.Create blank file: Creates an empty file. Click the edit icon () next to Untitled to provide a file name and extension, then add your custom contents. In the next step, it is possible to identify files created this way, with a custom name and content, as the entry point. After you configure the new file, click Save. |

If you choose to create a blank text file, enter the information into the file, name it using a full path (including the folder it belongs to and the file extension), then click Save.

##### Build app script

If you supply a `requirements.txt` file in an application source, it instructs DataRobot to install Python dependencies when building an app. However, you may also want to install non-Python dependencies. To install these dependencies, application sources can contain a `build-app.sh` script, called by DataRobot when you build an application for the first time. The `build-app.sh` script can run `npm install` or `yarn build`, allowing custom applications to support dependency installation for JavaScript-based applications.

The example below outlines a sample `build-app.sh` script for a custom node application.

```
#!/usr/bin/env sh
cd client

echo "Installing React dependencies from package.json..."
npm install

echo "Building React app..."
yarn run build && rm ./build/index.html
```

#### Resources

> [!NOTE] Preview
> Resource bundling for custom applications is off by default. Contact your DataRobot representative or administrator for information on enabling this feature.
> 
> Feature flag: Enable Resource Bundles

After creating an application source, you can configure the resources an application consumes to minimize potential environment errors in production. DataRobot allows you to customize resource limits and the replicas number. To edit the resources bundle:

1. Select an application source. In theResourcessection, click ()Edit:
2. In theUpdate resourcesdialog box, configure the following settings: SettingDescriptionBundleSelect a resource bundle from the dropdown that determines the maximum amount of memory and CPU that can be allocated for a custom application.ReplicasSet the number of replicas executed in parallel to balance workloads when a custom application is running. The default value is 1, and the maximum value is 4.Enable session affinitySend requests to the same replica. This must be enabled for stateful apps, storing data in the local file system or in memory, e.g., an app that can save chat history to a document and reference it. Some Streamlit components such as thefile_uploaderthrow errors without this setting enabled if more than one replica is available.Internally run apps on the root pathAllow an app to run on/instead of/custom_applications/{ID}. This setting isn't required if the app automatically handles path configuration (e.g., using Gunicorn or Streamlit). It is useful for web frameworks without a solution to make all routes to work on/custom_applications/{ID}/(e.g., R-Shiny).
3. Once you have configured the resource settings for the application source, clickSave.

#### Runtime parameters

You can create and define runtime parameters to supply different values to scripts and tasks used by a custom application at runtime.

You can add runtime parameters to a custom app by including them in a `metadata.yaml` file, making your custom app easier to reuse. A template for this file is available from Files > Create dropdown.

To define runtime parameters, you can add the following `runtimeParameterDefinitions` in `metadata.yaml`:

| Key | Description |
| --- | --- |
| fieldName | Define the name of the runtime parameter. |
| type | Define the data type the runtime parameter contains: string, boolean, numeric credential, deployment. |
| defaultValue | (Optional) Set the default string value for the runtime parameter (the credential type doesn't support default values). If you define a runtime parameter without specifying a defaultValue, the default value is None. |
| minValue | (Optional) For numeric runtime parameters, set the minimum numeric value allowed in the runtime parameter. |
| maxValue | (Optional) For numeric runtime parameters, set the maximum numeric value allowed in the runtime parameter. |
| credentialType | (Optional) For credential runtime parameters, set the type of credentials the parameter must contain. |
| allowEmpty | (Optional) Set the empty field policy for the runtime parameter.True: (Default) Allows an empty runtime parameter.False: Enforces providing a value for the runtime parameter before deployment. |
| description | (Optional) Provide a description of the purpose or contents of the runtime parameter. |

```
# Example: metadata.yaml
name: runtime-parameter-example

runtimeParameterDefinitions:
- fieldName: my_first_runtime_parameter
  type: string
  description: My first runtime parameter.

- fieldName: runtime_parameter_with_default_value
  type: string
  defaultValue: Default
  description: A string-type runtime parameter with a default value.

- fieldName: runtime_parameter_boolean
  type: boolean
  defaultValue: true
  description: A boolean-type runtime parameter with a default value of true.

- fieldName: runtime_parameter_numeric
  type: numeric
  defaultValue: 0
  minValue: -100
  maxValue: 100
  description: A boolean-type runtime parameter with a default value of 0, a minimum value of -100, and a maximum value of 100.

- fieldName: runtime_parameter_for_credentials
  type: credential
  allowEmpty: false
  description: A runtime parameter containing a dictionary of credentials.
```

The `credential` runtime parameter type supports any `credentialType` value available in the DataRobot REST API. The credential information included depends on the `credentialType`, as shown in the examples below:

> [!NOTE] Note
> For more information on the supported credential types, see the [API reference documentation for credentials](https://docs.datarobot.com/en/docs/api/reference/public-api/credentials.html#schemacredentialsbody).

| Credential Type | Example |
| --- | --- |
| basic | basic: credentialType: basic description: string name: string password: string user: string |
| azure | azure: credentialType: azure description: string name: string azureConnectionString: string |
| gcp | gcp: credentialType: gcp description: string name: string gcpKey: string |
| s3 | s3: credentialType: s3 description: string name: string awsAccessKeyId: string awsSecretAccessKey: string awsSessionToken: string |
| api_token | api_token: credentialType: api_token apiToken: string name: string |

### Manage an application source in a codespace

You can open and manage application sources in a [codespace](https://docs.datarobot.com/en/docs/workbench/wb-notebook/codespaces/index.html), allowing you to directly edit a source's files and upload new files to it.

To open an application source in a codespace, navigate to the source on Applications > Application sources page. Select it to view its contents and click Open in Codespace.

The application source will open in a codespace, where you can directly edit the existing files, upload new files, or use any of the [codespace functionality](https://docs.datarobot.com/en/docs/workbench/wb-notebook/codespaces/session-cs.html#create-files).

After you finish making changes to the application source in the codespace, click Save. The application source version is updated with your changes. If you previously deployed the version of the application source that you are modifying, saving creates a new source version. Otherwise, saving maintains the same source version. If you do not want to save, click Cancel. Otherwise, click Proceed.

After saving the codespace, DataRobot returns you to the Application sources page, listing the new source version in the Version dropdown.

### Replace an application source

After using an application, you may want to replace its source. Replacing an application source carries over the following from the original application:

- The application code
- The underlying execution environment
- Number of replicas
- Runtime parameters and secrets are copied over
- The t-shirt size (small, medium, or large) of the containers

To replace an application source, find the application on the Applications page, open the Actions menu, and select Replace source.

In the modal, select an application source from the dropdown to replace the one currently used by the application. Each source indicates its source version. You can use the search bar to specify an application source. After selecting a replacement source, click Confirm.

As the source is replaced, all users with access to the application can still use it, even though the Open button is disabled during replacement.

## Application logs

DataRobot records two types of logs for custom applications: build and runtime logs and access logs. Through these logs, you can monitor an application's build and runtime tasks and review the user access history for an application.

> [!NOTE] Permissions to view logs
> Access to logs for an application require [Owner or Editor](https://docs.datarobot.com/en/docs/workbench/nxt-registry/nxt-apps-workshop/nxt-manage-custom-app.html#share-applications) permissions for the custom application. Owners can view all logs, while Editors can only view build and runtime logs, not access logs.

### Build and runtime logs

You can browse logs that detail the history of build and runtime tasks for a custom application. From the Applications page, open the actions menu for the app you want to view logs for, and click View logs.

The logs modal details the history of compiling, building, and executing the custom application. This includes dependency checks, packaging, and any warnings or errors thrown.

### Access logs

Browse access logs to monitor the history of users who have opened or operated a custom application. To view access logs, navigate to the Applications page, open the actions menu for the app you want to view logs for, and click View access logs.

You can also view access logs directly from an [application source](https://docs.datarobot.com/en/docs/workbench/nxt-registry/nxt-apps-workshop/nxt-manage-custom-app.html#application-sources). Navigate to the Application sources page, locate the application source for your custom application, and expand the dropdown to view the applications built from the source. Then you can click the custom application for which you want to view the access logs to access a detailed view.

From the detailed view for a custom application, scroll down to the Access logs section.

The access logs detail users' visits to the application, including their email, user ID, time of visit, and their [role](https://docs.datarobot.com/en/docs/workbench/nxt-registry/nxt-apps-workshop/nxt-manage-custom-app.html#share-applications) for the application.

> [!NOTE] Usage logging interval
> In addition to the initial access event, every 24 hours of continuous access or use is recorded as an individual visit to the application. For example, when a user opens an application, an access event is logged, then, when that user session exceeds 24 hours of continuous access or use, another access event is logged. This results in two access events logged during a 24 hour and 1 minute custom application visit. In Self-Managed AI Platform environments, this interval is configurable through the `CUSTOM_APP_USAGE_METRIC_PUBLISH_MAX_FREQ` in the application configuration.

---
