# Deploy a Custom Function to Data 360 Sandbox by Using CLI

The deployment uploads the code package to Data 360. After deployment, your function is available as a chunking strategy option in the search index builder.

| Edition Table                                                                                                                                                                                                 |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Available in: **Developer**, **Enterprise**, **Performance**, and **Unlimited** Editions. See [Data 360 edition availability](https://help.salesforce.com/s/articleView?id=sf.c360_a_dc_editions.htm&type=5). |

| User Permissions Needed                                           |                                                        |
| ----------------------------------------------------------------- | ------------------------------------------------------ |
| To deploy a custom function and use it for search index chunking: | Permission set: <ul><li>Data Cloud Architect</li></ul> |

## Prerequisites

- Write your custom chunking function and validate it locally. See [Write a Custom Chunking Function](/docs/data/data-cloud-code-ext/guide/write-custom-chunking-function.md).

***

## Deploy Your Custom Function by Using the Salesforce CLI

1. Open a terminal, and go to the root of your code extension function package (the folder that contains `payload/`).

   ```bash
   cd <path-to-root-folder-of-function-package>
   ```

2. Make sure that you are signed in to the target org.

   ```bash
   sf org display --target-org <ORG_ALIAS>
   ```

3. Refresh package metadata from the package root.

   ```bash
   sf data-code-extension function scan --entrypoint ./payload/entrypoint.py
   ```

4. Deploy your code extension function.

   ```bash
   sf data-code-extension function deploy --name <DEPLOYMENT_NAME> --package-version <PACKAGE_VERSION> --description "<DESCRIPTION>" --package-dir <PACKAGE_DIR> --target-org <ORG_ALIAS> [--network <NETWORK_VALUE>] [--cpu-size CPU_L|CPU_XL|CPU_2XL|CPU_4XL]
   ```

   **Example:**

   ```bash
   sf data-code-extension function deploy --name <DEPLOYMENT_NAME> --package-version <PACKAGE_VERSION> --description "<DESCRIPTION>" --package-dir ./payload --target-org <ORG_ALIAS> --cpu-size CPU_XL
   ```

- `--name <DEPLOYMENT_NAME>` (required): Name for your code extension deployment.
- `--package-version <PACKAGE_VERSION>` (required): Semantic version for the package (for example, `1.0.0`).
- `--description "<DESCRIPTION>"` (required): Short description of the deployment.
- `--package-dir ./payload` (required): Directory that contains your packaged function (typically `./payload` under the package root).
- `--target-org <ORG_ALIAS>` (required): Org username or alias (same as other `sf` commands).
- `--cpu-size` (optional): The CPU size: `CPU_L`, `CPU_XL`, `CPU_2XL` (default), or `CPU_4XL`. Larger sizes provide more processing power but consume more credits. To understand how the compute size affects the compute model and credit consumption, see [*Salesforce Help*: Billing Considerations for Code Extension](https://help.salesforce.com/s/articleView?id=data.c360\_a_billing_considerations_code_extension.htm\&type=5).
- `--network` (optional): Network setting for packages that include Jupyter notebooks (for example, `host` for host network mode).

  **Example:**

  ```bash
  sf data-code-extension function deploy --name my_chunking_function --package-version 1.0.0 --description "Custom chunking for product pages" --package-dir ./payload --target-org myorg --cpu-size CPU_L
  ```

6. Confirm that the code deployment is successful. See [Monitor Custom Function Deployments](/docs/data/data-cloud-code-ext/guide/monitor-custom-function-deployments.md).

## Next Step

- [Use a Custom Chunking Function in a Search Index](/docs/data/data-cloud-code-ext/guide/use-chunking-in-search-index.md)

## See Also

- [Deploy a Custom Function to Data 360 by Using UI](/docs/data/data-cloud-code-ext/guide/deploy-custom-function.md)
- [Monitor Custom Function Deployments](/docs/data/data-cloud-code-ext/guide/monitor-custom-function-deployments.md)
- [Migrate Custom Function to Production](/docs/data/data-cloud-code-ext/guide/migrate-custom-function-to-production.md)
- [*Salesforce Help*: Billing Considerations for Code Extension](https://help.salesforce.com/s/articleView?id=data.c360\_a_billing_considerations_code_extension.htm\&type=5)
