Programmatic Usage

Integrate Omnigent into your scripts, applications, and CI pipelines. Start agent sessions, send them work, and return to the same conversations for follow-up tasks. You can also open saved sessions in the Web UI to review their progress and results.

Every session you start this way is an ordinary Omnigent session, so it gets the same Web UI, sharing, and sub-agent support as one you start by hand. For request fields and response schemas, see the API Reference.

Before you start

Install Omnigent and configure the model credentials your agent needs. The examples use a local single-user server at http://127.0.0.1:6767. For a shared server, replace that URL and configure authentication before sending requests.

See Shared Server for deployment setup. Local single-user servers do not require per-request credentials.

Authentication for a shared server

Shared servers support both user authentication and optional machine tokens. The credentials you use depend on the server's authentication setup:

  • Accounts or SSO: Use your signed-in user's session cookie or CLI login bearer token for API requests. These support scheduled tasks as well as sessions, subject to your user's permissions.

    omni login "<server-url>"

    This prompts for your username and password for built-in accounts, or opens a browser for SSO. It saves credentials for subsequent CLI commands; it does not print a token for use in curl.

    For built-in accounts, you can also request a token directly:

    ACCESS_TOKEN=$(curl --fail-with-body "<server-url>/auth/login" \
      -H 'Content-Type: application/json' \
      -d '{"username": "<username>", "password": "<password>"}' \
      | jq -er '.token')

    Use it in API requests with -H "Authorization: Bearer $ACCESS_TOKEN". This username/password endpoint does not apply to SSO.

  • Authentication proxy: Connect through the proxy, which supplies your identity to Omnigent. Follow your proxy provider's authentication method; Omnigent does not issue a token for this mode.

  • Machine tokens: For unattended scripts, an administrator can enable machine access and provide a client ID and secret. These tokens support agent, host, runner, and session APIs, but cannot access scheduled tasks.

    curl --fail-with-body "<server-url>/oauth/token" \
      --data-urlencode grant_type=client_credentials \
      --data-urlencode "client_id=<client-id>" \
      --data-urlencode "client_secret=<client-secret>"

    Include the returned access_token in your API requests or Python SDK headers as Authorization: Bearer <access_token>. Tokens expire after one hour by default; run the same command to get a new one.

Start a session

From your repository, run an agent with -p to send a prompt, print its response, and exit. Use your agent directory or YAML file in place of ./my-agent/:

omni run ./my-agent/ -p "Review the changes in the latest commit"

Omnigent starts a local server and runner automatically. Sessions are saved by default; their URL appears on stderr when they start. Open it to follow progress in the Web UI:

Omnigent session: http://127.0.0.1:6767/c/conv_abc123

Common options:

OptionWhen to use it
-p "<prompt>" / --prompt "<prompt>"Run a task without an interactive chat; the response goes to stdout.
--server "<server-url>"Save the session on a shared server. The agent definition is uploaded, and tools still run on the machine invoking the CLI.
--no-sessionRun a disposable local task with no history to view or resume afterward.
--model "<model>"Override the agent's model. See Models & Credentials.
--harness "<harness>"Override the agent's harness. See Harnesses for supported configurations.
--continue / -cContinue the most recent conversation for the same agent.
--resume "<conversation_id>"Continue a specific conversation using the ID from its session URL.

These examples use an agent YAML or directory through omni run; native terminal harnesses have their own CLI behavior. To run tools on another machine or in a cloud sandbox, use the REST API's host options.

Send a message or continue a conversation

Use the session ID from the previous step to send a message to that session. Saved sessions can also be opened in the Web UI.

Use --continue (or -c) to send a follow-up prompt to the most recent conversation for the same agent:

omni run ./my-agent/ --continue -p "Now check whether the tests cover those changes"

To continue a specific conversation, use its ID:

omni run ./my-agent/ --resume "<conversation_id>" -p "Explain the first finding"

Use --resume when your automation runs multiple conversations and needs to target a specific one. Use the ID from the CLI's session URL, or look it up with GET /v1/sessions.

Find sessions and follow their progress

The CLI prints the session URL to stderr at startup and the collected assistant text to stdout when the run finishes. Open that URL to see the conversation and its progress.

Use the Python or REST tab to list saved sessions, retrieve history, or monitor an agent from your application.

Fork, archive, or stop work

To fork into an interactive session:

omni run ./my-agent/ --fork "<conversation_id>"

--fork cannot be combined with -p. For scripted forks, archiving, or cancellation, use the Python or REST tab.

Share a session

Use the permissions API to share a session on a reachable shared server. Your credentials need manage or owner access to the session, and the server's sharing settings must allow the requested access.

The examples use bearer-token authentication:

SERVER_URL="<server-url>"
SESSION_ID="<session-id>"
ACCESS_TOKEN="<access-token>"

For a specific user, level is 1 for read access, 2 to also send messages and interact with the session, or 3 to also manage sharing. Public access is always read-only (level: 1).

Use caseExample
Share with a specific user

Use the recipient's user ID on this server, such as their account username or SSO email. Repeating this request updates their existing access level.

curl --fail-with-body -X PUT "$SERVER_URL/v1/sessions/$SESSION_ID/permissions" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"user_id": "<user-id>", "level": 1}'
Make the session public

Grant __public__ read access so anyone who can sign in to the server can view the session through its URL, without an individual grant. The server must have public sharing enabled; this does not bypass sign-in.

curl --fail-with-body -X PUT "$SERVER_URL/v1/sessions/$SESSION_ID/permissions" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"user_id": "__public__", "level": 1}'
Inspect current grants
curl --fail-with-body "$SERVER_URL/v1/sessions/$SESSION_ID/permissions" \
  -H "Authorization: Bearer $ACCESS_TOKEN" | jq
Remove public access

Revoke the public grant; specific users' grants remain. To revoke a specific user instead, use their URL-encoded user ID in place of __public__.

curl --fail-with-body -X DELETE \
  "$SERVER_URL/v1/sessions/$SESSION_ID/permissions/__public__" \
  -H "Authorization: Bearer $ACCESS_TOKEN"

Send the recipient the session URL. A specific user must sign in with the identity you granted access to:

echo "$SERVER_URL/c/$SESSION_ID"

You can also let an agent share sessions through sys_session_share. Set agent_session_sharing: non-public in its agent configuration to allow sharing with users, or agent_session_sharing: public to also allow public grants. The tool accepts user_id, level ("read", "edit", or "manage"), and an optional session_id that defaults to the calling session. The caller's permissions and server sharing settings still apply.

Edit an installed agent's configuration

Agents you install on a server keep their config.yaml bundle server-side. Instead of re-uploading the whole bundle to change a description, prompt, model, harness, or MCP server, you can read the editable fields and send a partial update over the REST API. Only the agent's owner can read or edit its configuration, even when a session that uses the agent is shared.

Check the server advertises support first: GET /v1/info returns agent_config_edit: true when configuration editing is available. Older servers omit the field; treat that as unsupported. On servers that lack support, the endpoints below return 501.

SERVER_URL="http://127.0.0.1:6767"
AGENT_ID="<agent-id>"   # from GET /v1/agents
Use caseExample
Read the editable configuration

Returns id, name, version, description, harness, model, the literal instructions, and mcp_servers keyed by server name. Each MCP entry lists its transport, description, url, command, args, and editable flag, plus the names of configured credentials in configured_header_names and configured_env_names. Credential values are never returned, and responses are sent with Cache-Control: no-store.

curl -fsS -i "$SERVER_URL/v1/agents/$AGENT_ID/config"

Save the ETag response header; the update request requires it:

ETAG=$(curl -fsS -D - -o /dev/null "$SERVER_URL/v1/agents/$AGENT_ID/config" \
  | tr -d '\r' | awk 'tolower($1) == "etag:" { print $2 }')
Update only the fields you send

Send a JSON body with If-Match set to the saved ETag. Omitted fields keep their current contents, including credentials, skills, and other bundled files. The response returns the updated configuration and a new ETag.

curl --fail-with-body -X PATCH "$SERVER_URL/v1/agents/$AGENT_ID" \
  -H 'Content-Type: application/json' \
  -H "If-Match: $ETAG" \
  -d '{
    "description": "Reviews migrations",
    "instructions": "Check compatibility and rollback steps.",
    "mcp_servers": {
      "docs": {"url": "https://docs.example.com/mcp"},
      "old-tool": null
    }
  }' | jq

A request without If-Match returns 428; a stale tag returns 412 (precondition_failed). Reload the configuration and reapply your change before retrying.

The body accepts these top-level fields. Unknown fields are rejected, and the agent's name and executor.type cannot change.

FieldBehavior
descriptionReplaces the description; null clears it.
instructionsReplaces the literal instructions; null or "" clears them. Clearing does not restore a bundled AGENTS.md.
modelNonempty string that replaces executor.model. Requires executor.type: omnigent; other executors return 409.
harnessNonempty harness id that replaces executor.config.harness. Requires executor.type: omnigent. See Harnesses.
mcp_serversMap of server name to a partial declaration or null. null deletes the server, an object patches it, and {} changes nothing. New servers need a complete http or stdio declaration including transport.

Within an MCP server patch:

A few things to know:

Automate recurring work

An automation runs an agent with a saved prompt on a recurring schedule, with no one at the keyboard. Each run starts a new session, or continues one kept session, so you can follow and review runs in the Web UI like any other session. The web UI calls these Automations; the API and agent tools call them scheduled tasks (/v1/scheduled-tasks).

You can create the same automation in three ways:

Each automation belongs to the user who created it, and you can see only your own. Whichever way you create one, a host must be online when the automation runs, or the automation must use a fresh cloud sandbox for each run. The agent also needs credentials and tool permissions that work without a person approving requests.

Each run sends your prompt followed by a short note that tells the agent no one is watching. See Scheduled Tasks for the full configuration, and How a firing runs for the run sequence.

Manage automations with the REST API

Before you call these endpoints:

SERVER_URL="http://127.0.0.1:6767"
# For a shared server, add -H "Authorization: Bearer $ACCESS_TOKEN" to each request.
Use caseExample
Create an automation

Run a review every weekday at 9am on a connected host. Get the agent ID from GET /v1/agents and the host ID from GET /v1/hosts. TASK_ID stores the new automation's ID:

TASK_ID=$(curl --fail-with-body "$SERVER_URL/v1/scheduled-tasks" \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Weekday code review",
    "prompt": "Review the latest commit and report findings without editing files.",
    "rrule": "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;BYHOUR=9;BYMINUTE=0",
    "timezone": "America/Los_Angeles",
    "agent_id": "ag_reviewer",
    "host_id": "host_example",
    "workspace": "/home/ci/my-repository"
  }' | jq -er '.id')
Run it now

Start a run immediately to test the automation. This does not change the schedule, and it also works on a paused automation. The server returns 202 and starts the run in the background:

curl --fail-with-body -X POST "$SERVER_URL/v1/scheduled-tasks/$TASK_ID/run"
Check run history

List the most recent runs, newest first. Open a run's session at $SERVER_URL/c/<conversation_id>:

curl --fail-with-body "$SERVER_URL/v1/scheduled-tasks/$TASK_ID/runs?limit=10" \
  | jq '.runs[] | {status, conversation_id, error_code}'

Run status values include running, succeeded, failed, and skipped. For a failed run, error_code gives the reason, such as no_online_host or host_offline. To read older runs, pass the returned next_cursor as after.

List your automations
curl --fail-with-body "$SERVER_URL/v1/scheduled-tasks" \
  | jq '.scheduled_tasks[] | {id, name, state, next_run_at, last_run_status}'
Update or pause

Pause the automation without deleting it:

curl --fail-with-body -X PATCH "$SERVER_URL/v1/scheduled-tasks/$TASK_ID" \
  -H 'Content-Type: application/json' \
  -d '{"state": "paused"}' | jq

Send {"state": "active"} to resume it. The same request can change fields such as prompt, rrule, timezone, or host_id; fields you don't send stay the same.

Delete

Stop all future runs and remove the run history. Sessions from earlier runs remain:

curl --fail-with-body -X DELETE "$SERVER_URL/v1/scheduled-tasks/$TASK_ID"

The create request requires name, prompt, rrule, and agent_id. The schedule is an RFC 5545 recurrence rule, evaluated in timezone (UTC by default). See Recurrence rules for the minimum interval. These optional fields control each run:

FieldBehavior
host_id, workspaceRun on a specific connected host and directory. A workspace requires a host_id. Omit both to use your most recently active online host and its home directory.
execution_targetconnected_host (default) or managed_sandbox, which starts each run in a fresh sandbox. Don't set host_id or workspace with managed_sandbox.
session_mode, session_idnew (default) starts a new session for each run. continue sends every run's prompt into one session, so the agent keeps the context from earlier runs.
model_override, reasoning_effortOverride the agent's model or reasoning effort for each run.
permission_modeThe native harness's permission mode, such as Claude Code's acceptEdits. A mode that asks for approval can leave an unattended run waiting.
max_cost_usdA cost cap for each run. Once the run's recorded cost reaches the cap, its later requests and tool calls are blocked.
project_idFile each run's session into one of your projects.

Schedule recurring agent runs

Ask an agent to create a scheduled task when you want the same work repeated. Omnigent provides four built-in tools:

ToolWhat it does
sys_scheduled_task_createSave a prompt, agent, and recurring schedule.
sys_scheduled_task_listList your scheduled tasks.
sys_scheduled_task_updateChange a task's prompt, schedule, or other settings.
sys_scheduled_task_deleteRemove a task so it no longer runs.

For example, replace the host name and repository path in this prompt:

Create a scheduled task named "Weekday code review". Every weekday at 9am
Asia/Singapore, run native Claude Code on host "my-host" in
/home/ci/my-repository. Ask it to review the latest commit and report findings
without editing files. Look up the agent and host IDs first.

The schedule uses this recurrence rule with timezone: "Asia/Singapore":

FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;BYHOUR=9;BYMINUTE=0

You can later ask, "Move Weekday code review to 10am," or "Delete Weekday code review." The agent uses the list and update or delete tools to make the change.

Creating or updating a task from an agent always pauses for your approval before anything is saved, even when no policies are configured — review the agent, prompt, host, and permission settings in the prompt before accepting. Listing and deleting tasks do not ask. See Approval for create and update.

Start a session for each new ticket, message, or issue

Automations created from Jira, Slack, or GitHub trigger templates in the Web UI are ordinary scheduled tasks with a generated prompt. You can list, run, pause, and delete them with the same endpoints and tools. The templates check for new items on a schedule; they don't receive webhooks. To react to events that the templates don't cover, receive the event in your own service, then start a session and send it the work with POST /v1/sessions and POST /v1/sessions/{id}/events.

Let an agent manage other sessions

You can ask an agent to delegate work to another Omnigent agent. It uses built-in session tools to create a child conversation, send instructions, and read the results. These are tools the agent calls during a session; you don't need to write an API client to use them.

ToolWhat it does
sys_agent_listFind available agents and their IDs.
sys_session_createCreate a child session from an existing agent ID or a local agent config, optionally with a first message.
sys_session_sendSend a follow-up to a child session, or start a named sub-agent declared by the parent agent.
sys_session_listFind child sessions and other sessions you can access. Pass include_archived to also list archived ones.
sys_session_get_infoCheck a session's status, agent, and workspace.
sys_session_get_historyRead a session's recent messages and tool results.
sys_session_closeClose a finished child session while retaining its history.

For example, send this prompt in an Omnigent session:

Find the native Claude Code agent and create a child session titled
"Review tests". Ask it to review the test coverage in this repository without
editing files. Read its findings and summarize the missing coverage for me.

The agent can use sys_agent_list to find the agent, then call sys_session_create with arguments like these:

{
  "agent_id": "<agent_id from sys_agent_list>",
  "title": "Review tests",
  "message": "Review the test coverage in this repository. Report missing coverage without editing files."
}

The returned conversation_id identifies the child. To continue its work, ask:

Ask the "Review tests" child session to prioritize its findings by risk.

By default, sys_session_list leaves out archived sessions. With include_archived: true, the global sessions view lists them too, and each row carries an archived field.

sys_session_send can write only to the calling session's direct children. For agents with named sub-agents, reusing the same agent and title continues that child conversation; a different title starts a separate one. Child sessions appear in the Web UI, where you can follow their progress.

Some agents bundle skills that coordinate this work for you. For example, Polly provides investigate, fanout, and cross-review.

API endpoints reference

These tables summarize the main endpoints for agents, sessions, and automations.

The server exposes these agent, host, and project endpoints. Replace {id} with an agent ID from GET /v1/agents.

MethodPathWhat you can do
GET/v1/agentsList server agents, or your own agents with scope=user
POST/v1/agentsInstall or reinstall one of your agents from a bundle
GET/v1/agents/{id}Read one agent's summary
DELETE/v1/agents/{id}Remove one of your agents
GET/v1/agents/{id}/configRead an owned agent's editable configuration and its ETag
PATCH/v1/agents/{id}Update only the supplied configuration fields; requires If-Match
GET/v1/hostsList your hosts and their IDs
GET/v1/projectsList your projects and their IDs

The server exposes these session endpoints. Replace {id} with a session ID.

MethodPathWhat you can do
POST/v1/sessionsCreate a session
GET/v1/sessionsList and filter sessions
GET/v1/sessions/{id}Read session details and status
PATCH/v1/sessions/{id}Rename, configure, archive, or unarchive
DELETE/v1/sessions/{id}Delete a session and its associated resources
POST/v1/sessions/{id}/forkCopy conversation history into a new session
GET/v1/sessions/{id}/itemsRead conversation history
GET/v1/sessions/{id}/child_sessionsList child sessions
GET/v1/sessions/{id}/streamReceive live events via SSE
POST/v1/sessions/{id}/eventsSend a message or interrupt active work
PUT/v1/sessions/{id}/permissionsGrant or update user/public access
GET/v1/sessions/{id}/permissionsList permission grants
DELETE/v1/sessions/{id}/permissions/{user_id}Revoke a permission grant
GET/v1/sessions/{id}/pull-requestsList the pull requests linked to a session

The server exposes these automation endpoints. Replace {id} with an automation ID from GET /v1/scheduled-tasks.

MethodPathWhat you can do
POST/v1/scheduled-tasksCreate an automation
GET/v1/scheduled-tasksList your automations
GET/v1/scheduled-tasks/{id}Read one automation
PATCH/v1/scheduled-tasks/{id}Update fields, or pause and resume
DELETE/v1/scheduled-tasks/{id}Delete an automation and its run history
POST/v1/scheduled-tasks/{id}/runStart a run now without changing the schedule
GET/v1/scheduled-tasks/{id}/runsRead run history, newest first

See the API Reference for request and response schemas and for other endpoints.