← 成果物一覧に戻る

API仕様書

Version 1.0.0  |  プロジェクト: PropCloud - 賃貸管理クラウド

PropCloud API 仕様書

PropCloud の REST API 仕様を定義します。全エンドポイントは `/api` プレフィックスを持ち、JSON 形式でリクエスト・レスポンスを処理します。

共通仕様

認証

すべてのエンドポイント(`/api/auth/login` を除く)は、`Authorization` ヘッダーに Bearer トークンを必要とします。

Authorization: Bearer <JWT_TOKEN>

マルチテナント

リクエストは JWT トークンまたはミドルウェアにより組織(テナント)が自動的に解決されます。全データアクセスは組織スコープに限定されます。

エラーレスポンス

{
  "error": {
    "code": "NOT_FOUND",
    "message": "指定されたリソースが見つかりません"
  }
}
ステータスコード説明
400リクエストパラメータ不正
401認証エラー
403権限不足
404リソースが見つからない
409競合(重複データ等)
422バリデーションエラー
500サーバー内部エラー

ページネーション

一覧取得系エンドポイントは以下のクエリパラメータをサポートします。

パラメータデフォルト説明
`page`number1ページ番号
`limit`number201ページあたりの件数(最大100)
`sort`string`createdAt`ソートフィールド
`order`string`desc`ソート順(asc/desc)

レスポンス形式:

{
  "data": [...],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 150,
    "totalPages": 8
  }
}

エンドポイント一覧

認証 API

メソッドパス説明
POST`/api/auth/login`ログイン
POST`/api/auth/logout`ログアウト

物件 API

メソッドパス説明
GET`/api/buildings`建物一覧の取得
POST`/api/buildings`建物の登録
GET`/api/buildings/:id`建物詳細の取得
PATCH`/api/buildings/:id`建物情報の更新
DELETE`/api/buildings/:id`建物の削除
GET`/api/units`部屋一覧の取得
POST`/api/units`部屋の登録
GET`/api/units/:id`部屋詳細の取得
PATCH`/api/units/:id`部屋情報の更新
DELETE`/api/units/:id`部屋の削除

契約 API

メソッドパス説明
GET`/api/contracts`契約一覧の取得
POST`/api/contracts`契約の作成
GET`/api/contracts/:id`契約詳細の取得
PATCH`/api/contracts/:id`契約情報の更新
DELETE`/api/contracts/:id`契約の削除
POST`/api/contracts/:id/renew`契約の更新(更新手続き)
POST`/api/contracts/:id/cancel`契約の解約

入出金 API

メソッドパス説明
GET`/api/invoices`請求書一覧の取得
POST`/api/invoices`請求書の作成
POST`/api/invoices/generate`請求書の一括自動生成
GET`/api/payments`入金一覧の取得
POST`/api/payments`入金の登録
POST`/api/payments/reconcile`入金の消込処理

送金 API

メソッドパス説明
GET`/api/remittances`オーナー送金一覧の取得
POST`/api/remittances/generate`送金明細の一括生成

帳票 API

メソッドパス説明
GET`/api/documents`帳票一覧の取得
POST`/api/documents`帳票のアップロード
POST`/api/documents/generate`帳票の自動生成
GET`/api/documents/:id/preview`帳票のプレビュー

テナント(組織)API

メソッドパス説明
GET`/api/organizations/current`現在の組織情報の取得
PATCH`/api/organizations/current`組織情報の更新
PATCH`/api/organizations/current/branding`ブランディング設定の更新
PATCH`/api/organizations/current/settings`組織設定の更新

エンドポイント詳細

認証 API

POST /api/auth/login

ログイン認証を行い、JWT トークンを発行します。

**リクエスト:**

{
  "email": "admin@example.com",
  "password": "your-password",
  "organizationSlug": "acme-fudosan"
}

**レスポンス(200):**

{
  "token": "eyJhbGciOiJIUzI1NiIs...",
  "user": {
    "id": "clx1234567890",
    "email": "admin@example.com",
    "name": "田中 太郎",
    "role": "TENANT_ADMIN",
    "organizationId": "clxorg1234567"
  }
}

**エラー(401):**

{
  "error": {
    "code": "INVALID_CREDENTIALS",
    "message": "メールアドレスまたはパスワードが正しくありません"
  }
}

POST /api/auth/logout

現在のセッションをログアウトします。

**レスポンス(200):**

{
  "message": "ログアウトしました"
}

物件 API

GET /api/buildings

建物の一覧を取得します。

**クエリパラメータ:**

パラメータ説明
`search`string建物名・住所で検索
`managementType`string管理形態でフィルタ(SELF, COLLECTION, SUBLEASE, EXCLUSIVE)
`ownerId`stringオーナーIDでフィルタ

**レスポンス(200):**

{
  "data": [
    {
      "id": "clxbld1234567",
      "name": "メゾン青山",
      "address": "東京都港区青山1-2-3",
      "structure": "RC",
      "builtDate": "2010-03-15T00:00:00.000Z",
      "totalUnits": 20,
      "floors": 5,
      "nearestStation": "青山一丁目駅 徒歩5分",
      "managementType": "COLLECTION",
      "ownerId": "clxown1234567",
      "createdAt": "2025-01-10T09:00:00.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 45,
    "totalPages": 3
  }
}

POST /api/buildings

新しい建物を登録します。

**リクエスト:**

{
  "name": "メゾン青山",
  "address": "東京都港区青山1-2-3",
  "structure": "RC",
  "builtDate": "2010-03-15",
  "totalUnits": 20,
  "floors": 5,
  "nearestStation": "青山一丁目駅 徒歩5分",
  "managementType": "COLLECTION",
  "ownerId": "clxown1234567"
}

**レスポンス(201):**

{
  "data": {
    "id": "clxbld1234567",
    "name": "メゾン青山",
    "address": "東京都港区青山1-2-3",
    "structure": "RC",
    "builtDate": "2010-03-15T00:00:00.000Z",
    "totalUnits": 20,
    "floors": 5,
    "nearestStation": "青山一丁目駅 徒歩5分",
    "managementType": "COLLECTION",
    "ownerId": "clxown1234567",
    "createdAt": "2025-01-10T09:00:00.000Z",
    "updatedAt": "2025-01-10T09:00:00.000Z"
  }
}

GET /api/buildings/:id

指定IDの建物詳細を取得します。部屋一覧を含みます。

**レスポンス(200):**

{
  "data": {
    "id": "clxbld1234567",
    "name": "メゾン青山",
    "address": "東京都港区青山1-2-3",
    "structure": "RC",
    "builtDate": "2010-03-15T00:00:00.000Z",
    "totalUnits": 20,
    "floors": 5,
    "nearestStation": "青山一丁目駅 徒歩5分",
    "managementType": "COLLECTION",
    "owner": {
      "id": "clxown1234567",
      "name": "山田 花子"
    },
    "units": [
      {
        "id": "clxunit123456",
        "unitNumber": "101",
        "floor": 1,
        "layout": "1K",
        "area": 25.5,
        "rent": 85000,
        "status": "OCCUPIED"
      }
    ],
    "createdAt": "2025-01-10T09:00:00.000Z",
    "updatedAt": "2025-01-10T09:00:00.000Z"
  }
}

PATCH /api/buildings/:id

建物情報を部分更新します。

**リクエスト:**

{
  "name": "メゾン青山 改修済",
  "notes": "2025年大規模修繕完了"
}

**レスポンス(200):**

{
  "data": {
    "id": "clxbld1234567",
    "name": "メゾン青山 改修済",
    "notes": "2025年大規模修繕完了",
    "updatedAt": "2025-06-15T10:30:00.000Z"
  }
}

DELETE /api/buildings/:id

建物を削除します。紐づく部屋も同時に削除されます。

**レスポンス(200):**

{
  "message": "建物を削除しました"
}

GET /api/units

部屋の一覧を取得します。

**クエリパラメータ:**

パラメータ説明
`buildingId`string建物IDでフィルタ
`status`string空室状況でフィルタ(VACANT, OCCUPIED, MOVE_OUT_SOON 等)
`layoutType`string間取りでフィルタ(1K, 2LDK 等)
`rentMin`number最低賃料
`rentMax`number最高賃料

**レスポンス(200):**

{
  "data": [
    {
      "id": "clxunit123456",
      "unitNumber": "101",
      "floor": 1,
      "layout": "1K",
      "area": 25.5,
      "direction": "南",
      "rent": 85000,
      "managementFee": 5000,
      "commonFee": 3000,
      "deposit": 85000,
      "keyMoney": 85000,
      "status": "OCCUPIED",
      "buildingId": "clxbld1234567",
      "building": {
        "name": "メゾン青山"
      }
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 120,
    "totalPages": 6
  }
}

POST /api/units

新しい部屋を登録します。

**リクエスト:**

{
  "buildingId": "clxbld1234567",
  "unitNumber": "201",
  "floor": 2,
  "layout": "2LDK",
  "area": 55.0,
  "direction": "南東",
  "rent": 150000,
  "managementFee": 8000,
  "commonFee": 5000,
  "deposit": 150000,
  "keyMoney": 150000,
  "status": "VACANT",
  "equipment": ["エアコン", "浴室乾燥機", "オートロック", "宅配ボックス"]
}

**レスポンス(201):**

{
  "data": {
    "id": "clxunit789012",
    "unitNumber": "201",
    "floor": 2,
    "layout": "2LDK",
    "area": 55.0,
    "direction": "南東",
    "rent": 150000,
    "managementFee": 8000,
    "commonFee": 5000,
    "deposit": 150000,
    "keyMoney": 150000,
    "status": "VACANT",
    "equipment": ["エアコン", "浴室乾燥機", "オートロック", "宅配ボックス"],
    "buildingId": "clxbld1234567",
    "createdAt": "2025-01-10T09:00:00.000Z",
    "updatedAt": "2025-01-10T09:00:00.000Z"
  }
}

GET /api/units/:id

指定IDの部屋詳細を取得します。

**レスポンス(200):**

{
  "data": {
    "id": "clxunit123456",
    "unitNumber": "101",
    "floor": 1,
    "layout": "1K",
    "area": 25.5,
    "direction": "南",
    "rent": 85000,
    "managementFee": 5000,
    "commonFee": 3000,
    "deposit": 85000,
    "keyMoney": 85000,
    "status": "OCCUPIED",
    "equipment": ["エアコン", "浴室乾燥機"],
    "availableDate": null,
    "building": {
      "id": "clxbld1234567",
      "name": "メゾン青山",
      "address": "東京都港区青山1-2-3"
    },
    "contracts": [
      {
        "id": "clxctr1234567",
        "status": "ACTIVE",
        "startDate": "2024-04-01T00:00:00.000Z",
        "endDate": "2026-03-31T00:00:00.000Z",
        "tenant": {
          "id": "clxtnt1234567",
          "name": "鈴木 一郎"
        }
      }
    ]
  }
}

PATCH /api/units/:id

部屋情報を部分更新します。

**リクエスト:**

{
  "rent": 90000,
  "status": "RECRUITING"
}

**レスポンス(200):**

{
  "data": {
    "id": "clxunit123456",
    "rent": 90000,
    "status": "RECRUITING",
    "updatedAt": "2025-06-15T10:30:00.000Z"
  }
}

DELETE /api/units/:id

部屋を削除します。

**レスポンス(200):**

{
  "message": "部屋を削除しました"
}

契約 API

GET /api/contracts

契約の一覧を取得します。

**クエリパラメータ:**

パラメータ説明
`status`string契約状態でフィルタ(ACTIVE, EXPIRED, CANCELLED, PENDING_RENEWAL)
`unitId`string部屋IDでフィルタ
`tenantId`string入居者IDでフィルタ
`expiringBefore`string指定日以前に満了する契約をフィルタ(ISO 8601)

**レスポンス(200):**

{
  "data": [
    {
      "id": "clxctr1234567",
      "contractType": "NEW",
      "status": "ACTIVE",
      "startDate": "2024-04-01T00:00:00.000Z",
      "endDate": "2026-03-31T00:00:00.000Z",
      "rent": 85000,
      "managementFee": 5000,
      "commonFee": 3000,
      "deposit": 85000,
      "keyMoney": 85000,
      "unit": {
        "id": "clxunit123456",
        "unitNumber": "101",
        "building": {
          "name": "メゾン青山"
        }
      },
      "tenant": {
        "id": "clxtnt1234567",
        "name": "鈴木 一郎"
      }
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 85,
    "totalPages": 5
  }
}

POST /api/contracts

新しい賃貸借契約を作成します。

**リクエスト:**

{
  "unitId": "clxunit123456",
  "tenantId": "clxtnt1234567",
  "contractType": "NEW",
  "startDate": "2025-04-01",
  "endDate": "2027-03-31",
  "rent": 85000,
  "managementFee": 5000,
  "commonFee": 3000,
  "deposit": 85000,
  "keyMoney": 85000,
  "guarantorName": "鈴木 太郎",
  "guarantorPhone": "090-1234-5678",
  "guarantorAddress": "東京都渋谷区神宮前1-1-1",
  "guaranteeCompany": "日本保証株式会社",
  "specialTerms": "ペット不可。楽器演奏は21時まで。"
}

**レスポンス(201):**

{
  "data": {
    "id": "clxctr7890123",
    "contractType": "NEW",
    "status": "ACTIVE",
    "startDate": "2025-04-01T00:00:00.000Z",
    "endDate": "2027-03-31T00:00:00.000Z",
    "rent": 85000,
    "managementFee": 5000,
    "commonFee": 3000,
    "deposit": 85000,
    "keyMoney": 85000,
    "guarantorName": "鈴木 太郎",
    "guaranteeCompany": "日本保証株式会社",
    "specialTerms": "ペット不可。楽器演奏は21時まで。",
    "createdAt": "2025-03-15T09:00:00.000Z"
  }
}

GET /api/contracts/:id

指定IDの契約詳細を取得します。

**レスポンス(200):**

{
  "data": {
    "id": "clxctr1234567",
    "contractType": "NEW",
    "status": "ACTIVE",
    "startDate": "2024-04-01T00:00:00.000Z",
    "endDate": "2026-03-31T00:00:00.000Z",
    "rent": 85000,
    "managementFee": 5000,
    "commonFee": 3000,
    "deposit": 85000,
    "keyMoney": 85000,
    "renewalFee": null,
    "guarantorName": "鈴木 太郎",
    "guarantorPhone": "090-1234-5678",
    "guarantorAddress": "東京都渋谷区神宮前1-1-1",
    "guaranteeCompany": "日本保証株式会社",
    "specialTerms": "ペット不可。楽器演奏は21時まで。",
    "unit": {
      "id": "clxunit123456",
      "unitNumber": "101",
      "building": {
        "id": "clxbld1234567",
        "name": "メゾン青山",
        "address": "東京都港区青山1-2-3"
      }
    },
    "tenant": {
      "id": "clxtnt1234567",
      "name": "鈴木 一郎",
      "email": "suzuki@example.com",
      "phone": "090-9876-5432"
    },
    "invoices": [
      {
        "id": "clxinv1234567",
        "year": 2025,
        "month": 3,
        "totalAmount": 93000,
        "status": "PAID"
      }
    ]
  }
}

PATCH /api/contracts/:id

契約情報を部分更新します。

**リクエスト:**

{
  "rent": 90000,
  "specialTerms": "ペット不可。楽器演奏は21時まで。駐輪場1台付き。"
}

**レスポンス(200):**

{
  "data": {
    "id": "clxctr1234567",
    "rent": 90000,
    "specialTerms": "ペット不可。楽器演奏は21時まで。駐輪場1台付き。",
    "updatedAt": "2025-06-15T10:30:00.000Z"
  }
}

DELETE /api/contracts/:id

契約を削除します。

**レスポンス(200):**

{
  "message": "契約を削除しました"
}

POST /api/contracts/:id/renew

契約の更新手続きを行います。新しい更新契約が作成されます。

**リクエスト:**

{
  "newEndDate": "2028-03-31",
  "newRent": 87000,
  "renewalFee": 85000
}

**レスポンス(201):**

{
  "data": {
    "id": "clxctr_renewed",
    "contractType": "RENEWAL",
    "status": "ACTIVE",
    "startDate": "2026-04-01T00:00:00.000Z",
    "endDate": "2028-03-31T00:00:00.000Z",
    "rent": 87000,
    "renewalFee": 85000,
    "previousContractId": "clxctr1234567"
  }
}

POST /api/contracts/:id/cancel

契約を解約します。

**リクエスト:**

{
  "cancelDate": "2025-09-30",
  "cancelReason": "入居者都合による退去"
}

**レスポンス(200):**

{
  "data": {
    "id": "clxctr1234567",
    "status": "CANCELLED",
    "cancelDate": "2025-09-30T00:00:00.000Z",
    "cancelReason": "入居者都合による退去"
  }
}

入出金 API

GET /api/invoices

請求書の一覧を取得します。

**クエリパラメータ:**

パラメータ説明
`year`number対象年でフィルタ
`month`number対象月でフィルタ
`status`string請求状態でフィルタ(UNPAID, PARTIAL, PAID, OVERDUE)
`contractId`string契約IDでフィルタ

**レスポンス(200):**

{
  "data": [
    {
      "id": "clxinv1234567",
      "year": 2025,
      "month": 3,
      "totalAmount": 93000,
      "dueDate": "2025-03-27T00:00:00.000Z",
      "status": "PAID",
      "items": [
        { "name": "賃料", "amount": 85000, "taxRate": 0 },
        { "name": "管理費", "amount": 5000, "taxRate": 0 },
        { "name": "共益費", "amount": 3000, "taxRate": 0 }
      ],
      "contract": {
        "id": "clxctr1234567",
        "tenant": { "name": "鈴木 一郎" },
        "unit": { "unitNumber": "101" }
      }
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 200,
    "totalPages": 10
  }
}

POST /api/invoices

請求書を個別に作成します。

**リクエスト:**

{
  "contractId": "clxctr1234567",
  "year": 2025,
  "month": 4,
  "dueDate": "2025-04-27",
  "items": [
    { "name": "賃料", "amount": 85000, "taxRate": 0 },
    { "name": "管理費", "amount": 5000, "taxRate": 0 },
    { "name": "共益費", "amount": 3000, "taxRate": 0 }
  ]
}

**レスポンス(201):**

{
  "data": {
    "id": "clxinv7890123",
    "year": 2025,
    "month": 4,
    "totalAmount": 93000,
    "dueDate": "2025-04-27T00:00:00.000Z",
    "status": "UNPAID",
    "items": [
      { "name": "賃料", "amount": 85000, "taxRate": 0 },
      { "name": "管理費", "amount": 5000, "taxRate": 0 },
      { "name": "共益費", "amount": 3000, "taxRate": 0 }
    ]
  }
}

POST /api/invoices/generate

指定月の請求書を全アクティブ契約に対して一括自動生成します。

**リクエスト:**

{
  "year": 2025,
  "month": 4,
  "dueDay": 27
}

**レスポンス(200):**

{
  "data": {
    "generated": 85,
    "skipped": 3,
    "errors": 0,
    "details": {
      "skippedReasons": [
        { "contractId": "clxctr_skip1", "reason": "既に同月の請求書が存在" }
      ]
    }
  }
}

GET /api/payments

入金の一覧を取得します。

**クエリパラメータ:**

パラメータ説明
`invoiceId`string請求書IDでフィルタ
`paymentMethod`string支払方法でフィルタ
`dateFrom`string入金日の開始(ISO 8601)
`dateTo`string入金日の終了(ISO 8601)

**レスポンス(200):**

{
  "data": [
    {
      "id": "clxpay1234567",
      "amount": 93000,
      "paymentDate": "2025-03-25T00:00:00.000Z",
      "paymentMethod": "BANK_TRANSFER",
      "bankName": "三菱UFJ銀行",
      "depositorName": "スズキ イチロウ",
      "invoiceId": "clxinv1234567",
      "invoice": {
        "year": 2025,
        "month": 3,
        "totalAmount": 93000,
        "status": "PAID"
      }
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 180,
    "totalPages": 9
  }
}

POST /api/payments

入金を登録します。

**リクエスト:**

{
  "invoiceId": "clxinv1234567",
  "amount": 93000,
  "paymentDate": "2025-03-25",
  "paymentMethod": "BANK_TRANSFER",
  "bankName": "三菱UFJ銀行",
  "depositorName": "スズキ イチロウ"
}

**レスポンス(201):**

{
  "data": {
    "id": "clxpay7890123",
    "amount": 93000,
    "paymentDate": "2025-03-25T00:00:00.000Z",
    "paymentMethod": "BANK_TRANSFER",
    "bankName": "三菱UFJ銀行",
    "depositorName": "スズキ イチロウ",
    "invoiceId": "clxinv1234567"
  }
}

POST /api/payments/reconcile

銀行振込データと請求書の自動消込処理を行います。

**リクエスト:**

{
  "bankTransfers": [
    {
      "date": "2025-03-25",
      "amount": 93000,
      "depositorName": "スズキ イチロウ",
      "bankName": "三菱UFJ銀行"
    },
    {
      "date": "2025-03-26",
      "amount": 150000,
      "depositorName": "サトウ ハナコ",
      "bankName": "みずほ銀行"
    }
  ]
}

**レスポンス(200):**

{
  "data": {
    "matched": 1,
    "unmatched": 1,
    "results": [
      {
        "depositorName": "スズキ イチロウ",
        "amount": 93000,
        "status": "MATCHED",
        "invoiceId": "clxinv1234567",
        "paymentId": "clxpay_auto01"
      },
      {
        "depositorName": "サトウ ハナコ",
        "amount": 150000,
        "status": "UNMATCHED",
        "candidates": [
          {
            "invoiceId": "clxinv_cand01",
            "totalAmount": 163000,
            "tenantName": "佐藤 花子"
          }
        ]
      }
    ]
  }
}

送金 API

GET /api/remittances

オーナーへの送金明細の一覧を取得します。

**クエリパラメータ:**

パラメータ説明
`year`number対象年でフィルタ
`month`number対象月でフィルタ
`ownerId`stringオーナーIDでフィルタ
`status`stringステータスでフィルタ(PENDING, APPROVED, REMITTED)

**レスポンス(200):**

{
  "data": [
    {
      "id": "clxrem1234567",
      "year": 2025,
      "month": 3,
      "totalRent": 500000,
      "managementFee": 50000,
      "repairCost": 30000,
      "withholdingTax": 20420,
      "netAmount": 399580,
      "status": "APPROVED",
      "owner": {
        "id": "clxown1234567",
        "name": "山田 花子",
        "bankName": "三菱UFJ銀行",
        "accountNumber": "1234567"
      }
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 30,
    "totalPages": 2
  }
}

POST /api/remittances/generate

指定月のオーナー送金明細を一括生成します。入金済み賃料から管理手数料・修繕費・源泉徴収税を差し引いた送金額を計算します。

**リクエスト:**

{
  "year": 2025,
  "month": 3
}

**レスポンス(200):**

{
  "data": {
    "generated": 15,
    "totalNetAmount": 8500000,
    "details": [
      {
        "ownerId": "clxown1234567",
        "ownerName": "山田 花子",
        "netAmount": 399580
      }
    ]
  }
}

帳票 API

GET /api/documents

帳票の一覧を取得します。

**クエリパラメータ:**

パラメータ説明
`type`string帳票種別でフィルタ(CONTRACT, INVOICE, RECEIPT, SETTLEMENT 等)
`entityType`string関連エンティティ種別でフィルタ(contract, building 等)
`entityId`string関連エンティティIDでフィルタ

**レスポンス(200):**

{
  "data": [
    {
      "id": "clxdoc1234567",
      "name": "賃貸借契約書_メゾン青山101_鈴木一郎.pdf",
      "type": "CONTRACT",
      "fileUrl": "/storage/documents/clxdoc1234567.pdf",
      "fileSize": 245000,
      "mimeType": "application/pdf",
      "tags": ["契約書", "2025年度"],
      "entityType": "contract",
      "entityId": "clxctr1234567",
      "createdAt": "2025-03-15T09:00:00.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 50,
    "totalPages": 3
  }
}

POST /api/documents

帳票ファイルをアップロードします。multipart/form-data 形式です。

**リクエスト:**

フィールド必須説明
`file`Fileはいアップロードするファイル
`type`stringはい帳票種別
`entityType`stringいいえ関連エンティティ種別
`entityId`stringいいえ関連エンティティID
`tags`string[]いいえタグ

**レスポンス(201):**

{
  "data": {
    "id": "clxdoc7890123",
    "name": "領収書_2025年3月_鈴木一郎.pdf",
    "type": "RECEIPT",
    "fileUrl": "/storage/documents/clxdoc7890123.pdf",
    "fileSize": 120000,
    "mimeType": "application/pdf",
    "tags": ["領収書", "2025年3月"],
    "entityType": "contract",
    "entityId": "clxctr1234567",
    "createdAt": "2025-03-20T14:00:00.000Z"
  }
}

POST /api/documents/generate

帳票を自動生成します。テンプレートに基づき PDF を生成します。

**リクエスト:**

{
  "type": "INVOICE",
  "entityType": "contract",
  "entityId": "clxctr1234567",
  "parameters": {
    "year": 2025,
    "month": 4
  }
}

**レスポンス(201):**

{
  "data": {
    "id": "clxdoc_gen01",
    "name": "請求書_2025年4月_メゾン青山101_鈴木一郎.pdf",
    "type": "INVOICE",
    "fileUrl": "/storage/documents/clxdoc_gen01.pdf",
    "fileSize": 180000,
    "mimeType": "application/pdf"
  }
}

GET /api/documents/:id/preview

帳票のプレビュー(HTML またはインライン PDF)を返します。

**レスポンス(200):**

Content-Type に応じた帳票データが返されます。

Accept ヘッダーレスポンス
`text/html`HTML プレビュー
`application/pdf`PDF バイナリ

テナント(組織)API

GET /api/organizations/current

現在ログイン中のユーザーが所属する組織情報を取得します。

**レスポンス(200):**

{
  "data": {
    "id": "clxorg1234567",
    "name": "エイシン不動産",
    "slug": "eishin-fudosan",
    "domain": "eishin-fudosan.propcloud.jp",
    "logoUrl": "/storage/logos/eishin.png",
    "faviconUrl": "/storage/favicons/eishin.ico",
    "theme": {
      "primary": "#1B4D3E",
      "primaryLight": "#2D7A64",
      "accent": "#D4A574"
    },
    "settings": {
      "features": {
        "maintenanceTickets": true,
        "ownerPortal": false
      },
      "terminology": {
        "tenant": "入居者",
        "unit": "部屋"
      }
    },
    "plan": "STANDARD",
    "createdAt": "2024-01-01T00:00:00.000Z"
  }
}

PATCH /api/organizations/current

組織の基本情報を更新します。

**リクエスト:**

{
  "name": "エイシン不動産株式会社",
  "domain": "eishin.propcloud.jp"
}

**レスポンス(200):**

{
  "data": {
    "id": "clxorg1234567",
    "name": "エイシン不動産株式会社",
    "domain": "eishin.propcloud.jp",
    "updatedAt": "2025-06-15T10:30:00.000Z"
  }
}

PATCH /api/organizations/current/branding

組織のブランディング設定(ロゴ・カラーテーマ)を更新します。

**リクエスト:**

{
  "logoUrl": "/storage/logos/eishin-new.png",
  "faviconUrl": "/storage/favicons/eishin-new.ico",
  "theme": {
    "primary": "#1B4D3E",
    "primaryLight": "#2D7A64",
    "accent": "#D4A574"
  }
}

**レスポンス(200):**

{
  "data": {
    "id": "clxorg1234567",
    "logoUrl": "/storage/logos/eishin-new.png",
    "faviconUrl": "/storage/favicons/eishin-new.ico",
    "theme": {
      "primary": "#1B4D3E",
      "primaryLight": "#2D7A64",
      "accent": "#D4A574"
    },
    "updatedAt": "2025-06-15T10:30:00.000Z"
  }
}

PATCH /api/organizations/current/settings

組織の機能設定・用語設定を更新します。

**リクエスト:**

{
  "features": {
    "maintenanceTickets": true,
    "ownerPortal": true,
    "documentGeneration": true
  },
  "terminology": {
    "tenant": "入居者",
    "unit": "部屋",
    "building": "物件"
  },
  "emailConfig": {
    "fromName": "エイシン不動産",
    "replyTo": "info@eishin-fudosan.co.jp"
  }
}

**レスポンス(200):**

{
  "data": {
    "id": "clxorg1234567",
    "settings": {
      "features": {
        "maintenanceTickets": true,
        "ownerPortal": true,
        "documentGeneration": true
      },
      "terminology": {
        "tenant": "入居者",
        "unit": "部屋",
        "building": "物件"
      },
      "emailConfig": {
        "fromName": "エイシン不動産",
        "replyTo": "info@eishin-fudosan.co.jp"
      }
    },
    "updatedAt": "2025-06-15T10:30:00.000Z"
  }
}