easypost-api
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseEasyPost API Skill
EasyPost API技能
This skill makes Claude productive at building EasyPost integrations. It covers the full shipping workflow: addresses, parcels, rates, labels, customs, tracking, pickups, scan forms, batches, insurance, claims, reports, webhooks, and the carrier-specific peculiarities that cause most real-world bugs.
It is Node.js-first and defaults to the official SDK, but field names and endpoint shapes are the same across languages. When the SDK can't do something, drop to or raw HTTPS against the documented REST endpoint.
@easypost/apiclient.makeApiCall()Source of truth, in this order:
- Content of this skill (battle-tested patterns, carrier gotchas).
- Official docs: https://docs.easypost.com/
- SDK source: https://github.com/easypost/easypost-node
If this skill and the docs disagree about behavior, trust the docs and update the skill afterward.
本技能可帮助Claude高效构建EasyPost集成。它涵盖完整的物流工作流:地址、包裹、费率、标签、报关、追踪、上门取件、扫描单、批量处理、保险、理赔、报告、Webhook,以及导致多数实际场景bug的承运商特有细节。
本技能优先支持Node.js,默认使用官方 SDK,但字段名称和端点结构在所有编程语言中保持一致。当SDK无法实现某些功能时,可使用或直接调用文档中记录的REST端点进行HTTPS请求。
@easypost/apiclient.makeApiCall()信息优先级如下:
- 本技能内容(经过实战检验的模式、承运商注意事项)
- 官方文档:https://docs.easypost.com/
- SDK源码:https://github.com/easypost/easypost-node
若本技能与文档在行为描述上存在冲突,请以文档为准,并后续更新本技能。
How to use this skill
如何使用本技能
This skill is deliberately split into focused reference files. Don't load everything — load only the topics you need for the task at hand. Each file is short enough to digest in a single read and ends with pointers to adjacent topics.
Start by identifying the task, then read the matching file(s). If the task touches multiple areas (e.g., "international shipment with insurance"), read each area's file.
本技能被刻意拆分为多个聚焦主题的参考文件。无需加载全部内容,只需加载当前任务所需的主题文件即可。每个文件篇幅较短,可一次性阅读完毕,并在末尾提供相关主题的跳转指引。
首先确定任务类型,然后阅读对应的文件。若任务涉及多个领域(例如“带保险的国际货运”),则需阅读每个相关领域的文件。
Routing table
路由表
For ecommerce integrations, start with — it walks the cart → checkout → fulfillment → delivery → returns lifecycle and points at the per-concept files.
references/ecommerce-flows.md| If the task is about… | Read |
|---|---|
| End-to-end ecommerce flow (cart, checkout, fulfillment, returns, notifications) | |
| What EasyPost does NOT do (duties, tax, autocomplete, cutoffs, etc.) | |
| Installing the SDK, configuring the client, TypeScript types, test vs. production keys | |
SDK helper methods ( | |
| Finding current service levels, predefined packages, supported options at runtime | |
| Creating a shipment, picking a rate, buying a label, downloading the label | |
| Address validation, international address quirks | |
| Parcel dimensions, weight, predefined packages | |
| Choosing the cheapest/fastest rate, SmartRate, Luma rulesets | |
| International shipping, customs forms, EEI, incoterms, tax IDs | |
| Real-time tracking, tracker statuses, tracking URLs, bulk retrieve | |
| Webhook setup, HMAC verification, event payloads | |
| Return labels, refunding postage | |
| Bulk label purchase (batches) | |
| End-of-day scan forms / manifests | |
| Scheduling carrier pickups | |
| Buying insurance, filing claims | |
| CSV reports (shipment, invoice, cash flow, etc.) | |
| Adding/managing carrier accounts, credentials, metadata | |
| Commercial invoice, QR codes, packing slips | |
| Error classes, retries, idempotency, rate limits | |
| Listing resources, cursor pagination | |
| Test API keys, test tracking codes, sandbox behavior | |
| API keys, users, child accounts, billing | |
| Multi-parcel Orders, EndShippers (resellers/DAP) | |
| USPS specifics (flat rate, HazMat, domestic vs. international) | |
| UPS specifics (weight limits, OAuth, predefined packages) | |
| UPS Digital Access Program (DAP) rules | |
| FedEx specifics (BYOCA, SmartPost, Express One Rate, lithium batteries) | |
| DHL Express (international only) | |
| DHL eCommerce (C2C/B2C only, placeholder rates) | |
| ePost Global (USPS first mile + international) | |
对于电商集成,请从开始——它涵盖了购物车→结账→履约→配送→退货的完整生命周期,并指向对应概念的文件。
references/ecommerce-flows.md| 若任务涉及… | 阅读文件 |
|---|---|
| 端到端电商流程(购物车、结账、履约、退货、通知) | |
| EasyPost不支持的功能(关税、税费、自动补全、截止时间等) | |
| SDK安装、客户端配置、TypeScript类型、测试与生产密钥 | |
SDK辅助方法( | |
| 在运行时查找当前服务级别、预定义包裹、支持的选项 | |
| 创建运单、选择费率、购买标签、下载标签 | |
| 地址验证、国际地址特殊规则 | |
| 包裹尺寸、重量、预定义包裹 | |
| 选择最便宜/最快的费率、SmartRate、Luma规则集 | |
| 国际货运、报关单、EEI、国际贸易术语、税号 | |
| 实时追踪、追踪状态、追踪URL、批量检索 | |
| Webhook设置、HMAC验证、事件负载 | |
| 退货标签、邮资退款 | |
| 批量购买标签(批次处理) | |
| 每日结束扫描单/清单 | |
| 预约承运商上门取件 | |
| 购买保险、提交理赔申请 | |
| CSV报告(运单、发票、现金流等) | |
| 添加/管理承运商账户、凭证、元数据 | |
| 商业发票、二维码、装箱单 | |
| 错误类、重试、幂等性、速率限制 | |
| 资源列表、游标分页 | |
| 测试API密钥、测试追踪码、沙箱行为 | |
| API密钥、用户、子账户、账单 | |
| 多包裹订单、EndShippers(经销商/DAP) | |
| USPS特定规则(平邮、危险品、国内vs国际) | |
| UPS特定规则(重量限制、OAuth、预定义包裹) | |
| UPS数字访问计划(DAP)规则 | |
| FedEx特定规则(BYOCA、SmartPost、Express One Rate、锂电池) | |
| DHL Express(仅国际) | |
| DHL eCommerce(仅C2C/B2C,占位费率) | |
| ePost Global(USPS首程+国际) | |
Runnable examples
可运行示例
scripts/- — address → parcel → shipment → buy lowest rate → save label PDF
scripts/create-shipment.mjs - — address verification with
scripts/verify-address.mjscreateAndVerify - — customs info + items + shipment with tax identifier
scripts/international-shipment.mjs - — create tracker, poll status
scripts/track-shipment.mjs - — Express endpoint using
scripts/webhook-handler.mjsclient.Utils.validateWebhook - — create batch, add shipments, purchase, generate combined label
scripts/batch-buy.mjs - — create pickup, buy cheapest pickup rate
scripts/schedule-pickup.mjs - — pick cheapest rate meeting a delivery deadline
scripts/smartrate-deliver-by.mjs
scripts/- — 地址→包裹→运单→购买最低费率→保存标签PDF
scripts/create-shipment.mjs - — 使用
scripts/verify-address.mjs进行地址验证createAndVerify - — 报关信息+物品+带税号的运单
scripts/international-shipment.mjs - — 创建追踪器、轮询状态
scripts/track-shipment.mjs - — 使用
scripts/webhook-handler.mjs的Express端点client.Utils.validateWebhook - — 创建批次、添加运单、购买、生成合并标签
scripts/batch-buy.mjs - — 创建取件预约、购买最便宜的取件费率
scripts/schedule-pickup.mjs - — 选择满足配送期限的最便宜费率
scripts/smartrate-deliver-by.mjs
Cardinal rules
核心规则
These apply everywhere and save most of the common footguns:
-
Always use a test API key during development. Production keys cost real money on every label purchase. Test keys start with(or
test_), production withEZTK.EZAKhas the full rundown.references/testing.md -
Inspectwhenever
shipment.messagesis shorter than expected. Carriers that failed to rate return a message (carrier name + reason) instead of a rate. Silently missing rates is usually a missing field or wrong credential.rates -
For international shipments, customs info is required, not optional. Buildwith accurate HS tariff numbers, set
CustomsInfo, and setcustoms_certify = true. Seecustoms_signer.references/international.md -
Do not trustblindly for international or time-critical shipments. Use SmartRate or Luma when delivery guarantees matter (
lowestRate()).references/rates-and-smartrate.md -
Verify webhook HMAC signatures with. See
client.Utils.validateWebhook()for the exact pattern.references/webhooks.md -
Rates and services differ between test and production. Negotiated discounts only surface in production. Don't use test-mode rates in your analytics.
-
Phone number and company name reduce address-correction fees on FedEx and UPS. Always pass them when you have them.
-
Label URLs expire.is a signed URL with a TTL. Download the PDF/PNG to your own storage immediately after purchase.
postage_label.label_url -
is required for UPS DAP and some reseller/partner accounts. If you get a rating error mentioning "end shipper," create an
end_shipper_idand pass its ID at purchase.EndShipper -
Carrier-specific fields belong in, not at the top level. E.g.,
options,options.hazmat,options.aes_itn,options.incoterm,options.delivery_confirmation.options.label_format
这些规则适用于所有场景,可避免多数常见陷阱:
-
开发期间务必使用测试API密钥。生产密钥会在每次购买标签时产生真实费用。测试密钥以(或
test_)开头,生产密钥以EZTK开头。详细说明见EZAK。references/testing.md -
当数量少于预期时,务必检查
rates。未能返回费率的承运商会返回一条消息(承运商名称+原因)而非费率。费率缺失通常是因为缺少字段或凭证错误。shipment.messages -
国际货运必须提供报关信息,而非可选。创建时需填写准确的HS关税编号,设置
CustomsInfo,并指定customs_certify = true。详见customs_signer。references/international.md -
对于国际货运或时间敏感的货运,请勿盲目信任。当配送时效有保障要求时,请使用SmartRate或Luma(详见
lowestRate())。references/rates-and-smartrate.md -
使用验证Webhook的HMAC签名。具体实现模式见
client.Utils.validateWebhook()。references/webhooks.md -
测试环境与生产环境的费率和服务不同。协商折扣仅在生产环境中显示。请勿在分析中使用测试模式下的费率。
-
提供电话号码和公司名称可减少FedEx和UPS的地址修正费用。如有相关信息,请务必填写。
-
标签URL会过期。是带有有效期的签名URL。购买后请立即将PDF/PNG下载至您自己的存储系统。
postage_label.label_url -
UPS DAP和部分经销商/合作伙伴账户需要。若收到提及“end shipper”的费率错误,请创建一个
end_shipper_id并在购买时传入其ID。EndShipper -
承运商特定字段需放在中,而非顶层。例如:
options、options.hazmat、options.aes_itn、options.incoterm、options.delivery_confirmation。options.label_format
Skill-wide conventions for generated code
生成代码时的技能通用约定
When you write EasyPost code for the user, follow these conventions unless the user says otherwise:
- Use the SDK () before raw HTTP. Fall back to
@easypost/apionly for endpoints the SDK doesn't cover.client.makeApiCall() - In TypeScript, import entity and parameter types from (
@easypost/api,IShipment, etc.).IShipmentCreateParameters - Never hardcode an API key — read from .
process.env.EASYPOST_API_KEY - Always wrap purchase calls (,
Shipment.buy,Batch.buy,Pickup.buy) in try/catch. These are the calls that cost money.Insurance.create - Log the full array when a shipment has fewer rates than expected.
shipment.messages - When downloading a label, fetch and persist the bytes — don't store just the URL.
postage_label.label_url - When retrying a failed purchase, avoid double-purchasing: look up the shipment first and check whether is already populated.
postage_label - Prefer helpers (
client.Utils,getLowestRate,getLowestSmartRate) over rolling your own.validateWebhook
为用户编写EasyPost代码时,除非用户另有说明,请遵循以下约定:
- 优先使用SDK()而非原生HTTP请求。仅当SDK未覆盖对应端点时,再使用
@easypost/api。client.makeApiCall() - 在TypeScript中,从导入实体和参数类型(如
@easypost/api、IShipment等)。IShipmentCreateParameters - 请勿硬编码API密钥——从读取。
process.env.EASYPOST_API_KEY - 务必将购买类调用(、
Shipment.buy、Batch.buy、Pickup.buy)包裹在try/catch块中。这些调用会产生实际费用。Insurance.create - 当运单的费率数量少于预期时,记录完整的数组。
shipment.messages - 下载标签时,获取并持久化字节数据——不要仅存储URL。
postage_label.label_url - 重试失败的购买请求时,避免重复购买:先查询运单并检查是否已填充。
postage_label - 优先使用辅助方法(
client.Utils、getLowestRate、getLowestSmartRate)而非自行实现。validateWebhook
Writing style when teaching the user
指导用户时的写作风格
When the user is learning EasyPost (e.g., "how do I...?"), prefer showing a minimal runnable snippet over listing every field. Link to the specific reference file for the exhaustive field list. The PDF-style field dump is in the reference files; the top of SKILL.md and scripts are for "the five lines you actually need."
当用户学习EasyPost(例如“我该如何…?”)时,优先展示极简的可运行代码片段,而非列出所有字段。如需完整字段列表,请链接至对应的参考文件。参考文件中包含PDF式的字段详情;SKILL.md顶部和脚本目录提供的是“您实际需要的五行代码”。