• Projects
  • Service
  • About
  • branding.bz
  • Podcast
  • Tips
  • FAQ
  • Recruit
  • Download
  • Contact
  • branding.bz(ブランド構築SaaS)
  • DESIGN NOW(デザインメディア)
  • X
  • LinkedIn
  • Spotify
  • Facebook

213-0011 神奈川県川崎市高津区久本3-6-7-303

© 2026 ID INC. All rights reserved

claude-skills/スキル
SKILLOfficialproductivity

batch-shipping

プラグイン
shippo
ソース
GitHub で見る ↗
説明

Shippo APIを使用して、CSVファイルからまとめた配送データを処理し、複数の配送ラベルを一括作成・購入したり、1日分の配送実績報告書(マニフェスト)を生成したりできます。

原文を表示

Process bulk shipments from CSV files, create and purchase batch labels, and generate end-of-day manifests via the Shippo API

ユースケース
  • CSVファイルから配送データをまとめたい
  • 複数の配送ラベルを一括作成・購入したい
  • 1日分の配送実績報告書を生成したい
本文(日本語訳)

一括配送

購入は実際に処理されます

一括購入により、認可されたShippoアカウント(配送管理サービス)から実際に料金が引き落とされます。PurchaseBatchを実行する前に、配送件数、配送業者・サービス、見積もり総額を表示し、ユーザーの明示的な確認を得てください。


購入確認ゲート

PurchaseBatchを呼び出す前に、以下の内容をまとめて表示し、ユーザーの明示的な確認を得てください:

  • 購入予定の配送件数(総数)
  • 配送業者とサービスレベル(または複数の選択ルール)
  • 見積もり総額
  • 国内配送と国際配送の件数

ユーザーの明示的な確認なしに進めないでください。


CSVファイルの一括処理

列の仕様についてはshippo/references/csv-format.mdを参照してください。

  1. CSVを読み込んで解析します。必須列が存在することを確認し、行数を報告します。

  2. 各行の必須フィールドが空でないことを確認します。無効な行と理由を報告します。

  3. 国際配送の行を検出します(送信国≠受信国)。これらの行に対して税関申告書(通関手続きの書類)を作成します。shippo/references/customs-guide.mdを参照してください。正しい税関申告のコード値を使用してください:返品商品にはRETURN_MERCHANDISE(RETURNではなく)、慈善寄付にはHUMANITARIAN_DONATION(HUMANITARIANではなく)。

  4. 各行ごとに住所と荷物情報をまとめたbatch_shipments配列を構築します。

  5. CreateBatchをこの配列で呼び出します。

  6. GetBatchをポーリング(定期的に確認)して、ステータスがVALIDまたはINVALIDになるまで待ちます。以下の「ポーリング間隔」を参照してください。

  7. ステータスがINVALIDの場合、バッチ内の一部の配送情報が検証に失敗しています。以下の「無効なバッチの修正」を参照し、修正してからVALIDになるまで再度ポーリングします。いずれにせよ、各配送の失敗内容を報告してから進みます。

  8. 購入を確認します(上記の「購入確認ゲート」を参照)。

  9. PurchaseBatchを呼び出して、有効なすべての配送の配送ラベルを購入します。

  10. GetBatchをポーリングして、ステータスがPURCHASINGからPURCHASEDに変わるまで待ちます。以下の「ポーリング間隔」を参照してください。

  11. 報告します:試行数、成功数、失敗数。成功時には:追跡番号とラベルURL(完全なURL)。失敗時には:エラーメッセージ。

バッチラベルの取得

購入済みバッチでは、各ラベルのURLがバッチオブジェクトに直接含まれません。batch_shipments[]の各エントリにはtransactionフィールド(トランザクションオブジェクトID)があります。これに対してGetTransactionを呼び出すと、その配送のlabel_urlとtracking_numberが得られます。バッチレベルのlabel_urlは複数ラベルの統合PDF(最大100ページ)であり、1件ごとに分割することはできません。

バッチサイズの目安

500件以上の配送の場合は、複数のバッチに分割することを検討してください。大規模なバッチは検証と購入に時間がかかり、単一の失敗の原因特定が難しくなります。


ポーリング間隔

  • 100件未満の配送:3~5秒ごとにポーリングします。
  • 100件以上の配送:5~10秒ごとにポーリングします。
  • 30秒ごとに進捗をユーザーに報告します。
  • 60回の試行後は停止し、ユーザーに対してバッチオブジェクトIDを使用してGetBatchで後で確認するよう提案してください。

料金比較を含むバッチ

  1. 各配送ごとにCreateShipmentを呼び出して、料金見積もりを取得します(「料金比較」を参照)。

  2. 料金を提示します。ユーザーがサービスレベルのルール(例:「各配送で最安」または特定の配送業者・サービス)を選択します。

  3. 各アイテムにservicelevel_tokenを付けてbatch_shipmentsを構築します。

  4. 上記と同じように、作成、検証、購入を確認し、購入して報告します。


既存バッチの管理

  • 配送を追加:AddShipmentsToBatch(購入前のみ)。注意:無効な配送を追加すると、バッチ全体のステータスがINVALIDに変わります。追加後は各配送のステータスを確認してください。

  • 配送を削除:RemoveShipmentsFromBatch(購入前のみ)。


無効なバッチの修正

GetBatchがステータスINVALIDを返した場合、1件以上のバッチ配送が検証に失敗しており、修正するまでバッチは購入できません。

  1. 失敗を特定します。 GetBatchをobject_results=creation_failedで呼び出して失敗した配送のみを取得します(多数ある場合は?page=でページネーション)。または、各batch_shipments[].status(VALID / INVALID / INCOMPLETE / TRANSACTION_FAILED)と理由を示すmessagesを読みます。バッチレベルのerrors配列に、同じ失敗内容がまとめられています。

  2. 修正します。以下のいずれか:

    • 削除:失敗したバッチ配送のobject_id(batch_shipments[]から取得、配送オブジェクトIDではなく)を指定してRemoveShipmentsFromBatchを呼び出して削除するか、
    • 修正して再追加:修正した配送オブジェクト(住所、荷物、またはサービスレベルを修正)を指定してAddShipmentsToBatchを呼び出します。
  3. GetBatchを再度ポーリングしてステータスがVALIDになるまで待ちます。

  4. その後、購入を確認し(「購入確認ゲート」を参照)、PurchaseBatchを実行します。


営業終了時の配送リスト

  1. 以下を収集します:carrier_account(オブジェクトID)、shipment_date(YYYY-MM-DD形式、デフォルトは本日)、address_from(受け取り拠点の住所)。

  2. 必要に応じて、特定のトランザクションオブジェクトIDを収集してリストのスコープを絞ります。特定のトランザクションオブジェクトIDを指定する必要があります。日付範囲での自動含有はありません。

  3. CreateManifestを呼び出します。

  4. GetManifestをポーリングして、ステータスがSUCCESSまたはERRORになるまで待ちます。

  5. マニフェスト(配送リスト)のPDF URLと配送件数を返します。


クイックリファレンス

CSVバッチ: CSVを解析 → CreateCustomsDeclaration(国際配送行) → CreateBatch → GetBatchをポーリング → 購入を確認 → PurchaseBatch → GetBatchをポーリング

配送リスト: CreateManifest(トランザクションオブジェクトIDで指定) → GetManifestをポーリング

原文(English)を表示

<!-- ⚠️ DO NOT EDIT. Auto-generated from skills/batch-shipping/SKILL.md by scripts/sync.js Edits here will be overwritten on the next sync. To change this content, edit the canonical source and re-run the sync script. -->

Batch Shipping

Purchases Are Live

Batch purchases charge the authorized Shippo account for real. Before PurchaseBatch, show the shipment count, carrier/service, and estimated total cost, and require explicit user confirmation.


Purchase Confirmation Gate

Before every call to PurchaseBatch, summarize the following and ask the user for explicit confirmation:

  • Total number of shipments to be purchased
  • Carrier and service level (or selection rule if varied)
  • Estimated total cost
  • Number of domestic vs international shipments

Do not proceed without explicit user confirmation.


CSV Batch Processing

See shippo/references/csv-format.md for the column specification.

  1. Read and parse the CSV. Validate required columns are present. Report row count.
  2. Validate each row for non-empty required fields. Report invalid rows with reasons.
  3. Detect international rows (sender_country != recipient_country). Create customs declarations for those rows. See shippo/references/customs-guide.md. Use correct customs enum values: RETURN_MERCHANDISE (not RETURN) for returned goods, HUMANITARIAN_DONATION (not HUMANITARIAN) for charitable donations.
  4. Build the batch_shipments array with inline address and parcel objects per row.
  5. Call CreateBatch with the array.
  6. Poll GetBatch until status is VALID or INVALID. See Polling Intervals below.
  7. If the status is INVALID, some batch shipments failed validation: see "Fixing an INVALID batch" below, fix them, and re-poll until VALID. Report per-shipment failures either way before proceeding.
  8. Confirm purchase (see Purchase Confirmation Gate above).
  9. Call PurchaseBatch to buy labels for all valid shipments.
  10. Poll GetBatch until status changes from PURCHASING to PURCHASED. See Polling Intervals below.
  11. Report: total attempted, succeeded, failed. For successes: tracking_number and label_url (complete URL). For failures: error messages.

Retrieving batch labels

A purchased batch does not put each label URL inline on the batch object. Each entry in batch_shipments[] carries a transaction field, which is a Transaction object_id. Call GetTransaction on it to get that shipment's label_url and tracking_number. The batch-level label_url is a merged multi-label PDF (up to 100 labels per file) and cannot be split per order.

Batch Size Guidance

For batches over 500 shipments, consider splitting into multiple batches. Large batches take longer to validate and purchase, and a single failure can be harder to diagnose.


Polling Intervals

  • For batches under 100 shipments: poll every 3-5 seconds.
  • For batches with 100+ shipments: poll every 5-10 seconds.
  • Report progress to the user every 30 seconds.
  • Stop after 60 retries and suggest the user check back later using GetBatch with the batch object_id.

Batch with Rate Shopping

  1. Call CreateShipment per shipment to get rate quotes (see Rate Shopping).
  2. Present rates. User picks a service level rule (e.g., "cheapest for each" or a specific carrier/service).
  3. Build batch_shipments with servicelevel_token per item.
  4. Create, validate, confirm purchase, purchase, report as above.

Managing an Existing Batch

  • Add shipments: AddShipmentsToBatch (before purchase only). Note: adding an invalid shipment will change the entire batch status to INVALID. Check per-shipment statuses after adding.
  • Remove shipments: RemoveShipmentsFromBatch (before purchase only).

Fixing an INVALID batch

If GetBatch returns status INVALID, one or more batch shipments failed validation and the batch cannot be purchased until they are fixed.

  1. Find the failures. Call GetBatch with object_results=creation_failed to return only the failed shipments (paginate with ?page= if there are many), or read each batch_shipments[].status (VALID / INVALID / INCOMPLETE / TRANSACTION_FAILED) and its messages for the reason. The batch-level errors array collects the same per-shipment failures in one place.
  2. Fix them, either:
    • Remove: RemoveShipmentsFromBatch with the failed batch-shipment object_ids (from batch_shipments[].object_id, not the shipment object_id) to drop them, or
    • Correct and re-add: AddShipmentsToBatch with corrected shipment objects (fixed address, parcel, or servicelevel).
  3. Re-poll GetBatch until status is VALID.
  4. Then confirm purchase (see Purchase Confirmation Gate) and PurchaseBatch.

End-of-Day Manifest

  1. Collect: carrier_account (object_id), shipment_date (YYYY-MM-DD, default today), address_from (pickup address).
  2. Optionally collect specific transaction object_ids to scope the manifest. You must pass specific transaction object_ids -- there is no auto-include for a date range.
  3. Call CreateManifest.
  4. Poll GetManifest until status is SUCCESS or ERROR.
  5. Return the manifest PDF URL(s) and shipment count.

Quick Reference

CSV batch: Parse CSV -> CreateCustomsDeclaration (international rows) -> CreateBatch -> poll GetBatch -> confirm -> PurchaseBatch -> poll GetBatch

Manifest: CreateManifest (with transaction object_ids) -> poll GetManifest

原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。