# Machines

Machines represent registered agents or servers linked to your account. Use these endpoints to list, inspect, and revoke machines.

## List All Machines

### `GET /api/machine/list`

List all machines linked to the authenticated user's account.

**Authentication:**  
API key, Session cookie, or Machine JWT

**Response:**

```json
{
  "machines": [
    {
      "machineId": "m_8f3a4b2c",
      "machineName": "my-laptop",
      "createdAt": "2026-02-10T08:00:00.000Z",
      "lastRequestAt": "2026-02-17T14:30:00.000Z"
    },
    {
      "machineId": "m_9e5d6c1a",
      "machineName": "ci-runner",
      "createdAt": "2026-02-12T10:00:00.000Z",
      "lastRequestAt": "2026-02-17T12:00:00.000Z"
    }
  ]
}
```

**Examples**

**curl**

```bash
curl https://keychains.dev/api/machine/list \
  -H "Authorization: Bearer kc_your_api_key"
```

**Node.js**

```javascript
const res = await fetch("https://keychains.dev/api/machine/list", {
  headers: { Authorization: "Bearer kc_your_api_key" },
});
const { machines } = await res.json();
```

## Get Machine Details

### `GET /api/machine/:machineId`

Get details of a specific machine by its ID. Only accessible to the machine's owner.

**Authentication:**  
API key, Session cookie, or Machine JWT

**Response:**

```json
{
  "machineId": "m_8f3a4b2c",
  "machineName": "my-laptop",
  "createdAt": "2026-02-10T08:00:00.000Z",
  "lastRequestAt": "2026-02-17T14:30:00.000Z",
  "revokedAt": null
}
```

**Examples**

**curl**

```bash
curl https://keychains.dev/api/machine/m_8f3a4b2c \
  -H "Authorization: Bearer kc_your_api_key"
```

**Node.js**

```javascript
const res = await fetch("https://keychains.dev/api/machine/m_8f3a4b2c", {
  headers: { Authorization: "Bearer kc_your_api_key" },
});
const machine = await res.json();
```

## Revoke Machine

### `DELETE /api/machine/:machineId`

Revoke and remove a machine from your account. This permanently deletes the machine's keys and challenge data. All associated permission requests are also revoked.

**Authentication:**  
API key, Session cookie, or Machine JWT

**Response:**

```json
{
  "success": true
}
```

**Examples**

**curl**

```bash
curl -X DELETE https://keychains.dev/api/machine/m_8f3a4b2c \
  -H "Authorization: Bearer kc_your_api_key"
```

**Node.js**

```javascript
await fetch("https://keychains.dev/api/machine/m_8f3a4b2c", {
  method: "DELETE",
  headers: { Authorization: "Bearer kc_your_api_key" },
});
```
