# Start a CLI sign-in; answers a code to confirm in the browser.

> https://koi.dog/docs/api/cli-sign-in/start-device-login/

`POST /api/v1/auth/device/start` · Key: `none`

## Headers.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | `string` | no | Retry the same request with the same key. [Retry rules](https://koi.dog/docs/api/#retries). |

## Body.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `hostname` | `string` | yes | This machine's name, shown to the person who approves the sign-in as the CLI's own words (not checked). 1 to 64 characters. Matches `^[\x20-\x7e]+$`. |
| `os` | `enum` | yes | This machine's operating system, shown beside the name when the code is approved. One of `macos`, `linux`, `windows`, `other`. |
| `workspaceId` | `string` | no | The workspace to sign in to. Left out, the one the code is approved in; another workspace's id is `404`. At least 5 characters. |

## Response.

201 Created · JSON object

- **422 validation_failed**: Each schema error appears in `details`.

## Request.

```sh
curl -X POST https://api.koi.dog/api/v1/auth/device/start \
    -H "Origin: https://app.koi.dog" \
    -H "Content-Type: application/json" \
    -d '{
      "hostname": "<hostname>",
      "os": "macos"
    }'
```

```js
const res = await fetch("https://api.koi.dog/api/v1/auth/device/start", {
  method: "POST",
  headers: {
    Origin: "https://app.koi.dog",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    hostname: "<hostname>",
    os: "macos",
  }),
});
console.log(await res.json());
```

```python
import requests

r = requests.post(
    "https://api.koi.dog/api/v1/auth/device/start",
    headers={
        "Origin": "https://app.koi.dog",
    },
    json={
        "hostname": "<hostname>",
        "os": "macos",
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "deviceCode": "string",
  "userCode": "string",
  "verificationUri": "string",
  "expiresAt": "string",
  "intervalSeconds": 0
}
```
