PrepViaOrders API

PrepVia Orders API

Send the orders of your own store to PrepVia from your server. We pick, pack and ship them from our Miami warehouse, and you get the tracking back through the API and a webhook. You can also read your stock at the warehouse.

Get started

Base URL: https://api.prepvia.com/v1. Every request and response is JSON. Send Content-Type: application/json with a body.

  1. Create a test key on the Orders API page of the PrepVia app (https://www.app.prepvia.com/dashboard/channels/api). The key is shown once: store it on your server.
  2. Check the key with GET /v1/me.
  3. Send a test order, read it back, add your webhook and simulate a shipment. Test orders never ship.
  4. Create a live key and switch your server to it. Live orders go to the warehouse.
curl https://api.prepvia.com/v1/me \
  -H "Authorization: Bearer $PREPVIA_API_KEY"

Keys and test mode

Send the key in the Authorization header: Authorization: Bearer pvs_live_.... A key only sees its own PrepVia account. Revoke it in the app any time.

  • pvs_live_ keys create real orders. pvs_test_ keys create test orders that never ship and never touch your stock.
  • A test key only sees test orders, and a live key only sees live orders. Both read the same inventory.
  • Call the API from your server only. A call from a browser (any request with an Origin header) gets 403 browser_not_allowed. Never put a key in a web page or an app.
  • Every response has an X-Request-Id header, and every error body has request_id. Send it to your PrepVia contact when something looks wrong.

Errors

Every error has the same body:

{
  "error": {
    "code": "invalid_request",
    "message": "ship_to.postal_code must be a US ZIP code, like 33166 or 33166-1234",
    "param": "ship_to.postal_code"
  },
  "request_id": "0f6c1d2e-5a4b-4c3d-9e8f-7a6b5c4d3e2f"
}
HTTPcodeWhat it means
400invalid_requestA field or a filter is wrong. param says which one.
400invalid_jsonThe body is not valid JSON.
400unsupported_countryship_to.country is not US. PrepVia takes US addresses only for now.
400test_mode_onlysimulate_shipment was called with a live key.
401invalid_api_keyThe key is missing, wrong or revoked.
403account_suspendedThe PrepVia account is suspended.
403role_not_allowedAPI keys work only for PrepVia seller accounts.
403onboarding_requiredFinish the account setup in the PrepVia app first.
403api_not_enabledThe Orders API is not turned on for this account yet.
403insufficient_scopeThe key cannot do this. A key made before a feature existed lacks it: create a new key.
403browser_not_allowedThe call came from a browser. Call the API from your server only.
403api_connection_offPrepVia turned the Orders API off for this account.
404order_not_foundNo order with this id for this key (a test key sees only test orders).
404inventory_item_not_foundNo PrepVia item has this SKU in your account.
404webhook_endpoint_not_foundNo webhook endpoint with this id.
404not_foundNo such route.
409order_already_shippedA package already left the warehouse, so the order cannot be cancelled.
409order_cancelledThe test order is cancelled, so it cannot ship.
409order_changedThe order changed while PrepVia was working on it. Read it and try again.
409webhook_endpoint_existsThe account already has an endpoint for this mode. Delete it first.
413payload_too_largeThe body is over 64 KB.
422sku_not_foundA line has a SKU that is not a PrepVia item in your account (live key). Nothing was created.
429rate_limitedToo many requests. Wait Retry-After seconds.
500internal_errorSomething failed on our side. Try again, and send us the request_id if it repeats.
503orders_unavailablePrepVia cannot take orders through the API right now. Nothing was created. Try again in a few minutes.
503try_againPrepVia could not check the SKUs right now. Nothing was created. Send the same order again.
503address_not_storedPrepVia could not store the shipping address right now. Nothing was created. Send the same order again in a minute.
503webhooks_unavailablePrepVia cannot change webhook endpoints right now. Nothing was changed. Try again in a few minutes.

Limits

  • 120 requests per minute per key, and 600 per minute per IP.
  • Over the limit: 429 rate_limited, with a Retry-After header in seconds.
  • The request body can have up to 64 KB.
  • An order has 1 to 100 lines. A list returns up to 100.
  • Shipping addresses in the US only, for now.

Create an order

POST /v1/orders. Send each order once, as soon as it is paid. Sending the same external_id again is safe: you get the order that exists (200) and PrepVia never creates a second one. A new order answers 201.

FieldRules
external_idRequired. Your order id: 1 to 100 of A-Z a-z 0-9 . _ : # / -
order_numberOptional. What your buyer sees, up to 100 characters.
ordered_atOptional. ISO 8601 with the offset, like 2026-11-27T14:05:00Z.
ship_byOptional. ISO 8601 with the offset.
ship_to.nameRequired, up to 100 characters.
ship_to.address_line1Required, up to 100 characters. address_line2 and address_line3 are optional.
ship_to.cityRequired, up to 60 characters.
ship_to.stateRequired. The 2-letter code, like FL.
ship_to.postal_codeRequired. 12345 or 12345-6789.
ship_to.countryRequired. US.
ship_to.phoneOptional, up to 30 characters.
lines[].skuRequired. A SKU of a PrepVia item in your account.
lines[].quantityRequired. A whole number from 1 to 10000.
lines[].line_idOptional. Your line id, unique in the order.

Every SKU must be a PrepVia item in your account. With a live key, an order with an unknown SKU gets 422 sku_not_found and nothing is created: add the item, or ask PrepVia to match it, and send the same order again. With a test key the order is created, and status_detail says what a live key would do.

PrepVia stores the shipping address encrypted and uses it only for the label. No response ever returns it: an order shows only the city, the state, the first 3 digits of the ZIP code and the country.

curl https://api.prepvia.com/v1/orders \
  -H "Authorization: Bearer $PREPVIA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "external_id": "1001",
    "order_number": "#1001",
    "ordered_at": "2026-11-27T14:05:00Z",
    "ship_to": {
      "name": "Sample Buyer",
      "address_line1": "123 Example Ave",
      "city": "Miami",
      "state": "FL",
      "postal_code": "33166",
      "country": "US",
      "phone": "305-555-0100"
    },
    "lines": [{ "sku": "YOUR-SKU-1", "quantity": 2 }]
  }'

Read orders

GET /v1/orders/:id returns one order. GET /v1/orders lists the orders that changed most recently, with limit (1 to 100, 25 by default) or external_id. URL-encode the external_id: # goes as %23.

shipments lists each package that left the PrepVia warehouse, with the carrier and the tracking number. It stays empty until the first package leaves. The order turns shipped a few minutes after the last package leaves.

{
  "object": "order",
  "id": "5b1f0c2e-8a7d-4f3b-9d61-2c4e8f9a7b10",
  "external_id": "1001",
  "order_number": "#1001",
  "livemode": true,
  "status": "shipped",
  "status_detail": null,
  "ordered_at": "2026-11-27T14:05:00.000Z",
  "ship_by": null,
  "created_at": "2026-11-27T14:05:02.000Z",
  "updated_at": "2026-11-28T16:20:11.000Z",
  "destination": {
    "city": "Miami",
    "state": "FL",
    "postal_code_prefix": "331",
    "country": "US"
  },
  "lines": [
    { "line_id": "1", "sku": "YOUR-SKU-1", "quantity": 2, "matched": true }
  ],
  "shipments": [
    {
      "carrier": "USPS",
      "tracking_number": "9400100000000000000000",
      "shipped_at": "2026-11-28T16:15:40.000Z"
    }
  ]
}
# one order, by the PrepVia id
curl https://api.prepvia.com/v1/orders/ORDER_ID \
  -H "Authorization: Bearer $PREPVIA_API_KEY"

# your order, by your id (# goes as %23)
curl "https://api.prepvia.com/v1/orders?external_id=%231001" \
  -H "Authorization: Bearer $PREPVIA_API_KEY"

# the last 50 that changed
curl "https://api.prepvia.com/v1/orders?limit=50" \
  -H "Authorization: Bearer $PREPVIA_API_KEY"

Cancel an order

POST /v1/orders/:id/cancel.

  • 200: the order is cancelled (or it already was). Nothing ships.
  • 202: the warehouse already started. The order turns cancel_requested, and the PrepVia team stops it and confirms.
  • 409 order_already_shipped: a package already left. Nothing changes. Returns are between you and your buyer.
curl -X POST https://api.prepvia.com/v1/orders/ORDER_ID/cancel \
  -H "Authorization: Bearer $PREPVIA_API_KEY"

Order statuses

statusWhat it means
receivedPrepVia has the order and routes it to the warehouse.
needs_attentionThe PrepVia team must look at it. status_detail says why.
waiting_for_stockThe warehouse does not have enough units yet.
processingThe warehouse is picking and packing it.
cancel_requestedYou asked to cancel after the warehouse started. The team stops it and confirms.
shippedIt left the warehouse. shipments has the tracking.
cancelledCancelled, or PrepVia will not ship it. status_detail says which.

A test order stays received until you simulate a shipment or cancel it.

Inventory

Your stock at the PrepVia warehouse, by SKU: the same numbers PrepVia uses to route your orders. GET /v1/inventory lists by SKU, with limit (1 to 100, 25 by default), starting_after (the last SKU of the page before) or sku. GET /v1/inventory/:sku returns one.

SKU here means the SKU of your item in PrepVia. If PrepVia matched a SKU from your site to an item with a different SKU, read the stock with the PrepVia SKU of that item.

  • on_hand: the units PrepVia counted at the warehouse.
  • reserved: the units already held for orders PrepVia will ship.
  • available: on_hand minus reserved, never below 0. What a new order can take.
  • counted_at_prepvia: false: the SKU is linked to an Amazon listing, so PrepVia does not count it here. The three numbers are null and detail explains.
{
  "object": "inventory_item",
  "sku": "YOUR-SKU-1",
  "name": "Your product name",
  "image_url": "https://...",
  "livemode": true,
  "counted_at_prepvia": true,
  "on_hand": 10,
  "reserved": 3,
  "available": 7,
  "detail": null,
  "updated_at": "2026-11-27T13:00:00.000Z"
}
# the first 100 SKUs
curl "https://api.prepvia.com/v1/inventory?limit=100" \
  -H "Authorization: Bearer $PREPVIA_API_KEY"

# the next page: starting_after = the last sku of the page before
curl "https://api.prepvia.com/v1/inventory?limit=100&starting_after=LAST-SKU" \
  -H "Authorization: Bearer $PREPVIA_API_KEY"

# one SKU (URL-encode it)
curl https://api.prepvia.com/v1/inventory/YOUR-SKU-1 \
  -H "Authorization: Bearer $PREPVIA_API_KEY"

Webhooks

PrepVia sends a POST to your HTTPS address when an order ships (order.shipped) or is cancelled (order.cancelled, also when PrepVia will not ship it). The body has the order as GET /v1/orders/:id returns it.

  • One endpoint per account and mode: the test key adds the endpoint that gets test orders. The URL must be https, on the default port, with a public host name.
  • The secret (whsec_...) comes back only when you add the endpoint. Lost it: delete the endpoint and add it again. The delete cancels the events still waiting to go out, so read the orders that changed meanwhile with GET /v1/orders.
  • The event goes out a few minutes after the change. Answer 2xx within 10 seconds. If not, PrepVia tries again after about 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 12 hours, then stops.
  • The same event can arrive twice: skip an id you already handled. Events can arrive out of order: trust the order status, or read the order.
  • PrepVia never follows a redirect.
# add (the response has the secret, shown only this time)
curl https://api.prepvia.com/v1/webhook_endpoints \
  -H "Authorization: Bearer $PREPVIA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://your-site.com/prepvia/webhook" }'

# see it
curl https://api.prepvia.com/v1/webhook_endpoints \
  -H "Authorization: Bearer $PREPVIA_API_KEY"

# delete it
curl -X DELETE https://api.prepvia.com/v1/webhook_endpoints/ENDPOINT_ID \
  -H "Authorization: Bearer $PREPVIA_API_KEY"
POST https://your-site.com/prepvia/webhook
Content-Type: application/json
User-Agent: PrepVia-Webhooks/1.0
PrepVia-Event-Id: evt_8f14e45fceea167a5a36dedd
PrepVia-Signature: t=1795882840,v1=6f1c...e9a2

{
  "id": "evt_8f14e45fceea167a5a36dedd",
  "object": "event",
  "type": "order.shipped",
  "created_at": "2026-11-28T16:20:40.000Z",
  "livemode": true,
  "data": { "object": { "object": "order", "status": "shipped", "...": "..." } }
}

Verify a webhook

Every event is signed with your endpoint secret, in the PrepVia-Signature header: t=<unix time>,v1=<signature>. The signature is the HMAC-SHA256, in hex, of t, a dot and the raw body, with the secret as the key.

  • Use the raw body bytes, before any JSON parsing.
  • Compare in constant time.
  • Refuse an event whose t is more than 5 minutes from your clock.
import crypto from 'node:crypto';
import express from 'express';

const app = express();

// express.raw: the signature is over the exact bytes PrepVia sent.
app.post('/prepvia/webhook', express.raw({ type: 'application/json' }), (req, res) => {
  const raw = req.body.toString('utf8');
  const parts = {};
  for (const piece of String(req.get('PrepVia-Signature') || '').split(',')) {
    const [k, v] = piece.split('=');
    parts[k] = v;
  }
  const t = Number(parts.t);
  const expected = crypto
    .createHmac('sha256', process.env.PREPVIA_WEBHOOK_SECRET)
    .update(t + '.' + raw)
    .digest('hex');
  const ok =
    /^[0-9a-f]{64}$/.test(parts.v1 || '') &&
    crypto.timingSafeEqual(Buffer.from(parts.v1, 'hex'), Buffer.from(expected, 'hex')) &&
    Math.abs(Date.now() / 1000 - t) <= 300;
  if (!ok) return res.status(400).end();

  const event = JSON.parse(raw);
  // Skip event.id if you already handled it. Then update your order
  // with event.data.object (status and shipments).
  res.status(200).end();
});

Simulate a shipment

POST /v1/orders/:id/simulate_shipment, with a test key. The test order turns shipped with one sample package (carrier TEST), and order.shipped goes to your test endpoint. Nothing ships. A live key gets 400 test_mode_only.

curl -X POST https://api.prepvia.com/v1/orders/ORDER_ID/simulate_shipment \
  -H "Authorization: Bearer $PREPVIA_TEST_KEY"