# Scratch

Create, delete, and login to scratch orgs

* [`sfp scratch delete`](#sfp-scratch-delete)
* [`sfp scratch login`](#sfp-scratch-login)

## `sfp scratch delete`

Deletes a particular scratch org in the pool, This command is to be used in a pipeline with correct permissions to delete any active scratch org record or to be used by an adminsitrator

```
USAGE
  $ sfp scratch delete -o <value> -v <value> [--json] [--apiversion <value>] [--loglevel
    trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

FLAGS
  -o, --targetusername=<value>        (required) Username or alias of the target org.
  -v, --targetdevhubusername=<value>  (required) Username or alias of the Dev Hub org.
      --apiversion=<value>            Override the api version used for api requests made by this command
      --loglevel=<option>             [default: info] logging level for this command invocation
                                      <options: trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL>

GLOBAL FLAGS
  --json  Format output as json.

DESCRIPTION
  Deletes a particular scratch org in the pool, This command is to be used in a pipeline with correct permissions to
  delete any active scratch org record or to be used by an adminsitrator

EXAMPLES
  $ sfp scratch delete -o test-xasdasd@example.com -v devhub
```

*See code:* [*src/commands/scratch/delete.ts*](https://source.flxbl.io/flxbl/sfp-pro)

## `sfp scratch login`

This command performs a scratch org login using the username.

```
USAGE
  $ sfp scratch login -u <value> [--json] [--repository <value>] [-e <value>] [-t <value>] [--sfp-server-url
    <value>] [-d <value>] [-s] [-a <value>] [-v <value>] [--loglevel
    trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

FLAGS
  -a, --alias=<value>                 Alias for the org.
  -d, --devhub-username=<value>       Username of the DevHub org (for server-based auth)
  -e, --email=<value>                 Email address for authenticated user. Ignored if --application-token is provided.
                                      Can be set via SFP_SERVER_USER env var.
  -s, --set-default                   Set the authenticated org as the default that all org-related commands run
                                      against.
  -t, --application-token=<value>     Application token for CI/CD authentication. Can be set via SFP_SERVER_TOKEN env
                                      var (CLI flags take precedence over env vars).
  -u, --username=<value>              (required) Set the authenticated org as the default Dev Hub.
  -v, --targetdevhubusername=<value>  Username or alias of the Dev Hub org.
      --loglevel=<option>             [default: info] logging level for this command invocation
                                      <options: trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL>
      --repository=<value>            The repository identifier. E.g `owner/repo` for GitHub/GitLab or
                                      `org/project/repo` for Azure DevOps
      --sfp-server-url=<value>        URL of the SFP server. Can be set via SFP_SERVER_URL env var or config: sfp
                                      config:set server-url

GLOBAL FLAGS
  --json  Format output as json.

DESCRIPTION
  This command performs a scratch org login using the username.

EXAMPLES
  $ sfp scratch login --username myScratch -v myDevHub

  $ sfp scratch login --username myScratch --devhub-username admin@devhub.com

  $ sfp scratch login -u myScratch -a myscratch  # Auto-detects DevHub via server
```

*See code:* [*src/commands/scratch/login.ts*](https://source.flxbl.io/flxbl/sfp-pro)


---

# 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.flxbl.io/flxbl/sfp/cli-reference-v51-release-v3/advanced/scratch.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.
