# uip agent publish

> `uip agent publish` packs an agent project and pushes the resulting package to Orchestrator as a new solution package version. The returned `PackageVersionKey` is the input to [`uip agent deploy`](./uip-agent-deploy.md).

`uip agent publish` packs an agent project and pushes the resulting package to Orchestrator as a new solution package version. The returned `PackageVersionKey` is the input to [`uip agent deploy`](./uip-agent-deploy.md).

Internally, `publish` runs a multi-stage pipeline:

1. If the input is a directory, it validates the project structure and packs it to a temporary `.uis`.
2. It extracts the `.uis`, migrates any `agent.json` / `resource.json` down to the expected `storageVersion` (currently `44.0.0`), and repacks.
3. It shells out to `uip solution pack` to produce a solution `.zip` (containing one or more `.nupkg` files).
4. It uploads the solution — either through the standard Solutions API (default), or directly to Orchestrator's package feed when `--direct` is set.

Requires an active CLI session (`uip login`).

## Synopsis

```
uip agent publish [path] [-t <tenant>] [-l <locationKey>] [-n <name>]
                  [--package-version <version>]
                  [--folder-id <id>] [--direct]
                  [--login-validity <minutes>]
```

All `uip agent publish` invocations honor the [global options](./global-options.md) (`--output`, `--output-filter`, `--log-level`, `--log-file`). Exit codes follow the [standard contract](./exit-codes.md).

## Arguments

- `[path]` *(optional, default `.`)* — Path to the agent project directory **or** an already-packed `.uis` file. A `.uis` input skips the pack step; everything downstream (migrate, repack, solution pack, upload) still runs.

## Options

| Flag | Default | Purpose |
|---|---|---|
| `-t, --tenant <tenant>` | *login tenant* | Target tenant. Required if the login session has no default tenant. |
| `-l, --location-key <guid>` | — | Optional GUID forwarded to the Solutions API `packagesUpload` call (used by the default upload path only). |
| `-n, --name <name>` | *agent `metadata.name`* → path basename | Package name. Becomes the `.uis` / `.zip` filename and the package name in Orchestrator. |
| `--package-version <version>` | `1.0.0` | Version string for the uploaded package. |
| `--folder-id <id>` | *login folder's org unit ID* | Orchestrator folder Org Unit ID. **Only consulted when `--direct` is set**; the default Solutions upload path ignores it. |
| `--direct` | off | Upload each `.nupkg` directly to Orchestrator's package feed and create a `Release` per package, bypassing the Solutions API. Use this when the Solutions deployment path fails or you want releases created immediately in a specific folder. |
| `--login-validity <minutes>` | `10` | Minimum minutes of token validity required. See [Authentication](./authentication.md). |

## Examples

```bash
# Publish the current project to the login tenant
uip agent publish --package-version 1.0.0

# Publish a specific project folder
uip agent publish ./my-agent --package-version 1.0.0

# Publish a pre-packed .uis
uip agent publish ./dist/my-agent.uis --package-version 1.0.0

# Direct upload into a specific folder (creates releases in that folder)
uip agent publish ./my-agent \
  --package-version 1.1.0 \
  --direct --folder-id 42

# Override tenant and name
uip agent publish ./my-agent \
  -t production \
  -n invoice-agent \
  --package-version 2.0.0
```

## Data shape (--output json)

**Default upload path** (`Code: "AgentPublish"`):

```json
{
  "Code": "AgentPublish",
  "Data": {
    "Status": "Published successfully",
    "Name": "my-agent",
    "Version": "1.0.0",
    "PackageVersionKey": "a1b2c3d4-0000-0000-0000-000000000050"
  }
}
```

The `PackageVersionKey` is what you pass to `uip agent deploy`.

### `--direct` path

```json
{
  "Code": "AgentPublish",
  "Data": {
    "Status": "Published to Orchestrator (direct)",
    "Name": "my-agent",
    "Version": "1.0.0",
    "Releases": [
      {
        "Name": "InvoiceAgent",
        "Key": "a1b2c3d4-0000-0000-0000-000000000055",
        "ProcessKey": "com.uipath.agent.InvoiceAgent"
      }
    ]
  }
}
```

In `--direct` mode, each `.nupkg` inside the solution `.zip` is uploaded separately, and a release is created per package. There is no `PackageVersionKey`; the corresponding concept is the per-release `Key` — usable directly with [`uip agent run start`](./uip-agent-run.md).

## Migration behaviour

`publish` expects a `storageVersion` no higher than `44.0.0`, while fresh Studio Web projects may be `47.0.0`. It silently rewrites `agent.json` and tool `resource.json` files inside the temporary extract directory to the expected schema before repacking. Your on-disk project is never modified.

Each migrated file produces a `Message` log entry (for example, `Migrated /tmp/…/agent.json: storageVersion 47.0.0 → 44.0.0`).

## Related

- [`uip agent pack`](./uip-agent-pack.md) — the local packing step (included internally).
- [`uip agent deploy`](./uip-agent-deploy.md) — install and activate the uploaded package version.
- [`uip agent validate`](./uip-agent-validate.md) — run static checks and migration against your on-disk project before publishing.

## See also

- [Authentication](./authentication.md) — sessions, tenants, and `--login-validity`.
- [Orchestrator: jobs](./uip-orchestrator-jobs.md) — where released agent processes ultimately run.
- [Global options](./global-options.md), [Exit codes](./exit-codes.md).
