---
title: Share and access
description: Make a Space public, issue scoped share links or passwords, invite people, enable Sign in with Spacefast, and revoke access
---
Spacefast Share controls who can open a Space. Access comes from grants, and any matching grant lets a visitor in. Removing a public grant closes that route to the public only if no other public grant matches; links, people, and team access can remain.
## Sharing uses grants
Access is a set of additive **grants**. Each grant names an audience, a role, the paths it covers, and which published target it applies to. A matching grant admits a visitor. Revoking one grant does not revoke other matching grants or remove the owning team's permissions.
Grants let a Space be public at `/docs/**` and closed everywhere else. Revoking a share link takes effect on the next request without a publish.
The dashboard covers the common cases. The CLI and API can create any grant.
| Audience | Who it admits |
| --- | --- |
| `public` | Anyone on the web |
| `team` | Every member of the owning team |
| `person` | One invited person, by email |
| `link` | Whoever holds a share link |
| `password` | Whoever knows a password |
| `machine` | Whatever holds a bearer token |
| `external` | One subject proven by a team SSO or signer connection. See [SSO and external identity](/sso) |
## Roles
A role is a named bundle of capabilities. Every grant carries one.
| Role | Can |
| --- | --- |
| `viewer` | View pages |
| `commenter` | View, read comments, write comments |
| `editor` | The above, plus publish |
| `manager` | The above, plus manage access |
Share links and passwords are forwardable secrets, so they cap at `viewer` or `commenter`. Neither can hold `manage`. People, machine credentials, and external identities can hold any role.
Granting `commenter` on the live Space requires [Comments](/comments) set to **Everywhere**. When comments are limited to previews, the write fails with `comments_target_unavailable`; grant `commenter` on a version instead.
## In the dashboard
Open the Space and go to [**Share**](https://my.spacefast.com/?to=/:team/:space/share).
The **General access** control switches between **Private** and **Public**:
| Option | What it does |
| --- | --- |
| **Private** | Your team and people you add can view it |
| **Public** | Anyone on the web can open it |
When set to **Public**, **What public visitors can do** sets the role to `viewer` or `commenter`. A Space whose team has turned on [Private spaces only](#defaults-for-new-spaces) cannot be switched to Public.
The page also holds the **Password**, **Share link**, and **People** cards, plus **Access requests**. **Advanced** is collapsed and holds **Path rules**, **Machine credentials**, and **SSO and identity**. It opens automatically when some paths have their own rules. **Path rules** lists public and team grants path by path and can revoke them; creating a path-scoped grant is a CLI or API job.
## Make a Space public
Open the live Space to anyone on the web with [`sf share grant`](/cli/reference/share#sf-share-grant):
```bash
sf share grant --to public --role viewer --path '/**' --target live --space my-space
```
Scope the grant to a subtree instead of opening the whole Space:
```bash
sf share grant --to public --role viewer --path '/docs/**' --exclude '/docs/internal/**' --space my-space
```
`--to team` does the same for the owning team. Patterns use `*` for one segment and `**` for zero or more. A grant takes up to 100 include and exclude patterns combined. A public grant cannot carry publish or manage capabilities.
Grants default to `live`. Opening the live Space does not open branch previews or version URLs. To make immutable version URLs public too, add a grant for `all-versions`:
```bash
sf share grant --to public --role viewer --path '/**' --target all-versions --space my-space
```
Use `version:` to open one version. Branch previews need a `branch:` grant; `all-versions` does not cover them or the live Space. A public grant cannot target a branch, so share a branch preview with a link, a password, or a person instead. A team grant admits the owning team and cannot name another team you belong to.
You can also inspect or switch general access, indexing, and Comments in one command with [`sf share show`](/cli/reference/share#sf-share-show) and [`sf share set`](/cli/reference/share#sf-share-set):
```bash
sf share show --space my-space
sf share set --level public --role viewer --space my-space
sf share set --close-all-public --dry-run --space my-space
```
You can also declare public live paths under `access` in `spacefast.config.ts` (or `sf.jsonc`). That declaration compiles to a public `viewer` grant on `live`, stays inactive until the Space is claimed, and is ignored while the team has **Private spaces only** enabled. See [Configuration file](/config-file#access-public-identity-theme-and-snippets).
## Share links
A new team-owned Space does not create a share link in the current CLI or dashboard. The owning team signs in at the live URL. Create a link when you want to share outside the team.
Team requests to `POST /v1/spaces` that omit `capabilities: ["optional_access"]` still receive a compatibility Open link. Current publish clients send the capability and create no automatic link. Unclaimed anonymous Spaces keep their expiring Open link.
A share link is a lasting URL that opens only the paths you scoped it to, with no account needed. The secret rides in the query string, so one request returns the page with no redirect or interstitial:
```text
https://my-space.space.fast/docs?__=sfl_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```
### Create a share link
Create a scoped, expiring link with [`sf share link create`](/cli/reference/share#sf-share-link-create):
```bash
sf share link create \
--space my-space \
--name "Client review" \
--landing /docs \
--path '/docs/**' \
--path '/assets/**' \
--exclude '/docs/internal/**' \
--role commenter \
--expires 7d
```
| Flag | Default | What it does |
| --- | --- | --- |
| `--name` | required | The name shown in the links list |
| `--landing` | `/` if covered, else the first included path without a wildcard (`/docs/**` lands on `/docs`) | Clean route the link opens at; must fall inside the link's paths and is required when every path uses a single wildcard such as `/docs/*` |
| `--path` | `/**` | Included route pattern; repeatable for disjoint subtrees |
| `--exclude` | none | Excluded route pattern local to this link; repeatable |
| `--role` | `viewer` | `viewer` or `commenter` |
| `--target` | `live` | `live`, `all-versions`, `version:`, or `branch:` |
| `--not-before` | none | Do not admit anyone before this ISO timestamp |
| `--expires` | never | Duration such as `30m`, `24h`, or `7d` |
| `--max-uses` | unlimited | Successful opens before the link stops working, 1 to 1,000,000 |
| `--require-verified-email` | off | Admit only visitors whose session has a verified email |
| `--network` | none | Unsupported; the runtime has no trusted visitor IP, so the CLI refuses it |
| `--country` / `--exclude-country` | none | Allowed or blocked ISO country codes; repeatable |
| `--exclude-user-agent` | none | Block user agents containing this text; repeatable |
On the Space's [**Share**](https://my.spacefast.com/?to=/:team/:space/share) page, the **Share link** card's **Create share link** button opens a sheet with the same fields.
### List, copy, update, and revoke
Manage existing links from the CLI:
```bash
sf share link list --space my-space
sf share link copy lnk_xxxxxxxx --space my-space --show-secret
sf share link revoke lnk_xxxxxxxx --space my-space
```
Listing links never returns the secret. Only callers who can manage the Space's access can fetch the URL, and non-interactive shells require `--show-secret` to print it.
Revoking a link removes its grant in the same write, so every copy of the URL stops working on the next request.
[`sf share link update`](/cli/reference/share#sf-share-link-update-link) changes a link's scope, role, target, and constraints without rotating its URL, so you can narrow a link you already sent instead of replacing it.
An unclaimed Space may keep up to 50 active links; further creates fail with [`anonymous_share_link_limit`](/errors/anonymous_share_link_limit).
## Passwords
A password is its own grant with its own scope, not a lock on the whole Space. You can create several named passwords covering different paths.
Create a password grant with [`sf share password create`](/cli/reference/share#sf-share-password-create):
```bash
sf share password create \
--space my-space \
--name "Preview reviewers" \
--path '/**' \
--role viewer \
--password-from-stdin
```
Pass the password on `stdin` or through `SPACEFAST_SHARE_PASSWORD`. It never goes into `spacefast.config.ts` or `sf.jsonc`. A password needs at least 15 characters; the dashboard's **Generate password** button creates one. The verifier is Argon2id, and `--role` defaults to `viewer`.
List, rotate, or revoke passwords with [`sf share password`](/cli/reference/share#sf-share-password):
```bash
sf share password list --space my-space
sf share password rotate pwd_xxxxxxxx --space my-space --password-from-stdin
sf share password revoke pwd_xxxxxxxx --space my-space
```
Rotating keeps the grant and its scope and immediately signs out sessions admitted by the old password. Revoking removes the grant so those sessions lose access too.
On the Space's [**Share**](https://my.spacefast.com/?to=/:team/:space/share) page, the **Password** card carries **Set password**, **Change password**, and **Remove password**, with **Expires**, **Paths**, and **What password holders can do** under **Password options**. The card manages one password; use the CLI or API for more.
## Invite people
Invite collaborators by email with [`sf share people`](/cli/reference/share#sf-share-people):
```bash
sf share people invite person@example.com --space my-space --role commenter --scope /docs
sf share people list --space my-space
sf share people remove person@example.com --space my-space
```
`--scope` defaults to `/` and is repeatable, so one invitation can grant the same role on several subtrees. `--target` defaults to `live`.
On the Space's [**Share**](https://my.spacefast.com/?to=/:team/:space/share) page, the **People** card takes an email, a **What they can do** role, and a **What they get access to** scope. Pending rows show **Invitation pending** with **Resend** (`sf share people resend`) and **Remove** actions.
A person can hold up to 32 scoped grants on one Space, so one collaborator can hold different roles on different subtrees. An invitation expires after 7 days; **Resend** issues a fresh one.
## Machine credentials
For a script or automated job, issue a bearer token rather than sharing a link:
```bash
sf share token create --space my-space --name "Nightly export" --path '/exports/**'
sf share token list --space my-space
sf share token rotate mch_xxxxxxxx --space my-space
sf share token revoke mch_xxxxxxxx --space my-space
```
The token is shown once, right after creation. Rotating keeps the grant and its scope and invalidates the old token immediately.
A machine credential can hold any role. `viewer` reads pages, `editor` can also publish to that Space through the API, and `manager` can also manage its access. The dashboard form sets name, paths, role, and expiry on `live`; use the CLI for other targets or exclusions.
Send the token in the right header for the destination:
| Request destination | Header |
| --- | --- |
| The Space itself, such as `https://my-space.space.fast/exports/latest.csv` | `X-SF-Authorization: Bearer sfm_...` |
| The Spacefast API, such as a publish | `Authorization: Bearer sfm_...` |
On the Space, the ordinary `Authorization` header belongs to your own application and passes through untouched, so it never admits a visitor.
## Access requests
A visitor who lands on a Space they cannot open can ask for access. The form takes an email and an optional message of up to 280 characters. The visitor confirms the request through an emailed link within 30 minutes, and team owners and admins receive an email with a review link.
Manage pending requests in the **Access requests** card on the Space's [**Share**](https://my.spacefast.com/?to=/:team/:space/share) page or with [`sf share request`](/cli/reference/share#sf-share-request):
```bash
sf share request list --space my-space
sf share request approve arq_xxxxxxxx --space my-space
sf share request deny arq_xxxxxxxx --space my-space
```
Approving invites the requester to the path they asked about as a `viewer` unless you pass `--role`. The dashboard's **Approve as Can view** offers the exact path or its subtree. A Space holds at most 25 pending requests, and a request expires after 14 days.
A person who already accepted an invitation but lost their session gets back in the same way: a confirmed request that their existing grants already cover is approved automatically.
## Sign in with Spacefast
Sign in with Spacefast works in two places: signing visitors in to your private Spaces, and letting your own Spaces or applications accept Spacefast accounts through OAuth.
### Visitor sign-in on private Spaces
On a claimed private Space, visitors can choose **Continue with Spacefast** on the access page to sign in with their Spacefast account. Spacefast runs an OpenID Connect authorization code flow with PKCE (`openid`, `profile`, and `email` scopes) through the Space's managed client. It then checks the account's grants against the requested path and returns the visitor to that page.
Visitors can manage their own Space sessions through the API:
- [`acceptSharedSpaceInvitation`](/api/reference/account/acceptsharedspaceinvitation): accept an invitation to a shared Space.
- [`signOutOfSharedSpace`](/api/reference/account/signoutofsharedspace): sign out of one Space everywhere.
- [`leaveSharedSpace`](/api/reference/account/leavesharedspace): decline an invitation or leave a shared Space.
### Offer Sign in with Spacefast in your app
Register an OAuth app on your team with [`sf oauth-apps create`](/cli/reference/oauth-apps#sf-oauth-apps-create) (or [`createOAuthApp`](/api/reference/teams/createoauthapp)) so visitors can sign in to your Space or external app with their Spacefast account:
```bash
sf oauth-apps create \
--name "Guestbook" \
--redirect-uri https://my-space.space.fast/auth/callback
sf oauth-apps list
sf oauth-apps inspect
sf oauth-apps update --name "Guestbook Prod"
sf oauth-apps delete
```
Apps are public by default and run an OpenID Connect authorization code flow with PKCE (`openid`, `profile`, and `email` scopes). Pass `--confidential` only for a server-side app; its client secret prints once, and you can rotate it with [`sf oauth-apps secret rotate`](/cli/reference/oauth-apps#sf-oauth-apps-secret-rotate-app). Run [`sf oauth-apps inspect`](/cli/reference/oauth-apps#sf-oauth-apps-inspect-app) to read the app's OpenID Connect endpoints (`https://api.spacefast.com/v1/auth/oauth2/authorize`, `https://api.spacefast.com/v1/auth/oauth2/token`) and redirect URIs.
Building a [SpacePress](/build) app? You do not need to register a separate OAuth app: link visitors directly to `/__spacefast/sign-in?return=/path/` (or scaffold it with `sf add auth`). See [App users and sign-in](/users).
## What a visitor sees
- **On a public Space**: the page loads with no access check.
- **With a share link**: the token is redeemed before the file is read, so the first request returns the document. The response is never stored in any cache and carries `Referrer-Policy: no-referrer` so the secret does not leak on outbound clicks.
- **On a protected Space with no proof**: the request answers **403** with the Space's access page and `Cache-Control: private, no-store`. On a claimed Space, the page offers **Continue with Spacefast** and a request-access form. It adds a password box when the Space has a password, and a **Continue with ``** button for each [SSO connection](/sso) the Space has a grant for.
- **Submitting a password**: the form posts to the same origin and Spacefast verifies it. On success, it sets the visitor's session cookie and redirects with **303** back to the original path. Passwords are capped at 1024 bytes.
- **With `--require-verified-email`**: a link or password adds one step where the visitor enters an email and clicks a confirmation link within 15 minutes. The proof lasts 1 hour on that credential. Public grants and machine credentials cannot require it.
A visitor session expires after 7 days without use, or 30 days after it started.
Two behaviors can look like bugs and are not. A rewrite cannot widen access, because the visitor needs access to both the URL they asked for and the path it rewrote to. And a directory listing on a protected Space leaves out entries the visitor cannot open.
## Revoke every session at once
End every active visitor session on a Space immediately without a republish using [`sf access sessions revoke`](/cli/reference/access#sf-access-sessions-revoke):
```bash
sf access sessions revoke --space my-space
```
This signs out every visitor regardless of how they entered (share link, password, private open, or signed-in account). Grants stay in place, so anyone with a valid link or password can open the Space again on their next visit. To stop a link or password from working, revoke its grant.
## Defaults for new Spaces
A team chooses how its new Spaces start. In the dashboard:
1. Open team settings and go to [**Access**](https://my.spacefast.com/?to=/:team/settings/access).
2. Use the **Space access** card's **New spaces are** row.
| Preset | New Spaces start with |
| --- | --- |
| `private` | Access for the owning team |
| `public` | Access for the owning team, plus view access for anyone on the web |
The default is `private`. The API accepts the legacy value `team` and normalizes it to `private`. Changing the default applies only to Spaces created after the change. Neither preset creates a share link on its own.
The same card holds two team-wide switches:
- **Private spaces only**: while on, no Space in the team can be public. Turning it on revokes every public grant on the team's Spaces. Any later public grant, `public` default, or `access` block in `spacefast.config.ts` or `sf.jsonc` is refused or ignored with `team_private_spaces_only`. Invites, share links, and passwords keep working. Spaces made private by this switch stay private after you turn it off.
- **Hide from search engines**: every Space in the team serves `noindex` on its live hostnames, overriding the Space's own setting. It stays on while **Private spaces only** is on.
Only team owners and admins can change these switches, and only from the dashboard. For team-wide visibility audits and bulk lock-down on Enterprise plans, see [Security and trust](/security).
## CLI, API, MCP, and SDK