# Quickstart

Create your first time entry with Keito API v2.

## Prerequisites

- A Keito company.
- A personal access token from **Settings -> API & Developers**.
- The Company ID shown in **Settings -> API & Developers -> Company ID**.
- A project ID and task ID. Use `/api/v2/projects` and `/api/v2/tasks` to discover them.

## Step 1: Export Credentials

```bash
export KEITO_API_KEY="kto_xxxxx"
export KEITO_ACCOUNT_ID="your_company_id"
```

`KEITO_ACCOUNT_ID` is sent as the `Keito-Account-Id` header.

## Step 2: Verify Authentication

```bash
curl "https://app.keito.ai/api/v2/users/me" \
  -H "Authorization: Bearer $KEITO_API_KEY" \
  -H "Keito-Account-Id: $KEITO_ACCOUNT_ID"
```

The response includes your user profile and the resolved company.

## Step 3: Discover Projects and Tasks

```bash
curl "https://app.keito.ai/api/v2/projects?is_active=true&per_page=100" \
  -H "Authorization: Bearer $KEITO_API_KEY" \
  -H "Keito-Account-Id: $KEITO_ACCOUNT_ID"

curl "https://app.keito.ai/api/v2/tasks?is_active=true&per_page=100" \
  -H "Authorization: Bearer $KEITO_API_KEY" \
  -H "Keito-Account-Id: $KEITO_ACCOUNT_ID"
```

Tasks are company-wide in Keito, not project-specific.

## Step 4: Create a Time Entry

```bash
curl -X POST "https://app.keito.ai/api/v2/time_entries" \
  -H "Authorization: Bearer $KEITO_API_KEY" \
  -H "Keito-Account-Id: $KEITO_ACCOUNT_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "project_id": "project_id_here",
    "task_id": "task_id_here",
    "spent_date": "2026-05-05",
    "hours": 1.5,
    "notes": "Implemented OAuth flow",
    "source": "api",
    "metadata": {
      "session_id": "550e8400-e29b-41d4-a716-446655440000"
    }
  }'
```

## CLI Alternative

The Keito CLI handles the API calls for you:

```bash
keito auth login
keito projects list --json
keito projects tasks --json
keito time log --project "Acme Website" --task "Development" \
  --duration 1:30 \
  --date 2026-05-05 \
  --notes "Implemented OAuth flow"
```

For non-interactive environments, set `KEITO_API_KEY` and `KEITO_ACCOUNT_ID` instead of running `keito auth login`.

## Log an LLM Expense

The API supports expense creation through `/api/v2/expenses`. The current CLI tracks time only, so use the API or web app for LLM cost expenses.

```bash
curl -X POST "https://app.keito.ai/api/v2/expenses" \
  -H "Authorization: Bearer $KEITO_API_KEY" \
  -H "Keito-Account-Id: $KEITO_ACCOUNT_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "project_id": "project_id_here",
    "expense_category_id": "llm_usage_category_id",
    "spent_date": "2026-05-05",
    "total_cost": 0.135,
    "notes": "LLM usage for implementation session",
    "source": "agent",
    "metadata": {
      "model": "claude-opus-4-6",
      "input_tokens": 30000,
      "output_tokens": 15000
    }
  }'
```

## What's Next?

- [Authentication](/docs/auth/api-keys) - create API keys and find your Company ID.
- [Time Entries API](/docs/api-reference/time-entries) - create, update, stop, and delete time entries.
- [CLI Guide](/docs/cli/getting-started) - install and configure the CLI.