Skip to content

A grant is a short-lived token for one VM’s API. Give it to a person or a program instead of your key; it admits only the methods, paths and arguments you name, and anyone who holds it can use that scope until it expires.

The samples use a new VM named shared; VMs shows how to create one. A grant reaches the VM’s files and commands.

The create request returns a link that carries the token. The API keeps no record of a grant, so save the link when it is returned; there is no list of grants.

This grant admits GET under /home/user/ for one hour. The path is a glob: /home/user/** covers the folder and every file beneath it.

Terminal window
si svm grant create shared --method GET --path '/home/user/**' --ttl 1h
Output
https://6f1c0f0e8a.slashinfra.dev/?si_access=eyJ...

The link points at / on the VM’s host. Add the path of the file you want after the host, and keep ?si_access=, or send the token in a header. A scope that does not include / refuses the bare link with 403 forbidden.

The reply gives the expiry in expires_at, in milliseconds since the Unix epoch, and the generation that the grant is bound to.

To pin the arguments of a run, repeat --arg for each exact value. A grant for POST /bin/bash with --arg -c --arg 'make test' runs only that command.

The token is the part after si_access= in the link. Send it in Authorization or X-Si-Authorization as a bearer token, or in ?si_access=. A key starts with si_ and a grant token does not, so the gate tells them apart. A header keeps the token out of the URL, so it does not land in browser history or a screenshot.

A grant works only on the VM’s own host, not on the control API.

Set VM and GRANT once. Use the VM’s id and the token after si_access= in the link.

Terminal window
export VM=6f1c0f0e8a
export GRANT=eyJ...

The examples read /home/user/.profile, a file every VM starts with. The guest resolves the path beneath the scope root, so a symlink cannot leave the folder you named.

Terminal window
curl -sS "https://$VM.slashinfra.dev/home/user/.profile" \
-H "Authorization: Bearer $GRANT"
Output
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
...
Answer When
401 unauthorized The grant is malformed, expired, for another VM, or was minted before the last rotation.
403 forbidden The grant is valid, but the method, path or arg list is outside its scope.

Scroll horizontally to see all columns.

The gate answers both before the request reaches the VM, so neither wakes it. A request the grant admits does reach the VM and can wake it.

The samples send a PUT with the token in the query. The grant admits only GET, so the gate refuses it.

Terminal window
curl -sS -i -X PUT "https://$VM.slashinfra.dev/home/user/notes.txt?si_access=$GRANT" \
--data-binary 'hello'
Output
HTTP/2 403
...
x-si-error: forbidden
...
This request is not allowed. (forbidden)

Rotate ends every grant the VM has issued at once. You cannot revoke one grant alone. The gate applies the new generation within 30 seconds; until then, an older grant can still work. Port links have their own generation and keep working.

Terminal window
si svm grant rotate shared
Output
rotated every SVM API grant of SVM "shared"

The gate applies a rotation within 30 seconds; after that, the grant from Create a grant answers 401 unauthorized.

Terminal window
curl -sS -i "https://$VM.slashinfra.dev/home/user/.profile" \
-H "Authorization: Bearer $GRANT"
Output
HTTP/2 401
...
x-si-error: unauthorized
...
Sign in or send a valid API key. (unauthorized)
Field Type Default Allowed values What it changes
methods (--method) array of strings Required 1 to 16 uppercase methods; the CLI accepts GET, HEAD, POST, PUT, PATCH and DELETE The methods a request may use. Another method answers 403 forbidden.
paths (--path) array of strings Required 1 to 32 absolute path globs; * stays in one segment and ** crosses segments The paths a request may reach. Another path answers 403 forbidden.
args (--arg) array of strings Open 0 to 64 exact values, matched in order The arg values a request must carry. Omitting it leaves every argument list open; an empty list admits only a request with no arguments.
ttl_s (--ttl) number 3600 Whole seconds from 1 to 30 days; --ttl also accepts a number with s, m, h or d The life of the grant. A longer life answers 400 invalid_ttl.
ref (path) string Required The VM’s name or its id The VM whose API the grant reaches.
project (--project) string default A project name, or its proj_ id The project that holds the VM.

Scroll horizontally to see all columns.

Code When Fix
invalid_scope Create sends an empty method or path list, a list over the cap, a method that is not uppercase, or a path that is not absolute or has a . or .. segment. Send 1 to 16 uppercase methods and 1 to 32 absolute globs.
invalid_ttl Create sends a lifetime that is not a whole number of seconds from 1 to the plan’s maximum. Send whole seconds from 1 to 30 days, or omit it for 3600.
svm_not_found The ref names no VM in the project. Check the VM name or id, and the project.
project_not_found The project value names no project of the organization or key scope. Check the project name or id.
deleting The VM is being deleted. Wait for the delete to finish, or create another VM.

Scroll horizontally to see all columns.

Errors that any request can return are in the error catalog.

Operation Who can Key action
Create a grant Any member svm:write
Use a grant Anyone who holds the link None
Rotate the grants of a VM Any member svm:write

Scroll horizontally to see all columns.

  • A grant names 1 to 16 methods and 1 to 32 path globs. A list outside that range answers 400 invalid_scope.
  • A grant pins 0 to 64 arguments. Omitting args leaves every argument list open.
  • A method, path or argument has 1 to 4096 characters. A path glob is absolute and has no . or .. segment.
  • A grant lives 1 second to 30 days; the default is 3600 seconds.
  • A rotation ends every grant of the VM at once and the gate applies it within 30 seconds. Port links keep their own generation.
  • A token is bound to one VM and one generation. A token for another VM, another generation, or a past expiry answers 401 unauthorized.

The full list is in Limits.