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.
- 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. - Check the key with
GET /v1/me. - Send a test order, read it back, add your webhook and simulate a shipment. Test orders never ship.
- 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
Originheader) gets 403browser_not_allowed. Never put a key in a web page or an app. - Every response has an
X-Request-Idheader, and every error body hasrequest_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"
}| HTTP | code | What it means |
|---|---|---|
| 400 | invalid_request | A field or a filter is wrong. param says which one. |
| 400 | invalid_json | The body is not valid JSON. |
| 400 | unsupported_country | ship_to.country is not US. PrepVia takes US addresses only for now. |
| 400 | test_mode_only | simulate_shipment was called with a live key. |
| 401 | invalid_api_key | The key is missing, wrong or revoked. |
| 403 | account_suspended | The PrepVia account is suspended. |
| 403 | role_not_allowed | API keys work only for PrepVia seller accounts. |
| 403 | onboarding_required | Finish the account setup in the PrepVia app first. |
| 403 | api_not_enabled | The Orders API is not turned on for this account yet. |
| 403 | insufficient_scope | The key cannot do this. A key made before a feature existed lacks it: create a new key. |
| 403 | browser_not_allowed | The call came from a browser. Call the API from your server only. |
| 403 | api_connection_off | PrepVia turned the Orders API off for this account. |
| 404 | order_not_found | No order with this id for this key (a test key sees only test orders). |
| 404 | inventory_item_not_found | No PrepVia item has this SKU in your account. |
| 404 | webhook_endpoint_not_found | No webhook endpoint with this id. |
| 404 | not_found | No such route. |
| 409 | order_already_shipped | A package already left the warehouse, so the order cannot be cancelled. |
| 409 | order_cancelled | The test order is cancelled, so it cannot ship. |
| 409 | order_changed | The order changed while PrepVia was working on it. Read it and try again. |
| 409 | webhook_endpoint_exists | The account already has an endpoint for this mode. Delete it first. |
| 413 | payload_too_large | The body is over 64 KB. |
| 422 | sku_not_found | A line has a SKU that is not a PrepVia item in your account (live key). Nothing was created. |
| 429 | rate_limited | Too many requests. Wait Retry-After seconds. |
| 500 | internal_error | Something failed on our side. Try again, and send us the request_id if it repeats. |
| 503 | orders_unavailable | PrepVia cannot take orders through the API right now. Nothing was created. Try again in a few minutes. |
| 503 | try_again | PrepVia could not check the SKUs right now. Nothing was created. Send the same order again. |
| 503 | address_not_stored | PrepVia could not store the shipping address right now. Nothing was created. Send the same order again in a minute. |
| 503 | webhooks_unavailable | PrepVia 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 aRetry-Afterheader 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.
| Field | Rules |
|---|---|
| external_id | Required. Your order id: 1 to 100 of A-Z a-z 0-9 . _ : # / - |
| order_number | Optional. What your buyer sees, up to 100 characters. |
| ordered_at | Optional. ISO 8601 with the offset, like 2026-11-27T14:05:00Z. |
| ship_by | Optional. ISO 8601 with the offset. |
| ship_to.name | Required, up to 100 characters. |
| ship_to.address_line1 | Required, up to 100 characters. address_line2 and address_line3 are optional. |
| ship_to.city | Required, up to 60 characters. |
| ship_to.state | Required. The 2-letter code, like FL. |
| ship_to.postal_code | Required. 12345 or 12345-6789. |
| ship_to.country | Required. US. |
| ship_to.phone | Optional, up to 30 characters. |
| lines[].sku | Required. A SKU of a PrepVia item in your account. |
| lines[].quantity | Required. A whole number from 1 to 10000. |
| lines[].line_id | Optional. 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
| status | What it means |
|---|---|
| received | PrepVia has the order and routes it to the warehouse. |
| needs_attention | The PrepVia team must look at it. status_detail says why. |
| waiting_for_stock | The warehouse does not have enough units yet. |
| processing | The warehouse is picking and packing it. |
| cancel_requested | You asked to cancel after the warehouse started. The team stops it and confirms. |
| shipped | It left the warehouse. shipments has the tracking. |
| cancelled | Cancelled, 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 arenullanddetailexplains.
{
"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 withGET /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
idyou already handled. Events can arrive out of order: trust the orderstatus, 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"