# dflow context:use

> Save the server, workspace, project, and environment later commands should use.

Web page: /docs/cli/path/context-use/

This saves where later commands should go: a named context, the default server, or a workspace, project, and environment. Creating a project or an environment also selects it, so you only need this command when you want to point at something that already exists, or at a different server.

```bash
dflow context
dflow context --project PROJECT --environment ENVIRONMENT
dflow context:use NAME
dflow context:use --api URL
dflow context:use --workspace ORG --project PROJECT --environment ENVIRONMENT
```

`dflow context` with no flags prints the current selection. The same command with `--project` and `--environment` saves them. `dflow context:use` is the same save.

## Flags

`--api` sets the server used by `dflow login` and `dflow auth:register` when those commands omit `--api`.

`--workspace`, `--project`, and `--environment` save that scope. In the saved file and in errors, the workspace id is still called `org`.

You need a name, `--api`, or at least one of those scope flags. The usual global flags still apply.

## What you see

A name, or `--api`, prints `context`, `api`, and `default_api`. Scope flags print `workspace`, `project`, and `environment`. An empty value prints `-`.

Each value you pass has to match the name pattern. Without a refresh token this command does not call the API. When the login has a refresh token, `--workspace` resolves a name and switches the token the same way as `dflow workspaces:use`.

The flags on this command are saved. The same `--project` and `--environment` flags on another command apply to that command only.

## When it fails

Exit 1 when no selector is passed, a name is illegal, or the config path is a symlink.
