APIドキュメント

クイックスタート

1. アカウント作成してAPIキーを取得

Dashboard →

2. 書類をアップロード

curl -X POST https://denshiapi.mylastwork.com/api/v1/upload \
  -H "Authorization: Bearer ds_your_api_key" \
  -F "file=@invoice.pdf" \
  -F "transaction_date=2025-03-15" \
  -F "counterparty=株式会社サンプル" \
  -F "amount=550000" \
  -F "document_type=invoice"

認証

全てのAPIリクエストに Authorization ヘッダーが必要です。

Authorization: Bearer ds_your_api_key
POST /api/v1/upload

書類をアップロードして電子保存。SHA-256ハッシュとタイムスタンプを自動付与。

Request (multipart/form-data)

file (required) -- アップロードファイル (PDF/JPEG/PNG/TIFF/WebP/XML/CSV/Excel)

transaction_date -- 取引年月日 (YYYY-MM-DD)

counterparty -- 取引先名称

amount -- 取引金額(整数)

document_type -- invoice/receipt/contract/delivery/quotation/other

description -- 説明

tags -- タグ (JSON配列 or カンマ区切り)

Response

{
  "success": true,
  "data": {
    "id": "abc123...",
    "filename": "invoice.pdf",
    "hash_sha256": "e3b0c44298fc...",
    "timestamp_token": "a1b2c3d4...",
    "timestamped_at": "2025-03-15T10:30:00Z",
    "file_size": 245760,
    "content_type": "application/pdf"
  }
}
GET /api/v1/documents/:id

ドキュメントのメタデータを取得

GET /api/v1/documents/:id/download

ドキュメントファイルをダウンロード

POST /api/v1/verify

ドキュメントの改ざん検証。R2から再ダウンロードしてSHA-256を再計算、保存ハッシュと比較。

Request Body

curl -X POST https://denshiapi.mylastwork.com/api/v1/verify \
  -H "Authorization: Bearer ds_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"document_id": "abc123..."}'

Response

{
  "success": true,
  "data": {
    "is_valid": true,
    "document_id": "abc123...",
    "hash_valid": true,
    "stored_hash": "e3b0c44298fc...",
    "computed_hash": "e3b0c44298fc...",
    "timestamp_valid": true,
    "timestamped_at": "2025-03-15T10:30:00Z"
  }
}
GET /api/v1/audit

監査証跡を取得。全操作(upload/view/search/download/verify)の記録。

Query Parameters

document_id -- 特定ドキュメントのログのみ

from -- 開始日時 (ISO 8601)

to -- 終了日時 (ISO 8601)

action -- アクション種別でフィルタ

limit -- 件数(デフォルト50、最大100)

offset -- オフセット

Response

{
  "success": true,
  "data": {
    "entries": [{
      "id": 1,
      "document_id": "abc123...",
      "action": "upload",
      "details": "filename=invoice.pdf, size=245760",
      "ip_address": "203.0.113.1",
      "created_at": "2025-03-15T10:30:00Z"
    }],
    "total": 1
  }
}
POST /api/v1/validate-compliance

全ドキュメントの電子帳簿保存法準拠状況をチェック。不備のあるドキュメントと具体的な問題点を返却。

Response

{
  "success": true,
  "data": {
    "total_documents": 150,
    "compliant": 142,
    "non_compliant": 8,
    "issues": [{
      "document_id": "def456...",
      "filename": "receipt_old.jpg",
      "issues": [
        "取引先名称が未設定です(検索要件)",
        "取引金額が未設定です(検索要件)"
      ]
    }]
  }
}

エラーコード

Status 説明
400リクエストが不正
401APIキーが無効
404ドキュメントが見つからない
429月間上限に達した
500サーバーエラー