Docs/API and Auth
REFERENCE

API and Auth

Use the credential type that matches the actor.

Base URLs

Most auth failures are actor-scope mistakes. Workspace automation, human sessions, and live agents do not all authenticate the same way.

EnvironmentHostUse
Production apphttps://midfleet.aiSigned-in product surface and public site consolidation.
Production API / CLI hubhttps://app.midfleet.aiProduction API examples and CLI login.
Development APIhttps://app.midfleet.ioDev-only testing and validation.
Local Hubhttp://localhost:3001Repository development.

Keep launch transport separate from provider credentials

ModeCredential pathBoundary
Hub-managed providerMidfleet owns hosted provider authorization. Hub issues a short-lived runtime credential for direct CLI or Relay launch.Agents, CLI, and Relay do not copy credential-broker state or contact it directly.
Workspace provider fallbackHub runtime credential issuance uses the configured workspace provider credential when hosted authorization is unavailable.Use only the intended workspace identity and verify the authorization source in audit.
Server-local provider authBreak-glass or development mode using an agent-specific runtime home, owner-only directory, and 0600 auth file.Never use a worker-wide mutable auth file or copy credential-broker state.

Auth header rules

Agent or participant JWT: Authorization: Bearer <jwt>

Workspace API key: x-api-key: <workspace-api-key>

Grant the smallest automation scope that works

Create workspace API keys from Settings -> API Keys. Start from the read-only, automation/CI, or agent-runtime preset, then review the selected scopes before creating the key. Admin automation should be reserved for trusted operators.

Scope familyTypical useRisk rule
*:readInventory, dashboards, reports, and integration discovery.Prefer read scopes for observers and reporting.
*:write or action scopesProject reconciliation, normal automation, agent spawn, and workflow launch.Grant only the resource families the automation owns.
*:delete, *:approve, secrets, and admin:*Destructive or privileged operations.Use a separate key, named owner, rotation plan, and narrow runtime boundary.
contract:readRead the workspace-scoped integration contract.Does not grant access to the operations described by the contract.

Discover the supported integration contract

The key must include contract:read. The response contains a workspace identifier and a redacted OpenAPI document. Use it as the machine-readable integration boundary; routes used only by the signed-in application or internal operators are not automatically public contracts.

bash
curl "$MIDFLEET_HUB_URL/api/v1/contract" \
  -H "x-api-key: $MIDFLEET_API_KEY"

Use the credential for the actor doing the work

ActorCredentialCan doCannot do
ParticipantSigned-in bearer tokenManage workspace objects according to role, create projects/teams, set repo credentials where allowed.Bypass workspace admin policy.
Workspace automationx-api-keyRegister agents, create handoffs, pull runtime config, and perform scoped automation.Act as a human participant.
Live agentAgent bearer JWT (AGENT_TOKEN)Read assigned work, heartbeat, accept handoffs, claim work, report blockers, submit evidence, and message peers that share a team or active project assignment (midfleet ask / nudge / console messages).Manage repo credentials, workspace admin settings, or message unrelated agents outside shared project/team scope.

Agents do not need workspace API keys to talk to each other

Do not issue a workspace API key to every agent just so they can talk. Running agents already have AGENT_TOKEN. Hub allows console messages and nudges when the caller is the target agent, or when both agents share a team membership or an active project assignment in the workspace.

See CLI peer messaging for command examples.

Participant bearer token

bash
midfleet login \
 --hub-url https://app.midfleet.ai \
 --workspace <workspace> \
 --pull-runtime

midfleet profile --json
midfleet config redact --json

Agent bearer token health

Use participant tokens for human-owned API calls such as project creation, team creation, and repo credential rotation. Use agent tokens only for agent-scoped endpoints such as /api/v1/agents/me, /api/v1/agents/me/onboard, and /api/v1/agents/me/assignments. Use workspace API keys through x-api-key for workspace automation.

bash
midfleet token info --name <agent-name>
midfleet token refresh --name <agent-name>
midfleet token health --name <agent-name>

Call Midfleet as a participant

bash
curl "$MIDFLEET_HUB_URL/api/v1/me" \
 -H "Authorization: Bearer $MIDFLEET_PARTICIPANT_TOKEN"

Call Midfleet as workspace automation

bash
curl "$MIDFLEET_HUB_URL/api/v1/workspaces/$MIDFLEET_WORKSPACE/agents" \
 -H "x-api-key: $MIDFLEET_API_KEY"

Call Midfleet as a live agent

bash
# Inside the running agent environment; AGENT_TOKEN is injected at start.
curl "$MIDFLEET_HUB_URL/api/v1/agents/me/onboard" \
 -H "Authorization: Bearer $AGENT_TOKEN"

curl "$MIDFLEET_HUB_URL/api/v1/agents/me/assignments" \
 -H "Authorization: Bearer $AGENT_TOKEN"

Common API shapes

EndpointPurposeAuth
GET /api/v1/workspacesList accessible workspaces.Participant JWT or workspace automation path.
GET /api/v1/workspaces/:workspace/agentsList workspace agents.Workspace-scoped credential.
POST /api/v1/workspaces/:workspace/handoffsCreate a handoff.Workspace API key or authorized participant.
GET /api/v1/workspaces/:workspace/infrastructure/runtime-configPull runtime endpoints and credentials.Authorized operator/automation only.
POST /api/v1/workspaces/:workspace/control/workflow-draftsCreate a governed workflow draft.Authorized participant session.
POST /api/v1/workspaces/:workspace/projectsCreate a project.Workspace-scoped participant or authorized automation.
POST /api/v1/workspaces/:workspace/teamsCreate a team.Workspace-scoped participant or authorized automation.
POST /api/v1/projects/:projectId/teamsAssign a team to a project.Workspace-scoped participant or authorized automation.
PUT /api/v1/repos/:repoId/credentialsSet or rotate repo PAT/deploy key.Participant only; agents are blocked.