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

# API概要

> lim REST APIの認証、エンドポイント、レスポンス形式の概要。

# API概要

lim REST APIは、プログラムから会計操作を実行するためのHTTP APIです。AI Agent、外部システム、カスタムアプリケーションとの連携に使用します。

## ベースURL

```
https://api.uselim.com/v1
```

## 認証

すべてのリクエストにはAPIキーが必要です。`Authorization` ヘッダーにBearerトークンとして設定します:

```bash theme={null}
curl -H "Authorization: Bearer lim_sk_..." \
  https://api.uselim.com/v1/journals
```

### APIキーの取得

```bash theme={null}
lim auth create-api-key --name "my-integration"
```

<Warning>
  APIキーは会社単位で発行されます。キーを安全に管理し、公開リポジトリにコミットしないでください。
</Warning>

## 主要エンドポイント

### 仕訳

| メソッド    | パス                         | 説明    |
| ------- | -------------------------- | ----- |
| `POST`  | `/v1/journals`             | 仕訳の作成 |
| `GET`   | `/v1/journals`             | 仕訳の一覧 |
| `GET`   | `/v1/journals/:id`         | 仕訳の詳細 |
| `PATCH` | `/v1/journals/:id`         | 仕訳の更新 |
| `POST`  | `/v1/journals/:id/reverse` | 仕訳の取消 |

### 自然言語入力

| メソッド   | パス        | 説明         |
| ------ | --------- | ---------- |
| `POST` | `/v1/add` | 自然言語で仕訳を追加 |

### レポート

| メソッド  | パス                          | 説明          |
| ----- | --------------------------- | ----------- |
| `GET` | `/v1/reports/trial-balance` | 試算表         |
| `GET` | `/v1/reports/profit-loss`   | 損益計算書       |
| `GET` | `/v1/reports/balance-sheet` | 貸借対照表       |
| `GET` | `/v1/reports/cash-flow`     | キャッシュフロー計算書 |
| `GET` | `/v1/reports/runway`        | 資金繰り予測      |

### 勘定科目

| メソッド    | パス                   | 説明      |
| ------- | -------------------- | ------- |
| `GET`   | `/v1/accounts`       | 勘定科目の一覧 |
| `POST`  | `/v1/accounts`       | 勘定科目の作成 |
| `PATCH` | `/v1/accounts/:code` | 勘定科目の更新 |

## リクエスト例

### 自然言語で仕訳を追加

```bash theme={null}
curl -X POST https://api.uselim.com/v1/add \
  -H "Authorization: Bearer lim_sk_..." \
  -H "Content-Type: application/json" \
  -d '{"text": "AWS 11000円 クレジットカード"}'
```

### レスポンス

```json theme={null}
{
  "id": "je_01J7...",
  "date": "2026-03-15",
  "status": "posted",
  "lines": [
    {
      "account_code": "7100",
      "account_name": "通信費",
      "debit": 10000,
      "credit": 0
    },
    {
      "account_code": "1540",
      "account_name": "仮払消費税",
      "debit": 1000,
      "credit": 0
    },
    {
      "account_code": "2100",
      "account_name": "未払金",
      "debit": 0,
      "credit": 11000
    }
  ],
  "engine": {
    "method": "rule_match",
    "confidence": 99,
    "rule_id": "rule_aws_monthly"
  }
}
```

## レスポンス形式

すべてのレスポンスはJSONで返されます。ページネーション対応のリストAPIでは以下の形式です:

```json theme={null}
{
  "data": [...],
  "pagination": {
    "total": 142,
    "page": 1,
    "per_page": 50,
    "has_more": true
  }
}
```

## エラーハンドリング

```json theme={null}
{
  "error": {
    "code": "validation_error",
    "message": "Amount must be a positive integer",
    "field": "amount"
  }
}
```

| ステータスコード | 説明          |
| -------- | ----------- |
| `200`    | 成功          |
| `201`    | 作成成功        |
| `400`    | リクエストエラー    |
| `401`    | 認証エラー       |
| `403`    | 権限エラー       |
| `404`    | リソースが見つからない |
| `429`    | レート制限       |

## レート制限

| プラン        | リクエスト/分 |
| ---------- | ------- |
| Free       | 60      |
| Pro        | 600     |
| Enterprise | カスタム    |

## 次のステップ

<CardGroup cols={2}>
  <Card title="MCPサーバー" icon="plug" href="/ja/agents/mcp-server">
    AI AgentからAPIを利用する方法。
  </Card>

  <Card title="CLIリファレンス" icon="terminal" href="/ja/cli/overview">
    CLIからの操作方法。
  </Card>
</CardGroup>
