> ## Documentation Index
> Fetch the complete documentation index at: https://darwin.so/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Software-owned accounts

> Verify a software-controlled account and authenticate with recoverable machine keys.

> [!NOTE]
>
> 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:

```json theme={null}
{
  "name": "Research service",
  "publicKey": {"kty": "OKP", "crv": "Ed25519", "x": "<primary-public-key-base64url>"},
  "recoveryKey": {"kty": "OKP", "crv": "Ed25519", "x": "<recovery-public-key-base64url>"},
  "scopes": ["account:read", "applications:read", "applications:write", "agents:read", "agents:write", "directory:read"]
}
```

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.


## OpenAPI

````yaml openapi-v2.json POST /account/machine-keys
openapi: 3.1.0
info:
  title: Darwin API
  version: 2.0.0
  description: >-
    Search public capabilities and use durable Navigator sessions and agent
    operations. Verify the deployed API and package version before production
    use.
servers:
  - url: https://api.darwin.so/api/v2
security:
  - apiKey: []
  - bearer: []
paths:
  /account/machine-keys:
    post:
      summary: Enroll machine key
      description: >-
        Local preview. Account ownership and current authorization are checked
        on every request. Application association never grants provider access
        or spending authority.
      operationId: enroll_machine_key
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 160
                publicKey:
                  type: object
                  additionalProperties: false
                  properties:
                    kty:
                      const: OKP
                    crv:
                      const: Ed25519
                    x:
                      type: string
                      pattern: ^[A-Za-z0-9_-]{43}$
                  required:
                    - kty
                    - crv
                    - x
                recoveryKey:
                  type: object
                  additionalProperties: false
                  properties:
                    kty:
                      const: OKP
                    crv:
                      const: Ed25519
                    x:
                      type: string
                      pattern: ^[A-Za-z0-9_-]{43}$
                  required:
                    - kty
                    - crv
                    - x
                scopes:
                  type: array
                  items:
                    enum:
                      - 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
                  minItems: 1
                  maxItems: 14
              required:
                - name
                - publicKey
                - recoveryKey
                - scopes
      responses:
        '201':
          description: The request completed.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '400':
          description: Invalid input.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication or proof required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: The account or grant does not authorize this request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Username, replay, or idempotency conflict.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - AccountSession: []
components:
  schemas:
    Error:
      type: object
      additionalProperties: true
      properties:
        error:
          type: string
        message:
          type: string
        fields:
          type: array
          items:
            type: object
            additionalProperties: true
        code:
          type: string
          description: >-
            Machine-readable failure reason when the API returns a structured
            code, including revision conflicts.
        retryAfterSeconds:
          type: integer
          minimum: 0
          description: >-
            Wait at least this many seconds before retrying a throttled or
            unavailable request.
        authenticationRequest:
          type: object
          properties:
            authenticationRequestId:
              type: string
              minLength: 1
              maxLength: 200
              pattern: ^[A-Za-z0-9][A-Za-z0-9_.:-]*$
            actingAiId:
              type: string
              minLength: 1
              maxLength: 200
              pattern: ^[A-Za-z0-9][A-Za-z0-9_.:-]*$
            targetAiId:
              type: string
              minLength: 1
              maxLength: 200
              pattern: ^[A-Za-z0-9][A-Za-z0-9_.:-]*$
            purpose:
              type: string
              const: discovery
            expiresAt:
              type: string
              maxLength: 40
              format: date-time
              pattern: >-
                ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
          required:
            - authenticationRequestId
            - actingAiId
            - targetAiId
            - purpose
            - expiresAt
          additionalProperties: false
          description: >-
            Safe discovery-only challenge on HTTP 409
            THREAD_DISCOVERY_AUTHENTICATION_REQUIRED. No thread or executable
            route is implied. Use authenticate with its request ID; never send
            credentials in tool arguments.
        targetAgent:
          type: string
          minLength: 1
          maxLength: 200
          pattern: ^[A-Za-z0-9][A-Za-z0-9_.:-]*$
          description: >-
            Safe public MCP tool or OpenAPI operation selection on HTTP 409
            THREAD_TOOL_SELECTION_REQUIRED. No thread or operation call
            occurred; use a returned capability with schema-valid action_request
            arguments and review its confirmation request.
        agent:
          type: string
          minLength: 1
          maxLength: 200
          pattern: ^[A-Za-z0-9][A-Za-z0-9_.:-]*$
          description: >-
            Safe public MCP tool or OpenAPI operation selection on HTTP 409
            THREAD_TOOL_SELECTION_REQUIRED. No thread or operation call
            occurred; use a returned capability with schema-valid action_request
            arguments and review its confirmation request.
        expiresAt:
          type: string
          maxLength: 40
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
          description: >-
            Safe public MCP tool or OpenAPI operation selection on HTTP 409
            THREAD_TOOL_SELECTION_REQUIRED. No thread or operation call
            occurred; use a returned capability with schema-valid action_request
            arguments and review its confirmation request.
        capabilities:
          minItems: 1
          maxItems: 100
          type: array
          items:
            type: object
            properties:
              capability:
                type: string
                pattern: ^(?:public-mcp|public-openapi):[a-f0-9]{64}$
              title:
                type: string
                minLength: 1
                maxLength: 500
              inputSchema:
                type: object
                propertyNames:
                  type: string
                additionalProperties: {}
              effect:
                type: string
                const: external_effect
              pricing:
                type: string
                const: unknown
              requiresConfirmation:
                type: boolean
                const: true
            required:
              - capability
              - title
              - inputSchema
              - effect
              - pricing
              - requiresConfirmation
            additionalProperties: false
          description: >-
            Safe public MCP tool or OpenAPI operation selection on HTTP 409
            THREAD_TOOL_SELECTION_REQUIRED. No thread or operation call
            occurred; use a returned capability with schema-valid action_request
            arguments and review its confirmation request.
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      x-fern-header:
        name: apiKey
        env: DARWIN_API_KEY
      description: >-
        Pass your Darwin API key in the x-api-key header. You can also
        authenticate with Authorization: Bearer <apiKey>.
    bearer:
      type: http
      scheme: bearer
      bearerFormat: Darwin API key or OAuth access token
      x-fern-bearer:
        name: token
        env: DARWIN_API_KEY
      description: >-
        Pass a Darwin API key or OAuth access token as Authorization: Bearer
        <token>. You can also pass a Darwin API key in x-api-key.
    AccountSession:
      type: apiKey
      in: cookie
      name: __Secure-better-auth.session_token
      description: >-
        The HTTP-only Darwin account session cookie set after sign-in. Local
        development uses better-auth.session_token without the __Secure- prefix.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.