Bootstrapping an organization
Result: a verified root profile on the operator's machine, three disjoint user tags, a tagged human approver, and a recorded approval-model choice. The organization itself is created in the Turnkey dashboard at https://app.turnkey.com; nothing here creates an agent.
Reference
- authentication: profiles,
login, and the environment bundle. - resources:
user,user tag, andpolicycommand records.
Rules
- The root credential is the operator's. It never becomes an agent's runtime credential and never leaves the operator's machine.
- Tags are disjoint: a user carries at most one of
agent,provisioner,human-approver. - Pick the approval model before any policy is written; the choice decides which policy set the later workflows apply.
- Every
tkcommand takes--message-format json; branch onreasonandstatusas cli-convention.md describes.
Instructions
Inputs from the user: the name of the root profile (admin below) and
which human approves. The organization id comes from step 1.
Open the organization in the dashboard. Operator, at https://app.turnkey.com. Sign in, create an organization if there is none, and copy the Organization ID from the dashboard; it is
ORG_UUIDbelow.Install
<!-- example: bootstrap.install -->tk. Operator, on their machine. The installer fetches the latest release:curl --proto '=https' --tlsv1.2 -LsSf https://raw.githubusercontent.com/tkhq/tk/main/install.sh | sh tk --versionSave the root profile. Operator. Either path leaves a credential file under
~/.config/turnkey/tk/api-keys/, copying an existing file rather than referencing it; the private key is never printed.With an existing root API key file of this shape:
<!-- example: bootstrap.profile-create-existing -->{"public_key":"02…","private_key":"…","curve":"p256"}tk --message-format json --organization-id ORG_UUID profile create --profile-name admin --api-key-file ./root-key.jsonWithout one, let
<!-- example: bootstrap.profile-create-fresh -->tkgenerate the credential, then register it: in the dashboard at https://app.turnkey.com open the root user, add an API key, open the dialog's Advanced settings, and paste the printeddata.publicKey(curve P-256) instead of generating a key in the browser. Continue once the key shows on the user:tk --message-format json --organization-id ORG_UUID profile create --profile-name adminProceed when
commandisprofile.create.data.nextStepnames the registration step for a generated credential andloginfor an existing one.Verify and select the profile.
<!-- example: bootstrap.login -->tk --message-format json login --profile-name admin tk --profile admin --message-format json whoamiProceed when
loginreturnscommand: "auth.login"withdata.identity.organizationIdequal to the organization andwhoamireturns the sameuserId. Savedata.identity.userIdasHUMAN_USER_IDif this root user is the approver.unauthorizedmeans the public key is not on the root user yet; add it in the dashboard and rerunlogin.Create the three tags. Root.
<!-- example: bootstrap.tags -->tk --profile admin --message-format json user tag create --name agent tk --profile admin --message-format json user tag create --name provisioner tk --profile admin --message-format json user tag create --name human-approverEach record is
command: "user.tag.create"; setAGENT_TAG,PROVISIONER_TAG, andHUMAN_APPROVER_TAGto eachdata.activity.result.createUserTagResult.userTagId. Apendingstatus means a policy already gates tag creation; wait on the activity before the next step.Tag the human approver. Root. The approver is a user who will vote with
<!-- example: bootstrap.tag-human -->tk activity approve, the console, or the mobile app.tk --profile admin --message-format json user update --input-json '{"userId":"HUMAN_USER_ID","userTagIds":["HUMAN_APPROVER_TAG"]}'userTagIdsreplaces the user's tag set. Confirm withtk --profile admin --message-format json user get --id HUMAN_USER_ID, whosedata.user.userTagslists the tag id. A root approver also satisfies the root quorum, so consensus behavior is tested later with a non-root approver.Choose the approval model. Read approval-models.md with the user and record the cell: whether exports need a human, and whether minting does. Do not create policies here; the provisioning workflows apply the credential and minting policies, and managing-secrets applies the export policy for the chosen cell.
Hand off. Report the organization id, the profile name, the root user id, the three tag ids, the approver's user id, and the chosen cell. Stop.
Verified by
| Examples | Test |
|---|---|
| bootstrap.profile-create-existing, bootstrap.login, bootstrap.tags, bootstrap.tag-human | identity::bootstrapping_organization_root_tags_and_approval_model |
| bootstrap.profile-create-fresh | identity::profile_create_generates_a_credential_that_logs_in_once_registered |
bootstrap.install is a manual prerequisite; the suite runs the built binary.
Troubleshooting
loginfails withunauthorized(401 or 403): the profile's public key,details.publicKey, is not registered on a user in that organization. Add it to the root user at https://app.turnkey.com, then rerun the samelogin.loginfails withinvalid_inputnamingprofile set: the profile was saved with a different organization or endpoint. Run thetk profile setcommand the message names, thenloginagain.loginfails with any other error: see managing-identities.user tag createfails withapi_errorand a 400: a tag with that name already exists. Read the id fromtk --profile admin --message-format json user tag list.user updatereturnsstatus: "pending": an existing policy gates user updates. Resume withtk activity wait --id ACTIVITY_ID --timeout 60; do not resubmit.- Any command fails with
invalid_inputabout the environment bundle: a partialTURNKEY_*bundle is set in the shell. Unset it or pass--profile admin.
Related Skills
- managing-identities: create the agent and provisioner users this organization is now ready for.
- managing-policies: apply the policy set for the chosen approval cell.
- monitoring-activities: when a step
above returns
pending.