# Scopes

> For AI agents: the complete documentation index is at https://buddy.works/llms.txt

A Buddy artifact belongs to a workspace, a project or an environment. Scope decides where the artifact is listed and which pipelines and runs can reach it.

The artifact scope determines its visibility and availability to pipelines. Three scopes are supported: Workspace, Project, and Environment.

| Scope | Availability |
| :--- | :--- |
| **Workspace** | All projects within the workspace |
| **Project** | A specific project |
| **Environment** | Runs in the specified environment, provided the environment is assigned to the pipeline |

Artifact scope and permissions are independent mechanisms. A pipeline requires the appropriate permission level configured on the artifact's Permissions tab, even if the artifact is within the pipeline's project scope.

## Scope configuration

You choose the scope when you create the artifact. In the UI and the CLI you can pick **Workspace** or **Project**. **Environment** is available only through the REST API.

### Scope configuration in the UI

You set the scope in the **Scope** field of the **New artifact** form.

![New Bucket artifact form](https://buddy.works/docs/artifacts/artifacts-new-bucket-form.png)

### Scope configuration using the CLI

The `--scope` flag sets the scope, with the value `WORKSPACE` or `PROJECT`. [`bdy artifact create`](https://buddy.works/docs/cli/artifact/create.md) describes the other flags.

```bash
bdy artifact create shared-base-images -t CONTAINER -b --scope WORKSPACE
```

## Registry addresses do not include the project

Container image references and npm package names include the workspace and artifact identifiers, regardless of the artifact scope. The project identifier is not included. For example, an image stored in a Project-scoped artifact can be downloaded using the following command:

```bash
docker pull container.registry.sh/my-workspace/my-app-images:1.0.0
```

A path with the project name, e.g. `container.registry.sh/my-workspace/my-project/my-app-images`, fails with `denied`. In npm, the package scope is the workspace name: the artifact `my-lib` is the package `@my-workspace/my-lib`.

`docker push` and `npm publish` to a name that does not exist in the workspace create an artifact with **Workspace** scope, even when you work in a project context. [Container registry](https://buddy.works/docs/artifacts/container-registry.md) and [npm registry](https://buddy.works/docs/artifacts/npm-registry.md) describe this.

## Environment-scoped artifacts

An environment-scoped artifact is available only to a run in that environment, and only when the pipeline has the environment assigned. You create such an artifact through the REST API, with `scope: ENVIRONMENT` and the environment ID:

```json
{
  "name": "my-app-config",
  "type": "BUCKET",
  "scope": "ENVIRONMENT",
  "environment": { "id": "<environment-id>" }
}
```

Environment-scoped artifacts are not listed in the UI, including the environment resource list, or in artifact lists returned by the Buddy CLI and REST API. Requests to their `html_url` return an HTTP `404 Not Found` response.

The **Publish Artifact Version** action has no environment field. Only a pipeline assigned to the artifact's environment publishes a version, in a run in that environment. [Environments](https://buddy.works/docs/environments/introduction.md) describes how to assign environments to pipelines.

## Scope in pipeline context and triggers

In the pipeline's `artifacts` context, the `scope` field accepts `WORKSPACE`, `PROJECT`, `ENVIRONMENT`, and `ANY`. The default value is `ANY`. Entries using the default scope are stored in shorthand notation:

```yaml
artifacts:
- my-app-build:3.*
```

[Run a pipeline with an artifact version](https://buddy.works/docs/artifacts/run-with-version.md) describes a run with a selected version and the `artifacts` context. [On artifact event](https://buddy.works/docs/pipelines/introduction/triggering-pipelines/on-artifact-event.md) describes the scope filter in the trigger.

See also:

- [Permissions and access](https://buddy.works/docs/artifacts/permissions-and-access.md) - access levels for pipelines, sandboxes and project roles
- [Access control](https://buddy.works/docs/artifacts/access-control.md) - access to files from outside Buddy: Buddy Auth, HTTP BA and Public
- [Container registry](https://buddy.works/docs/artifacts/container-registry.md) - image addresses and creating an artifact with `docker push`
- [Troubleshooting](https://buddy.works/docs/artifacts/troubleshooting.md) - the `Artifact 'identifier' must be unique` error and other messages


---
Original source: https://buddy.works/docs/artifacts/scopes