---
schema_version: "1"
id: 199994512d187315bb31a858a98baad576738d4125232c61b904cb374a5dc5dc
title: Set Up Your SFDX Project
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforce-slack-sdk/apex-slack-sdk/guides/run-sfdx.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-slack-sdk/guide/run-sfdx.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: b5c2fc25de62dd6198b529f5c90315f9ea3323faebcc39edecc02a3b6346b74d
products:
  - Apex SDK for Slack (Beta)
---
# Set Up Your SFDX Project

After you [set up your development environment](https://developer.salesforce.com/docs/platform/salesforce-slack-sdk/guide/setup-your-env.md), configure your project definitions and create a scratch org for your first Slack app.

## Configure Your Project Definitions

To configure your SFDX project definition:

1. Open the project in VS Code.

2. Update `sfdx-project.json` with the login URL for your Dev Hub org. Use the `my.salesforce` version (Classic) of the URL, not a Lightning Experience one. For example, `https://my-dev-domain.my.salesforce.com`.

   ```bash
   "sfdcLoginUrl": "https://<my_domain>.my.salesforce.com",
   ```

3. Set `sourceApiVersion` to 54.0 or later.

   ```bash
   "sourceApiVersion": "54.0",
   ```

## Create a Scratch Org

Scratch orgs simplify your Slack app development and drive developer productivity and collaboration. You can only have 3 active orgs at once. By default, you can create up to 6 scratch orgs a day.

**note:** Scratch orgs are short-lived, development, and testing orgs that are similar to your production and sandbox orgs.

To create a scratch org:

1. Sign up and configure the scratch org using the scratch org definition in `project-scratch-def.json`, and run this command.

   ```bash
   sf org create scratch --definition-file config/project-scratch-def.json --alias scratch1 --set-default --duration-days 30
   ```

   - `--alias` sets an alias for your scratch org username so that you can refer to it with a simpler name from other commands.
   - `--set-default` sets this org as the default scratch org for your project so that you don’t have to specify the target org with commands that require it.
   - `--duration-days` sets the duration of the scratch org to the maximum of 30 days, after which it's deleted and you lose access to it.

2. After you create your scratch org, you can see it in your org list known to the CLI by running `sf org list`.

**tip:** To see how many scratch orgs you're using, run `sf org list limits --target-org <DevHub org username or alias>` and search for `ActiveScratchOrgs` and `DailyScratchOrgs` in the output table. Alternatively, to view your Active scratch orgs, go to the App Launcher in Lightning Experience, enter **Scratch** to find **All Scratch Orgs** and **Scratch Org Info**.

3. Capture your scratch org user information.

   1. With the username that was created for your new scratch org, generate a password for this new admin user. Record this password to help you log in to your scratch org later.

   ```bash
    sf org generate password --target-org scratch1
   ```

   - `--target-org` specifies your scratch org username. You can find this information in **Scratch Org Info**. Alternatively, use the `scratch1` alias you created earlier.

   2. Next, determine the instance URL using the same username or alias. Save this info for later.

   ```bash
    sf org display user --target-org scratch1
   ```

4. Assign Slack permission sets to your scratch org user.
   1. Log in to your scratch org with your scratch org username and generated password. Alternatively, open your scratch org by running `sf org open`. Since you set this scratch org as the default using the `--set-default` flag in an earlier step, SFDX stores your authentication token and uses it to log in for you.
   2. Create a permission set with the same steps as [Enable User Permissions](https://developer.salesforce.com/docs/platform/salesforce-slack-sdk/guide/setup-your-env.md#enable-user-permissions) in your scratch org. Make sure to select **Connect Salesforce with Slack** and **Create and Update Second-Generation Packages**. Assign the permission set to your scratch org user.

**important:** You must also [accept the Salesforce for Slack Beta Terms and Conditions](https://developer.salesforce.com/docs/platform/salesforce-slack-sdk/guide/enable-beta.md) to use Apex SDK for Slack in a scratch org.

5. Confirm your SFDX setup.

   1. Open VS Code, and create a file called `SayHello.cls` in `force-app/main/default/classes`. Copy and paste this code, and then save the file.

   ```java
   // SayHello.cls
   public class SayHello {
      public String hello() {
         return 'Hello World!';
      }
   }
   ```

   2. Create the metadata file `SayHello.cls-meta.xml` in `force-app/main/default/classes`. Copy and paste this code, and then save the file.

   ```xquery
   <?xml version="1.0" encoding="UTF-8"?>
   <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>54.0</apiVersion>
    <status>Active</status>
   </ApexClass>
   ```

   3. Deploy the source to the scratch org.

   ```bash
   sf project deploy start
   ```

   When you deploy successfully, a summary is displayed. Next, [deploy a Slack app](https://developer.salesforce.com/docs/platform/salesforce-slack-sdk/guide/run-deploy.md) to your scratch org.

**tip:** If you receive an expired access or refresh token error, check that your scratch org is still valid and not expired.

## See Also

[Scratch Orgs](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs.htm)
