# CLI reference

Every command of `sona`, the SDK's command-line tool, as `sona <command> --help` prints it: the synopsis, what it
does and its own options. The global options and the exit status at the foot hold for every command. How the
commands fit together, with worked examples, is in [the CLI guide](../guides/cli.md).

```sh
sona help
sona render --help
sona avatar random --help --json
```

## version

```text
sona version
```

Prints the CLI's and the SDK's version and the platform.

## help

```text
sona help [command]
```

Prints this overview, or one command's page (the same as `sona <command> --help`).

## catalogue

### catalogue search

```text
sona catalogue search [words...] [options]
```

Searches the offline catalogue (`sona-catalogue.bin`). Every word must be in the name, game or type; "in quotes" matches a whole name. By default only what the editor offers is listed.

- `--section <name>`: shirt, trousers, shoes, headwear, glasses, gloves, wristwear, ring, earrings, carryable, costume, hair, eyes, eyebrows, mouth, facialHair, eyeShadow, facialFeature, chin, nose, ears, body, head, animation, shape, other
- `--game <name>`: items from that game only
- `--body man|woman`: what the editor offers that body
- `--slots <mask>`: items with any of these AssetMask bits (0x40, or a slot name)
- `--require <flags>`: comma-separated flags that must be set: offered, named, stock, award, marketplace, hidden, notPickable, hasModel, glb, colourable, colourways, multiSlot
- `--exclude <flags>`: flags that must be clear
- `--all`: also items the editor does not offer, and hidden duplicates
- `--on-disk`: only items the `--dir` folders hold (what a render can draw)
- `--offset <n>, --limit <n>`: paging (limit 20 by default, at most 5000)

### catalogue show

```text
sona catalogue show <item id>
```

Everything the catalogue knows about one item. Exit 1 when it is not there.

### catalogue games

```text
sona catalogue games
```

The games items come from, with their item counts.

### catalogue sections

```text
sona catalogue sections
```

The section names `--section` takes.

## avatar

### avatar new

```text
sona avatar new [--body man|woman] [--from <starter>] [-o file]
```

A new avatar: the editor's own new avatar (the atlas starter in its default shoes), or one of the starters atlas, vega, juno and cutout. `--body` woman gives it the woman's body and default clothes.

### avatar random

```text
sona avatar random [--seed n] [--body man|woman] [--style s] [--palette p] [options] [-o file]
```

A random avatar from the catalogue (the core's sona_make_random): body, shape, colours, face, hair and an outfit with no clashes. The same seed, options and library give the same avatar, and a newer catalogue changes only the picks whose item left or was outscored. Needs `--catalogue`.

- `--seed <n>`: the random seed (default 1)
- `--style <s>`: any, casual, smart, sporty, costume (by the catalogue's item types)
- `--palette <p>`: natural, vivid, pastel, mono, fantasy (skin, hair, eyes, lips, make-up)
- `--game <name>`: clothes from that game only; `--tag` <words>: clothes whose name, game or type hold them
- `--set`: the clothes of one matched set; `--props`: sometimes a prop; `--plain`: no accessories
- `--on-disk`: only items the `--dir` folders hold
- `--no-costume`: never a costume

### avatar dress-like

```text
sona avatar dress-like <avatar> <like> [--parts list] [--match m] [--layer] [-o file]
```

Dresses <avatar> like <like>: each item made for the other body becomes its variant for this one (the same item for the other body, else the closest of its set, else with `--match` any one of its type). Without `--catalogue` only items both bodies wear come across.

- `--parts <list>`: clothes, props, hair, face, colours, shape or all (default clothes,props)
- `--match <m>`: same, similar (default) or any
- `--layer`: keep this avatar's own clothes where nothing copied covers them
- `--on-disk`: variants only from items the `--dir` folders hold

### avatar show

```text
sona avatar show <avatar>
```

What an avatar is: body, shape, what it wears (with names when `--catalogue` is given), its face, colours and whether a console would take it as it is.

### avatar validate

```text
sona avatar validate <avatar> [--console] [--build]
```

Checks an avatar: it parses, the manifest is valid, the body is known; reports whether it is clothed and console-ready. Exit 1 when a check fails.

- `--console`: console-ready is required too (a real console accepts it as it is)
- `--build`: also build it through the sources (`--dir` or `--gate`) and fail on missing items

### avatar dress

```text
sona avatar dress <avatar> <item>... [--colours c1,c2,c3] [--stack-props] [--no-required] [-o file]
```

Wears items with the editor's rules (what a slot replaces, the required clothes). An item is an id, or with `--catalogue` an item's exact name.

- `--colours a,b,c`: the item's three colours (#rrggbb)
- `--stack-props`: keep the props already held
- `--no-required`: do not refill shirt, trousers and shoes

### avatar undress

```text
sona avatar undress <avatar> [<slot or item id>...] [--all] [--no-required] [-o file]
```

Takes off what a slot holds (shirt, hat, 0x40, ...) or one item; `--all` takes off everything but the hair.

### avatar colour

```text
sona avatar colour <avatar> <slot> <colour> [-o file]
```

Sets one of the nine colours: skin, hair, mouth, eyes, eyebrows, eyeShadow, facialHair, facialFeature, facialFeature2. Colours are #rrggbb or #aarrggbb.

### avatar shape

```text
sona avatar shape <avatar> [--weight w] [--height h] [-o file]
```

Sets the two body sliders, -1 to 1 (stored as given; beyond 1 saturates when drawn).

### avatar body

```text
sona avatar body <avatar> man|woman [--no-dress] [-o file]
```

Changes the body, and the clothes made for the other body, as the editor does.

### avatar ready

```text
sona avatar ready <avatar> [-o file]
```

Makes the avatar console-ready: one prop, the required clothes, the body's defaults. Exit 1 when it still is not (it wears a custom item).

### avatar filter

```text
sona avatar filter <avatar> --filter <list> [-o file]
```

The avatar through a content filter ([content filters](../guides/filters.md)): a denied shirt, trousers, shoes or hair becomes the slot's default, denied eyes, eyebrows and mouth the first allowed stock part, anything else denied comes off. Prints the avatar and, with `--json`, every change and why.

## outfit

### outfit check

```text
sona outfit check <avatar>
```

Every issue of an avatar's outfit: clashes, items for the other body, duplicates, misplaced items, missing slots, the shape, the last-worn cache, unknown or unlisted items, props. Exit 1 when there is an error. With `--catalogue` the catalogue's checks run too.

### outfit fix

```text
sona outfit fix <avatar> [-o file]
```

Mends every error the check finds, with the editor's own rules, and prints the avatar.

### outfit sets

```text
sona outfit sets [words] [--game g] [--body man|woman] [--offset n] [--limit n]
```

The catalogue's matched sets: items of one title that dress a body in two or more sections.

### outfit set

```text
sona outfit set <index or item id> [--body man|woman]
```

One matched set and its items.

### outfit clash

```text
sona outfit clash <item> <item>
```

Whether two items go together: a slot in common (one takes the other off), or no body that wears both.

## render

```text
sona render <avatar> -o <file.png> [options]
```

A picture of the avatar on a headless GPU device (Vulkan; D3D11 on Windows), transparent unless `--background` is given. The credit badge is drawn in the corner and the PNG carries the credit's text chunks.

- `--camera full|upper|bust|face`: the framing (default full)
- `--size WxH`: any size up to 8192 (default 512x512; one number is square)
- `--clip <key>`: a clip key (`sona clips`), idle or still (default still)
- `--time <s>`: seconds into the clip
- `--yaw <deg>, --pitch <deg>`: turn the camera about the avatar
- `--background <c>`: #rrggbb or #aarrggbb (default transparent)
- `--shadow`: the key light's shadow
- `--no-credit`: leave the badge out (the licence still requires the credit where the picture is shown)
- `--backend vulkan|d3d11, --cpu`: pick the device; `--cpu` takes a software rasteriser

## filter

### filter tags

```text
sona filter tags [--filter <list>]
```

The content tags (the built-in ones derived from the catalogue, and any a rules file adds) with how many items carry each, and how many items the `--filter` allows.

### filter check

```text
sona filter check <item id>... --filter <list>
```

The filter's verdict on items: allowed or not, why, their section, source and tags. Exit 1 when one is denied.

## clips

```text
sona clips
```

The clip keys render and export take.

## export

```text
sona export glb|fbx|roblox <avatar> -o <file> [--clip key] [--time s] [--rigged] [--clips k,...] [--bones unity|vrm|vrm0|ue4|ue5]
```

glb: a glTF 2.0 binary of the avatar as posed (still by default): every part it draws, skinned on the CPU, with its colour texture and vertex colours, +Y up and facing +Z. glb `--rigged`: the avatar on its skeleton in the T-pose, bones named by `--bones` (default unity). fbx: the same as binary FBX 7.4. `--clips` (rigged glb and fbx): those clips as animations on the skeleton. roblox: an FBX for Roblox Studio's avatar import: R15 part names, a T-pose, no props, no clips, and hair, hats, glasses, earrings, wristwear and rings left off.

## manifest

### manifest unpack

```text
sona manifest unpack <avatar> [-o file.json]
```

The manifest form: every field of the 1000-byte manifest as JSON, to read or edit.

### manifest pack

```text
sona manifest pack <form.json> [-o file]
```

A manifest form back to the 1000 bytes (byte for byte what it was unpacked from).

## item

### item templates

```text
sona item templates
```

The 28 custom-item templates (the custom items guide).

### item new

```text
sona item new <dir> --template <id or name> --name <text> [options]
```

A custom-item source folder: item.json and a white blank.png of the template's size to paint color.png from.

- `--body man|woman|both`: which template, when a name is made for more than one body
- `--pair`: also the other body's folder (<dir>-man or <dir>-woman), with the paired id
- `--description, --creator, --licence`: <text>, `--layout` split|template, `--sha256` <hex>, `--force`

### item id

```text
sona item id --template <id or name> [--body man|woman|both]
```

A fresh custom id for a template.

### item check

```text
sona item check <file.sonaitem> [--deep]
```

The loader's verdict on a `.sonaitem`: rules 1 to 11, with the rule that failed. `--deep` reads the template through the sources too (its hash, rule 12, smaller textures). Exit 1 when refused.

### item pack

```text
sona item pack <dir> [-o file] [--no-sign] [--key file] [--dry-run]
```

Packs a source folder into a `.sonaitem`, signed with your creator key (`--key`, `$SONA_CREATOR_KEY` or `~/.sona/creator.key`, made on first use). The same bytes the web packer writes. A change since the last pack raises the version.

### item unpack

```text
sona item unpack <file.sonaitem> <dir> [--force]
```

The folder form back: item.json naming PNGs; each PNG keeps its texture so packing it untouched gives the same blocks.

### item preview

```text
sona item preview <item id or file.sonaitem> -o <file.png> [--size WxH] [--body man|woman]
```

The item worn alone on a grey stand-in body, framed by its slot.

### item mesh

```text
sona item mesh <file.glb> --template <id or name> --name <text> [options]
```

A format 1.1 item from your own skinned glb (the custom items guide): the mesh, its skin and its textures checked (rule 13) and packed with the template's slot and body, signed like pack. Reads the template and the rig through the sources (`--dir` with avatar-rig.json). The same bytes as sona-item mesh.

- `--body man|woman|both`: which template, when a name is made for more than one body
- `--fit template|none`: none: no coverage check against the template (default template)
- `--id <item id>`: keep an id (default: a fresh one); `--version` <n>
- `--description, --creator, --created`: <yyyy-mm-dd>, `--item-licence` <text>
- `-o <file>`: default <file without .glb>.sonaitem; `--no-sign`, `--key` <file> as pack

## app

### app show

```text
sona app show --app <id> [--app-key-file <file>] [--server <url>]
```

Your app on 360sona, by its key: name, sign-in settings, branding, origins, the SDK Licence and downloads. The key comes from `--app-key-file`, `$SONA_APP_KEY` or the file `$SONA_APP_KEY_FILE` names; the server from `--server` or `$SONA_SERVER` (default https://test.360sona.com). The Studio's Consoles and Apps pane does the same.

- `--server <url>`: the 360sona server (default https://test.360sona.com)
- `--app-key-file <file>`: a file holding the app's key (sak_...)

### app origins

```text
sona app origins [list | add <origin>... | remove <origin>... | set <origin>...]
```

The web origins that may draw with your app id (https://example.com, or http://localhost for testing).

### app request

```text
sona app request --name <app name> --contact <e-mail> --about <text> --agree "I have read and understand the Developer Terms" --app-key-file <file>
```

Asks for an app id (POST /sona/v1/requests). A read-only app is approved at once: the id is printed and the key, which is shown once, is written to `--app-key-file` (or the file `$SONA_APP_KEY_FILE` names) and never printed. Anything more waits for a person, and the command exits 1 saying so. `--contact` is the developer's own address; the agreement is recorded with the time. Read the terms first: <server>/devterms.html. Nothing is asked: a missing value is exit 2 with the flag to pass.

- `--wants lookup|signin`: what the app does (default lookup); signin needs `--redirect` <url>
- `--force`: replace a key file that already holds a key

### app licence

```text
sona app licence --agree "I have read and understand the SDK Licence"
```

Accepts the SDK Licence for the app, which downloads need. The server records the app and the time. Without `--agree` it changes nothing: it prints where the licence is and the sentence, and exits 2. Read it first: https://360sona.com/devterms.html#sdk-licence

### app download

```text
sona app download <platform> [-o file.zip] [--unpack <folder>] [--with-catalogue] [--force]
```

Downloads the SDK made for your app: web, or a native platform (windows-x64, linux-x64, linux-arm64, macos, ios, android, xbox360, unity, unreal, godot), stamped with the app and a new build id, with `sona-licence.json`. `--with-catalogue` adds the offline catalogue. `--unpack` writes the files into a folder (no unzip needed): set SONA_SDK to that folder and every command finds the licence, the catalogue and the `sona made for your app`.

### app tools

```text
sona app tools <platform> [-o file]
```

Downloads the tools installer (sona, sona-mcp, SDK Studio, the offline docs) for windows-x64, linux-x64 or macos and checks its SHA-256. The first copy comes with curl: GET /sona/v1/apps/<id>/tools?platform=<platform> with the app's key.

### app builds

```text
sona app builds
```

Every native build made for your app, newest first, and whether it was revoked.

### app revoke

```text
sona app revoke <build id>
```

Turns one native build off: it can no longer read from the gate.

### app usage

```text
sona app usage
```

Today's items and answers against the daily allowance.

## console

### console list

```text
sona console list <Content folder> [--catalogue file]
```

The avatar items stored on a console: a Content folder (Content/<profile>/<title>/00009000/), as copied off a development kit or its drive. The same folder works as a source (`--dir` takes asset folders; the Studio takes console:<Content folder>).

## project

### project templates

```text
sona project templates
```

The project templates (the Studio's Projects pane, sona-mcp).

### project list

```text
sona project list [--projects <folder>]
```

The projects in a folder (default: the Studio's, `~/360sona` Projects or Documents\360sona Projects).

### project new

```text
sona project new <dir> [--template t] [--name n] [--avatar <avatar>]
```

A project from a template, with the avatar (default the starter) and your licence file in it.

- `--sdk-include <dir>, --sdk-library <file>`: the SDK it builds against (default: `--sdk` or `$SONA_SDK`)

### project build

```text
sona project build <dir> [--jobs n] [--sdk-include dir --sdk-library file]
```

Configures and builds the project with CMake; the log is .sona/build.log.

### project run

```text
sona project run <dir> [-- <args>...]
```

Runs the built project and reads its log and frame stats (.sona/run.log).

## scene

```text
sona scene [--count n] [--outfits starters|random] [--frames n] [--size WxH] [--clip key] [-o shot.png]
```

The Studio's Scene on the command line: n avatars (1 to 10,000) in a grid on a headless device, every one ready, then timed frames: sona_update, and a draw read back as sona_snapshot does. `--outfits` random dresses each from the catalogue with items the `--dir` folders hold. sona-bench measures GPU time on its own device.

## docs

### docs list

```text
sona docs list [--docs <folder>]
```

The SDK's Markdown pages (the Studio's Docs pane, offline).

### docs search

```text
sona docs search <words...>
```

Every line of the docs that has all the words, any case.

### docs show

```text
sona docs show <page>
```

One page as text.

## mcp

```text
sona mcp [--http <port>] [--root <folder>] [options]
```

The SDK's MCP server, as sona-mcp: stdio by default, `--http` on a loopback port too (0 picks one; `--stdio` keeps stdio as well). Agents search items, dress and render avatars, and make, build and run projects.

- `--root <folder>`: where projects go and writes may land (default: the working folder)
- `--allow-write <folder>`: another folder writes may go in (up to 8)
- `--allow-writes-anywhere, --allow-exec`: lift the write sandbox, or let agents build edited projects
- `--config <file.json>`: the same settings from a file (also `$SONA_MCP_CONFIG`); `$SONA_MCP_ROOT`, `$SONA_MCP_ALLOW_WRITE` and SONA_MCP_ALLOW_EXEC=1 set them from the environment
- `--port-file`: <file>, `--token-file` <file>, `--samples` <devs-cast.json>

## Global options

Every command takes these.

- `--json`: print the result as one JSON object (every command)
- `-o, --out <file>`: where a command writes its file; - is stdout
- `--sdk <folder>`: the SDK made for your app, unpacked (or `$SONA_SDK`): its licence, catalogue and the `sona made for your app`, which runs every command that draws or exports
- `--dir <folder>`: an asset folder the avatar's items are read from (up to 4; or `$SONA_DIR`)
- `--gate, --gate-url <url>`: read items from the 360sona gate (needs the app's licence and the network)
- `--server <url>`: the 360sona server (or `$SONA_SERVER`): the app commands, and the licence check of `--gate`
- `--licence <file>`: `sona-licence.json` (else `$SONA_LICENCE`, <sdk>/sona-licence.json, ./sona-licence.json; testing builds fall back to the test licence)
- `--app <id>`: the app id (default: the licence's)
- `--catalogue <file>`: `sona-catalogue.bin` (else `$SONA_CATALOGUE`, <sdk>/data/sona-catalogue.bin)
- `--filter <list>`: a content filter: presets (family, no-logos, no-licensed) and rules files, comma-separated; searches, random avatars and renders leave out what it denies (needs `--catalogue`)
- `--timeout <s>`: how long an avatar may take to build (default 120)
- `--threads <n>`: worker threads (default 0: everything on the calling thread)
- `--quiet, --verbose`
- `-h, --help`: this page, or a command's page

## Exit status

| Code | Means |
|---|---|
| 0 | done |
| 1 | the answer is no: invalid, refused, not console-ready, not found |
| 2 | bad arguments |
| 3 | a file could not be read or written |
| 4 | an input did not decode (manifest, item, PNG, JSON) |
| 5 | not available here (no GPU device, not in this build) |
| 6 | the SDK refused (licence, sources, an avatar that did not build, a gate that gave no files in time) |
| 7 | out of memory or a bug |
