Blog/Category
Shipping Tips & Tricks

Shipping for AI Agents: The Developer's Guide to MCP and API (2026)

November 30, 2026
Founder and CEO
Shipping for AI Agents: The Developer's Guide to MCP and API (2026)

Updated November 2026. Facts verified against vendor and carrier documentation; see references at the end.

There are 2 ways to connect a shipping API to an AI agent. Connect the Ship.com MCP server at https://app.ship.com/mcp when the agent lives in a client like Claude Code, Cursor or VS Code. Call the REST API under https://app.ship.com/public/ when your own server code runs the show. Both use the same Bearer token, both buy USPS and UPS labels from your Ship.com balance, and label purchases in your code should go through the MCP buy_label tool with a preview and a price cap.

Each section below covers one decision, and most link to a post with the full details.

MCP or REST: which shipping API should your AI agent use?

Use MCP when a model decides what to call. Use REST when your code decides. Most real builds use both: MCP for the agent, REST for the boring, predictable steps like creating an order from a checkout.

MCP serverREST API
Endpointhttps://app.ship.com/mcpPaths under https://app.ship.com/public/
TransportStreamable HTTP, JSON-RPC 2.0 over POST, stateless (no session IDs)JSON over HTTPS
AuthConnection key as Authorization: Bearer, or OAuth sign-in (40 tools on both)Authorization: Bearer <token>, the same token as the MCP connection key
Buy labelsbuy_label and trigger_batch_purchase, on either connectionIn our code examples, buying goes through the MCP tools (see below)
Tracking, voids, address checkstrack_order, cancel_shipping_label, validate_addressNot in REST
ErrorsHTTP status codes plus tool errors with isError: trueAlways HTTP 200; check the success field
Rate limit60 requests per minute per token; 429 with Retry-After: 60Not documented
Supporthelp@ship.comapi-support@ship.com

One rule covers both: keep the key on the server. Our MCP endpoint refuses browser requests from other websites (403 forbidden_origin), and anyone can copy a key out of front-end code.

How do you get a key?

The API is self-serve. Sign up at ship.com/sign-up, then in app.ship.com go to Settings > API Integration. The token starts with OAUTH2.. Despite the prefix, it is a plain bearer token, and it lasts 180 days.

The same token works for MCP and REST, so replacing it affects both. Clicking Generate API Key or calling the REST token refresh (POST /public/refresh) issues a new token and retires the old one for every MCP client and every REST integration at once. "Show my connection key" returns the same token while it is still valid, so it won't break anything.

You don't need your own USPS account or eVS. Ship.com buys the postage from your Ship.com balance, so you skip the USPS OAuth and payment-account setup we covered in our USPS Web Tools migration post.

How do you connect an agent through MCP?

In Claude Code it is one command:

claude mcp add --transport http shipcom https://app.ship.com/mcp --header "Authorization: Bearer YOUR_TOKEN"

Keep the --header part to use your connection key. Without it, Claude Code signs in through OAuth, which also gets all 40 tools. Cursor, VS Code and Windsurf take a short JSON file with the same URL and header. All 4 configs are in our MCP setup guide for Claude Code, Cursor and VS Code.

Claude's web, desktop and mobile apps connect with OAuth sign-in. Both connection types get all 40 tools, so they can quote, buy, track and manage orders. Exactly which Claude surface can do what is in Use Ship.com in Claude.

From your own code, connect with your framework's MCP client and pass the key as a header. The OpenAI Agents SDK uses MCPServerStreamableHttp with a headers param, and the Vercel AI SDK uses createMCPClient from @ai-sdk/mcp with an HTTP transport. Walkthroughs: shipping tools for the OpenAI Agents SDK and Stripe Checkout to shipping label in Next.js.

What does a safe label purchase look like in code?

You rate the order, preview the purchase, then confirm it with a cap. Here is the whole flow as raw MCP calls from a server shell, with the key in an environment variable. The order ID and ZIP are the examples from our docs.

export SHIPCOM_TOKEN="YOUR_TOKEN"   # server-side only, never in browser code

# 1. Rate an existing order (weights in ounces)
curl -s https://app.ship.com/mcp \
  -H "Authorization: Bearer $SHIPCOM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_rates","arguments":{"order_id":48210551,"weight_oz":12}}}'

# 2. Preview the purchase: confirm is false, nothing is bought
curl -s https://app.ship.com/mcp \
  -H "Authorization: Bearer $SHIPCOM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"buy_label","arguments":{"order_id":48210551,"rate_id":"RATE_ID_FROM_STEP_1","package_id":"PACKAGE_ID_FROM_STEP_1","method":"METHOD_FROM_STEP_1","service_level":"SERVICE_LEVEL_FROM_STEP_1","max_cost":8.00,"confirm":false}}}'

# 3. After a person approves the previewed price, buy with the same cap
curl -s https://app.ship.com/mcp \
  -H "Authorization: Bearer $SHIPCOM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"buy_label","arguments":{"order_id":48210551,"rate_id":"RATE_ID_FROM_STEP_1","package_id":"PACKAGE_ID_FROM_STEP_1","method":"METHOD_FROM_STEP_1","service_level":"SERVICE_LEVEL_FROM_STEP_1","max_cost":8.00,"confirm":true}}}'

Step 1 returns a package_id and a list of rates, each with its own rate_id, method and service_level. Rate tokens are long, so copy them exactly. Step 2 returns the price, pay_as_you_go_fee, total_charge and balance_after. Show those to a person. Step 3 buys, and the reply carries label_url, tracking_number and tracking_url.

If the rate is over the cap, the server refuses: "Refusing to buy: rate is $<price> which exceeds max_cost $<max>. Nothing was purchased." The cap covers postage only, not fees or insurance. The server doesn't require a preview before a confirm, so make your agent show the previewed total and wait for approval. And a clean preview can still fail on confirm, because the preview doesn't check billing, plan limits or the address.

Why MCP for buying, even from code? It has the confirm preview and the max_cost cap built in, and the same tools give you tracking and voids. We use this pattern in every code post. The full checklist, with logging and approvals, is in how to let an AI agent buy shipping labels safely.

What should REST handle?

REST is for the fixed steps your code runs the same way every time: create orders, rate them, manage customers and register a tracking webhook. The main endpoints:

  • POST /public/order creates one order. POST /public/order/batch takes an array, but it isn't transactional: if one order fails, the earlier ones are already created.
  • POST /public/quote rates a ZIP-to-ZIP shipment with no order. POST /public/shipping-info rates an existing order by orderID.
  • GET /public/order/{id} returns the order with a shipment object holding trackingNumber, trackingURL and shippingLabelURL.
  • GET, POST and PUT on customers, and POST /public/webhook for tracking notifications.

A minimal quote looks like this:

curl -s -X POST https://app.ship.com/public/quote \
  -H "Authorization: Bearer $SHIPCOM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"fromZip": "90210", "toZip": "10001", "weight": 12}'

Every REST response is HTTP 200, success or not. Read the success boolean, then error (and message when present). A failed auth looks like {"success": false, "error": "Invalid or Expired Credentials"}. ZIP fields take 5 digits. The REST pages don't state units for weight and dimensions; the MCP docs use ounces and inches, so check a quote before you trust a number. Full field lists are in the REST reference.

How does batch label buying work?

trigger_batch_purchase buys labels for many Ready to ship orders at once. Without confirm it rates every order and returns per-order prices and a postage total. With confirm: true it queues the batch, and labels are usually bought within about a minute. You follow it with get_batch_status.

Know the limits before you build on it. Batches buy USPS Ground Advantage only, there is no service choice, and one batch runs at a time per account. max_total has no default, so always set it. Orders that already have a label aren't bought twice, and voided or canceled orders drop out. Batch shipping needs a Growth or Executive plan. The 200-order walkthrough is in batch label purchase with an AI agent.

How should an agent handle errors and retries?

  • 429 from the MCP endpoint means you passed 60 requests per minute for that token. Wait the full Retry-After: 60. Every authenticated request counts, including initialize and tools/list.
  • 401 comes with a code: missing_bearer_token, invalid_token or expired_token. Pasting the whole "Authorization: Bearer ..." string into a header field gives you invalid_token.
  • "rate_id is invalid or has expired. Call get_rates again and use a fresh rate_id." means re-rate, then preview again.
  • Pass your own external_order_id to create_order or bulk_create_orders. A retry then returns the existing order instead of a duplicate. Don't fire parallel creates with the same ID.
  • For a wrong label, cancel_shipping_label voids within 29 days of the ship date. The refund goes to your postage balance, typically about 14 days after the carrier accepts the void, and not at all if the package was already scanned.

The full error table, with what your agent should do for each one, is in error handling for shipping agents.

How do you track shipments?

Use a webhook for label notifications and polling for shipment status. Register one webhook URL per account with POST /public/webhook. Deliveries carry X-Ship-Signature, an HMAC-SHA256 over the timestamp, a period and the raw body, and retries resend the same EventId, so dedupe on it. For shipment status, poll GET /public/order/{id} or call the MCP track_order tool.

What does it cost?

Postage is up to 89% off USPS and up to 87% off UPS. On top of plan pricing, buy_label adds a $0.30 pay-as-you-go fee per label when your auto-recharge amount is $0.01 or less, and quote rates already include any per-label charge your plan adds. Optional insurance on US orders is $0.99 for each $100, or part of $100, of insured value. Plan details are on our pricing page.

Where do you go deeper?

If you are building a vendor shortlist, read the best MCP servers for shipping in 2026 and the best EasyPost alternatives.

Frequently asked questions

Can an AI agent buy shipping labels through an API?

Yes. On Ship.com an agent buys through the MCP tools buy_label and trigger_batch_purchase, using a connection key sent as a Bearer header or OAuth sign-in. Both tools preview by default and only buy with confirm: true. Pass max_cost or max_total so the server refuses anything over your cap, and have a person approve the previewed price first.

Should I use MCP or REST for a shipping agent?

Use MCP when a model chooses the calls, in a client like Claude Code or through your framework's MCP client. Use REST for fixed steps in your own server code, like creating an order after checkout. Ship.com uses one Bearer token for both. Tracking, voids and address checks are MCP tools only, so most agent builds end up using both.

Do I need a USPS account to buy labels with Ship.com's API?

No. You don't need your own USPS account or eVS. Ship.com buys the postage from your Ship.com balance, and auto-recharge can top it up from your card on file. That means no USPS OAuth credentials, no Enterprise Payment Account and no label approval process on your side. You sign up, copy your key from Settings and start rating.

Why does the Ship.com REST API return 200 on errors?

That is how the REST API reports results: every response is HTTP 200 and JSON, whether the call worked or not. Your code has to read the success boolean in the body. When it is false, the error field, and sometimes a message field, explains why. The MCP endpoint is different: it uses HTTP codes like 401 and 429 and marks failed tool calls with isError.

Connect Ship.com to your agent

One URL and one key gets your agent rating, buying, batching and tracking USPS and UPS labels at up to 89% off USPS and up to 87% off UPS.

Read the Ship MCP setup guide

Create a Ship.com account

Build with the Ship.com API

Create orders, rate them and get tracking webhooks from your own server, with postage at up to 89% off USPS and up to 87% off UPS. Questions go to api-support@ship.com.

Get your API key

Create a Ship.com account

References

Joe DiSorbo
About the author
Joe DiSorbo
Founder and CEO

Joe DiSorbo is the founder and CEO of Ship.com, the shipping platform that gives more than 10,000 business customers discounted USPS and UPS rates and simplifies logistics for ecommerce brands and software platforms. Before Ship.com, he founded and led Webgistix, an ecommerce technology and global fulfillment company that grew internationally before Rakuten acquired it in 2013. His background spans global operations, software development, finance and logistics, with experience across the United States and Asia. Joe holds undergraduate degrees in Economics and Geography, masters degrees in Finance and International Management, and is a graduate of Harvard Business School (OPM 41).

Shipping software built for online sellers

Ship.com saves you time and money, giving you more freedom to live your life.

  • No credit card required.
  • Up to 89% off USPS and up to 87% off UPS.
  • Connects with major e-commerce platforms.
  • Free home pickup. Skip the trip to the post office.
Try for free
UPS
UP TO 87% OFF
Daily Rates*
USPS
UP TO 89% OFF
Retail Prices*
Today's orders
Order #1042USPS Ground AdvantageReady
Order #1043UPS Ground SaverReady
Order #1044USPS Priority MailReady
★★★★★Trusted by 10,000+ business customers

More on this topic

See all