APIドキュメント

クイックスタート

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

Dashboard →

2. APIを呼び出す

curl -X POST https://invoiceapi.mylastwork.com/api/v1/generate \
  -H "Authorization: Bearer iv_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"seller":{...},"buyer":{...},"issue_date":"2026-03-17","items":[{...}]}'

認証

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

Authorization: Bearer iv_your_api_key
POST /api/v1/generate

JSON → 適格請求書(HTML)を生成。税率別集計・消費税額を自動計算し、Base64エンコードHTMLを返却。

Request Body

{
  "seller": {
    "name": "株式会社サンプル商事",
    "registration_number": "T1234567890123",
    "address": "東京都千代田区丸の内1-1-1",
    "phone": "03-1234-5678"
  },
  "buyer": {
    "name": "株式会社クライアント",
    "address": "大阪府大阪市北区梅田2-2-2"
  },
  "issue_date": "2026-03-17",
  "due_date": "2026-04-30",
  "items": [
    {
      "name": "Webサイト制作",
      "quantity": 1,
      "unit_price": 500000,
      "tax_rate": 10
    },
    {
      "name": "お茶菓子(打合せ用)",
      "quantity": 5,
      "unit_price": 500,
      "tax_rate": 8
    }
  ],
  "payment_method": "銀行振込",
  "bank_info": {
    "bank_name": "みずほ銀行",
    "branch_name": "丸の内支店",
    "account_type": "ordinary",
    "account_number": "1234567",
    "account_holder": "カ)サンプルショウジ"
  }
}

Response

{
  "success": true,
  "data": {
    "invoice_number": "INV-20260317-0042",
    "subtotals": [
      { "rate": 8, "subtotal": 2500, "tax_amount": 200 },
      { "rate": 10, "subtotal": 500000, "tax_amount": 50000 }
    ],
    "total_before_tax": 502500,
    "total_tax": 50200,
    "grand_total": 552700,
    "pdf_base64": "PCFET0NUWVBF...(Base64エンコードHTML)",
    "content_type": "text/html"
  }
}

適格請求書の必須6項目

  1. 適格請求書発行事業者の氏名・名称・登録番号 → seller.name + seller.registration_number
  2. 取引年月日 → issue_date
  3. 取引内容 → items[].name
  4. 税率ごとに区分した対価の額 → 自動計算
  5. 税率ごとの消費税額 → 自動計算(切り捨て)
  6. 書類の交付を受ける事業者の氏名・名称 → buyer.name
POST /api/v1/validate

請求書データのバリデーション。必須項目・登録番号フォーマット・日付・税率を検証。

Request Body

{
  "seller": {
    "name": "",
    "registration_number": "T123"
  },
  "buyer": {},
  "issue_date": "2026-13-45",
  "items": []
}

Response

{
  "success": true,
  "data": {
    "valid": false,
    "errors": [
      { "field": "seller.name", "message": "事業者名は必須です" },
      {
        "field": "seller.registration_number",
        "message": "登録番号はT+13桁の数字の形式で入力してください",
        "value": "T123"
      },
      { "field": "issue_date", "message": "取引年月日はYYYY-MM-DD形式で入力してください" },
      { "field": "items", "message": "明細行は1行以上必要です" },
      { "field": "buyer.name", "message": "宛先事業者名は必須です" }
    ]
  }
}
POST /api/v1/calculate

消費税計算。軽減税率(8%)と標準税率(10%)を自動区分し、切り捨てで消費税額を算出。

Request Body

{
  "items": [
    { "name": "Webサイト制作", "quantity": 1, "unit_price": 500000, "tax_rate": 10 },
    { "name": "お茶菓子", "quantity": 5, "unit_price": 500, "tax_rate": 8 }
  ]
}

Response

{
  "success": true,
  "data": {
    "items": [
      { "name": "Webサイト制作", "quantity": 1, "unit_price": 500000, "tax_rate": 10, "amount": 500000 },
      { "name": "お茶菓子", "quantity": 5, "unit_price": 500, "tax_rate": 8, "amount": 2500 }
    ],
    "subtotals": [
      { "rate": 8, "subtotal": 2500, "tax_amount": 200 },
      { "rate": 10, "subtotal": 500000, "tax_amount": 50000 }
    ],
    "total_before_tax": 502500,
    "total_tax": 50200,
    "grand_total": 552700
  }
}
GET /api/v1/verify-registration

適格請求書発行事業者の登録番号(T+13桁)のフォーマット・チェックデジットを検証。

Query Parameters

number — 登録番号 (例: T1234567890123)

GET /api/v1/verify-registration?number=T1234567890123

{
  "success": true,
  "data": {
    "number": "T1234567890123",
    "format_valid": true,
    "check_digit_valid": true,
    "message": "登録番号のフォーマットは正しいです"
  }
}

税率リファレンス

tax_rate 種別 対象
8 軽減税率 飲食料品(酒類・外食を除く)、定期購読の新聞
10 標準税率 上記以外の全ての課税対象

エラーコード

Status 説明
400リクエストが不正(必須項目不足・フォーマットエラー)
401APIキーが無効・未指定
429月間上限に達した
500サーバーエラー