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.
Create a grant
Section titled “Create a grant”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.
si svm grant create shared --method GET --path '/home/user/**' --ttl 1hhttps://6f1c0f0e8a.slashinfra.dev/?si_access=eyJ...curl -sS -X POST "https://api.slashinfra.com/svms/shared/grants" \ -H "Authorization: Bearer $SI_API_KEY" -H "Content-Type: application/json" \ -d '{"methods":["GET"],"paths":["/home/user/**"],"ttl_s":3600}'API reference: Control API operation
{"url":"https://6f1c0f0e8a.slashinfra.dev/?si_access=eyJ...","expires_at":1795963173000,"generation":0}import os, requests
res = requests.post( "https://api.slashinfra.com/svms/shared/grants", headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"}, json={"methods": ["GET"], "paths": ["/home/user/**"], "ttl_s": 3600},)res.raise_for_status()print(res.json()["url"])https://6f1c0f0e8a.slashinfra.dev/?si_access=eyJ...const res = await fetch('https://api.slashinfra.com/svms/shared/grants', { method: 'POST', headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ methods: ['GET'], paths: ['/home/user/**'], ttl_s: 3600 }),})if (!res.ok) throw new Error(await res.text())const grant = (await res.json()) as { url: string }console.log(grant.url)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.
Use a grant
Section titled “Use a grant”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.
export VM=6f1c0f0e8aexport 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.
curl -sS "https://$VM.slashinfra.dev/home/user/.profile" \ -H "Authorization: Bearer $GRANT"# ~/.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.
...import os, requests
res = requests.get( f"https://{os.environ['VM']}.slashinfra.dev/home/user/.profile", headers={"Authorization": f"Bearer {os.environ['GRANT']}"},)res.raise_for_status()print(res.text, end="")# ~/.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.
...const res = await fetch(`https://${process.env.VM!}.slashinfra.dev/home/user/.profile`, { headers: { Authorization: `Bearer ${process.env.GRANT!}` },})if (!res.ok) throw new Error(await res.text())process.stdout.write(await res.text())# ~/.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.
...What a refused grant answers
Section titled “What a refused grant answers”| 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.
curl -sS -i -X PUT "https://$VM.slashinfra.dev/home/user/notes.txt?si_access=$GRANT" \ --data-binary 'hello'HTTP/2 403...x-si-error: forbidden...This request is not allowed. (forbidden)import os, requests
res = requests.put( f"https://{os.environ['VM']}.slashinfra.dev/home/user/notes.txt", params={"si_access": os.environ["GRANT"]}, data=b"hello",)print(res.status_code, res.headers["X-Si-Error"])403 forbiddenconst url = new URL(`https://${process.env.VM!}.slashinfra.dev/home/user/notes.txt`)url.searchParams.set('si_access', process.env.GRANT!)const res = await fetch(url, { method: 'PUT', body: 'hello' })console.log(res.status, res.headers.get('X-Si-Error'))403 forbiddenRotate the grants of a VM
Section titled “Rotate the grants of a VM”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.
si svm grant rotate sharedrotated every SVM API grant of SVM "shared"curl -sS -X POST "https://api.slashinfra.com/svms/shared/grants/rotate" \ -H "Authorization: Bearer $SI_API_KEY"API reference: Control API operation
{"generation":1}import os, requests
res = requests.post( "https://api.slashinfra.com/svms/shared/grants/rotate", headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},)res.raise_for_status()print(res.json()["generation"])1const res = await fetch('https://api.slashinfra.com/svms/shared/grants/rotate', { method: 'POST', headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}` },})if (!res.ok) throw new Error(await res.text())const rotated = (await res.json()) as { generation: number }console.log(rotated.generation)1The gate applies a rotation within 30 seconds; after that, the grant from Create a grant answers 401 unauthorized.
curl -sS -i "https://$VM.slashinfra.dev/home/user/.profile" \ -H "Authorization: Bearer $GRANT"HTTP/2 401...x-si-error: unauthorized...Sign in or send a valid API key. (unauthorized)import os, requests
res = requests.get( f"https://{os.environ['VM']}.slashinfra.dev/home/user/.profile", headers={"Authorization": f"Bearer {os.environ['GRANT']}"},)print(res.status_code, res.headers["X-Si-Error"])401 unauthorizedconst res = await fetch(`https://${process.env.VM!}.slashinfra.dev/home/user/.profile`, { headers: { Authorization: `Bearer ${process.env.GRANT!}` },})console.log(res.status, res.headers.get('X-Si-Error'))401 unauthorizedOptions
Section titled “Options”| 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.
Errors
Section titled “Errors”| 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.
Permissions
Section titled “Permissions”| 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.
Limits
Section titled “Limits”- 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
argsleaves 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.
- Who can reach your VM: grants beside roles, keys and port links.
- Web addresses: port links keep their own generation when you rotate grants.
- Control API grants: every operation, field and status code.