Skip to main content

Workloads

Workloads are compute jobs on Targon. The API uses a register-then-deploy flow:

  1. RegisterPOST /tha/v3/orgs/{org_slug}/workloads saves configuration. State is registered.
  2. DeployPOST /tha/v3/orgs/{org_slug}/workloads/{workload_uid}/deploy provisions runtime resources.

Updating a running workload (outside registered, suspended, or deleted) triggers an automatic redeploy.

Workload types

RENTAL

Dedicated container deployed via targon-op. Supports volumes, SSH keys, exec, and persistent storage. Maps to inventory type rental.

VM

Virtual machine deployed via the Targon VM master. Requires vm_config.password. Does not support envs, commands, args, registry_auth, or volumes. Maps to inventory type vm.

See the Virtual Machines guide for dashboard workflows and SSH access.

BM

Dedicated physical server claimed from Targon Mainframe. Requires region and at least one SSH key. Optional bm_config.hostname and reservation_uid. Does not support envs, ports, commands, args, registry_auth, volumes, or experiments. Maps to inventory type bm.

See the Bare Metal guide for region selection and SSH access.

Lifecycle states

StatusDescription
registeredCreated; awaiting deploy
provisioningDeploy in progress
runningHealthy / ready
errorFailure
suspendedSuspended; runtime removed (not supported for VM)
deletedSoft-deleted

Authentication

All workload endpoints are scoped to an organization. Replace {org_slug} with your organization slug.

Authenticate with a personal access token or org service token:

Authorization: Bearer <YOUR_API_TOKEN>

JSON request bodies reject unknown fields.

Pagination: list endpoints accept limit (default 1000) and cursor (UID of the last item from the previous page). Responses include next_cursor.


Create Workload

POST /tha/v3/orgs/{org_slug}/workloads

Request body

FieldTypeDescription
typestringRequired. RENTAL, VM, or BM
namestringRequired. Lowercase alphanumeric and hyphens, max 32 characters
imagestringRequired. Container image reference (RENTAL), VM image name (VM), or BM image name (BM)
resource_namestringRequired. Inventory resource name (e.g. h200-small)
regionstringRequired for BM. Active region UID (lowercase slug, max 32 characters). Not for other types
reservation_uidstringBind to an ACTIVE reservation. VM and BM only
envsarrayEnvironment variables. RENTAL only
portsarrayPort mappings. See Port object. Not for BM
commandsarrayContainer command override. RENTAL only
argsarrayContainer arguments. RENTAL only
registry_authobjectPrivate registry credentials. RENTAL only
ssh_keysarraySSH key UIDs to attach. Required for BM
volumesarrayVolume mounts. RENTAL only
vm_configobjectRequired for VM. See VM config
bm_configobjectOptional for BM. See BM config
project_idstringOptional project UID to assign the workload
experimentsobjectFeature experiments (config-gated). Keys: reserved-gpu, persistent-workload. Not for BM

Port object

FieldTypeDescription
portintegerRequired. 1024–65535
protocolstringTCP, UDP, or SCTP (VM: TCP / UDP only)
routingstringPROXIED (default) or DIRECT (max 10 direct ports per workload)

Env object

FieldTypeDescription
namestringVariable name
valuestringVariable value

Registry auth object

FieldTypeDescription
serverstringRegistry server URL
usernamestringRegistry username
passwordstringRegistry password or token

Volume mount object

FieldTypeDescription
uidstringRequired. Volume UID
mount_pathstringRequired. Absolute path inside the container
read_onlybooleanMount read-only. Default false

VM config

FieldTypeDescription
passwordstringRequired. Min 4 characters

BM config

FieldTypeDescription
hostnamestringRFC 1123 hostname (lowercase letters, digits, hyphens, dots; max 63 characters). Defaults to the workload name

Example: Rental

curl -X POST https://api.targon.com/tha/v3/orgs/{org_slug}/workloads \
-H "Authorization: Bearer <YOUR_API_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"name": "my-training-job",
"image": "pytorch/pytorch:latest",
"resource_name": "h200-small",
"type": "RENTAL",
"ports": [
{"port": 8080, "protocol": "TCP", "routing": "PROXIED"},
{"port": 2222, "protocol": "TCP", "routing": "DIRECT"}
],
"volumes": [
{"uid": "vol-xyz789abc123", "mount_path": "/data"}
],
"ssh_keys": ["shk-def456ghi789"]
}'

Example: VM

curl -X POST https://api.targon.com/tha/v3/orgs/{org_slug}/workloads \
-H "Authorization: Bearer <YOUR_API_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"name": "my-confidential-vm",
"type": "VM",
"image": "<vm-image-name>",
"resource_name": "h200-small",
"ssh_keys": ["shk-def456ghi789"],
"vm_config": {
"password": "your-sudo-password"
}
}'

List available VM images with GET /tha/v3/orgs/{org_slug}/workloads/vm-images. See the Virtual Machines guide.

Example: Bare Metal

curl -X POST https://api.targon.com/tha/v3/orgs/{org_slug}/workloads \
-H "Authorization: Bearer <YOUR_API_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"name": "my-bare-metal",
"type": "BM",
"image": "<bm-image-name>",
"resource_name": "<hardware-class>",
"region": "us-ord-1",
"ssh_keys": ["shk-def456ghi789"],
"bm_config": {
"hostname": "gpu-node-01"
}
}'

List available BM images with GET /tha/v3/orgs/{org_slug}/workloads/bm-images. List regions with GET /tha/v3/region. See the Bare Metal guide.

Response

Returns WorkloadOperationResponse:

FieldTypeDescription
uidstringWorkload UID
typestringWorkload type
namestringWorkload name
imagestringContainer image
reservation_uidstringBound reservation UID (VM / BM, when set)
cost_per_hournumberHourly cost (USD)
resourceobjectResource details
revisionstringCurrent revision
volumesarrayVolume mounts
stateobjectCurrent state
created_atstringISO 8601 timestamp
updated_atstringISO 8601 timestamp

resource object: name, display_name, gpu_type, gpu_count, vcpu, memory, disk_size_mib, network_mode.

state object: status, message, urls, public_ip, ssh_port, ready_replicas, total_replicas.


List Workloads

GET /tha/v3/orgs/{org_slug}/workloads

QueryTypeDescription
limitintegerMax items
cursorstringPagination cursor
typestringFilter by workload type
statusstringFilter by status
project_idstringFilter by project UID
namestringFilter by name

Returns { "items": [...], "next_cursor": "..." }. Each item is a WorkloadOperationResponse.


Get Workload

GET /tha/v3/orgs/{org_slug}/workloads/{workload_uid}

Returns the full Workload object, including envs, ports, commands, args, registry_auth, ssh_keys, and experiments. BM workloads also include bm_config (region, hostname) and reservation_uid when bound.


Update Workload

PATCH /tha/v3/orgs/{org_slug}/workloads/{workload_uid}

All fields optional. Supported: name, image, envs, ports, commands, args, registry_auth, ssh_keys, volumes, project_id, experiments. Set project_id to "" to unassign a project.


Delete Workload

DELETE /tha/v3/orgs/{org_slug}/workloads/{workload_uid}

Returns 204 No Content. Tears down runtime and soft-deletes the workload.


Deploy Workload

POST /tha/v3/orgs/{org_slug}/workloads/{workload_uid}/deploy

Starts provisioning. Returns WorkloadOperationResponse. Checks credits and inventory availability (region-scoped for BM).

BM deploys are single-attempt: a 409 WORKLOAD_BM_CLAIM_CONFLICT means no capacity matched and nothing was claimed.


Suspend Workload

POST /tha/v3/orgs/{org_slug}/workloads/{workload_uid}/suspend

Suspends the workload and removes runtime resources. Not supported for VM or BM.


Reboot Workload

POST /tha/v3/orgs/{org_slug}/workloads/{workload_uid}/reboot

Reboots a VM workload. Not supported for BM.


Get Workload State

GET /tha/v3/orgs/{org_slug}/workloads/{workload_uid}/state

FieldTypeDescription
uidstringWorkload UID
workload_typestringWorkload type
statusstringCurrent status
messagestringStatus message
urlsarray{ "port", "url" } access URLs
public_ipstringPublic IP (when applicable)
ssh_portintegerSSH port (when applicable)
ready_replicasintegerReady replica count
total_replicasintegerTotal replica count
updated_atstringISO 8601 timestamp

List Workload Events

GET /tha/v3/orgs/{org_slug}/workloads/{workload_uid}/events

Query: limit, cursor.

Each event: workload_uid, workload_type, resource_name, event_type, pod_name, container_name, container_image, new_status, replica_count, old_replica_count, reason, message, display_message, exit_code, created_at.


Get Workload Logs

GET /tha/v3/orgs/{org_slug}/workloads/{workload_uid}/logs

QueryTypeDescription
sincestringRFC 3339 timestamp
tailintegerNumber of recent lines
followbooleanStream logs (text/plain)
previousbooleanLogs from previous container instance
typestringVM only: serial or qemu

Exec Workload

POST /tha/v3/orgs/{org_slug}/workloads/{workload_uid}/exec

RENTAL only. Streams command output as text/plain.

Query: command (repeatable) — e.g. ?command=ls&command=-la.


List VM Images

GET /tha/v3/orgs/{org_slug}/workloads/vm-images

Returns available VM images: { "name", "display_name", "description" }.


List BM Images

GET /tha/v3/orgs/{org_slug}/workloads/bm-images

Returns managed OS images for BM workloads: { "name", "display_name", "os_family" }. Pass name as image when creating a BM workload.


Verify Workload Digest

POST /tha/v3/orgs/{org_slug}/workloads/verify

Body: { "uid": string, "digest": string } (SHA256).

Response: { "verified": boolean }.


Attach / Detach Volume

PUT /tha/v3/orgs/{org_slug}/workloads/{workload_uid}/volumes/{volume_uid}

Body: { "mount_path": string, "read_only": boolean }. RENTAL only.

DELETE /tha/v3/orgs/{org_slug}/workloads/{workload_uid}/volumes/{volume_uid} — returns 204.


Attach / Detach SSH Key

PUT /tha/v3/orgs/{org_slug}/workloads/{workload_uid}/ssh-keys/{ssh_key_uid} — empty body.

Response: { "workload_uid", "ssh_key_uid" }.

DELETE /tha/v3/orgs/{org_slug}/workloads/{workload_uid}/ssh-keys/{ssh_key_uid} — returns 204.


Errors

Errors return JSON: { "error": "message", "reason": "REASON_CODE" }.

Common status codes: 400 (validation), 401 (auth), 403 (forbidden), 404 (not found), 409 (conflict), 500 (server error).

BM-specific reason codes:

ReasonStatusDescription
WORKLOAD_BM_REGION_REQUIRED400region missing
WORKLOAD_BM_REGION_INVALID400region is not a lowercase slug ≤ 32 characters
WORKLOAD_BM_SSH_KEYS_REQUIRED400No ssh_keys supplied
WORKLOAD_BM_HOSTNAME_INVALID400bm_config.hostname is not a valid RFC 1123 hostname
WORKLOAD_BM_REGION_NOT_FOUND409region is not an active region
WORKLOAD_BM_RESERVATION_REGION_MISMATCH409Reservation is in a different region
WORKLOAD_BM_CLAIM_CONFLICT409No bare-metal capacity available for the request
WORKLOAD_BM_TARGET_NOT_FOUND404Image, reservation, or matching server not found
WORKLOAD_BM_SERVICE_UNAVAILABLE503Bare-metal control plane unavailable