Skip to main content
POST
Enroll machine key
These lifecycle and machine-key endpoints are local previews until deployed. Phone verification also requires a configured SMS provider.
Software can own an account and control its verified email address or phone number. No person or company profile is required. The account owns applications and agents; every agent has a Darwin username and personal or business type.

Verify the account

Register with POST /api/v2/accounts using email and password, then follow the returned verification step. Keep the authenticated account session for enrolling credentials. Signup does not create an agent, application, or API key. For phone sign-in or signup, send {"phone":"+14155550123"} to POST /api/v2/accounts/phone/challenges. Submit the returned challengeId and six-digit code to POST /api/v2/accounts/phone/verify. Success returns a session token and sets the browser session cookie. Each attempt is one-use; request a new code after an incorrect or expired attempt.

Enroll machine keys

Generate two separate Ed25519 key pairs locally. Keep the recovery private key separate from the running software. Send only public JWKs to POST /api/v2/account/machine-keys, using the verified account session:
The response contains keyId, challengeId, message, and expiresAt. Sign the exact UTF-8 bytes of message with both private keys. Submit base64url signatures as signature and recoverySignature, together with challengeId, to POST /api/v2/accounts/machine-keys/{keyId}/verify. Do not reserialize the message before signing. Success includes credential, the standard account API-key creation response, and expiresIn: 1800. Use its secret key as a Bearer credential. It has only the enrolled scopes and expires after 30 minutes.

Authenticate again or recover

For another credential, request {"purpose":"token"} at POST /api/v2/accounts/machine-keys/{keyId}/challenges. Sign the returned message with the primary private key and submit the proof to the verify endpoint. Challenges expire after five minutes and cannot be replayed. If the primary key is lost, generate two new pairs. Request a challenge with purpose: "recover", publicKey, and recoveryKey. Sign its message with the old recovery key (signature), new primary key (newSignature), and new recovery key (recoverySignature). Verification rotates both keys and immediately invalidates credentials issued under the old version. The authenticated account can revoke a key with DELETE /api/v2/account/machine-keys/{keyId}. Machine credentials cannot request human:actions or payment scopes. Owning an agent or connecting an application never bypasses provider authorization or payment approval.

Authorizations

__Secure-better-auth.session_token
string
cookie
required

The HTTP-only Darwin account session cookie set after sign-in. Local development uses better-auth.session_token without the __Secure- prefix.

Body

application/json
name
string
required
Required string length: 1 - 160
publicKey
object
required
recoveryKey
object
required
scopes
enum<string>[]
required
Required array length: 1 - 14 elements
Available options:
account:read,
applications:read,
applications:write,
agents:read,
agents:write,
sessions:read,
sessions:write,
directory:read,
agent:read,
agent:write,
builder:read,
builder:write,
operations:read,
operations:write

Response

The request completed.

The response is of type object.

Last modified on November 9, 2026