ResaleWarden

API guide for stores and marketplaces

Check items from your own intake, point-of-sale or listing systems, keep the audit trail, and hear when stock is recalled later.

Everything here is also available in the store portal, at resalewarden.drbyte.org/portal, which is where an owner opens a store, chooses a plan, creates API keys and adds webhooks. Using the API means agreeing to the store terms; what an answer means, and what it does not, is set out in sources and coverage.

Basics

API keys and scopes

An owner creates keys on the portal's API keys page. The key is shown once, in full, and only its first characters are kept for display; store it in a secret store, never in code or a web page. Send it in the x-api-key header:

curl https://resalewarden.drbyte.org/api/v1/check \
  -H "x-api-key: $RESALEWARDEN_KEY" \
  -H "content-type: application/json" \
  -d '{"brand": "Acme", "model": "AB-100"}'

Each key has one or more scopes:

ScopeAllows
checkChecks, label photos and batch uploads.
lookups:readThe audit log, its exports, batch status and results, and the stock list.
inventoryRecording stock decisions.

A key can be tied to one of the store's locations, and then files its checks there. A key can never manage the account: people, plans, keys and webhooks are managed in the portal. Revoke a key on the same page; a revoked, unknown or malformed key gets the same 401.

Checking an item

POST /api/v1/check with a barcode, or a brand (and, ideally, a model):

FieldTypeNotes
gtinstring8, 12, 13 or 14 digits with a valid check digit; spaces and dashes are allowed.
brand, modelstringUp to 120 characters each, as printed on the label.
descriptionstringUp to 300 characters, such as "convertible car seat". Never a customer's details.
categorystringOne of the category keys from GET /api/v1/meta.
manufacture_datestringYYYY, YYYY-MM or YYYY-MM-DD; not in the future.
jurisdictionstringCA, CA-ON, US, US-CA and so on. Defaults to the store's region.
location_idintegerOne of the store's locations. Defaults to the key's location, if it has one.

The answer is recorded in the audit log before it is returned:

{
  "lookup_id": 812,
  "checked_at": "2026-10-07T15:00:00.000Z",
  "jurisdiction": "US",
  "verdict": "CHECK",
  "reason": "Model AB-100 was recalled by CPSC on 2025-03-14 under the brand Acme Baby. Confirm the brand on the label.",
  "what_to_check": ["Model AB-100 was recalled by CPSC on 2025-03-14 under the brand Acme Baby. Confirm the brand on the label."],
  "what_to_do": [],
  "product": { "gtin": null, "brand": "Acme", "model": "AB-100", "category": "juvenile_products", "...": "..." },
  "recalls": [ { "recall_id": "...", "agency": "CPSC", "recall_date": "2025-03-14", "hazard": "...",
                 "remedy": "...", "source_url": "https://...", "match": "model_similar_brand" } ],
  "rules": [],
  "sources": [ { "name": "CPSC recall ...", "url": "https://..." } ],
  "data_as_of": "2026-10-07T11:45:00.000Z"
}

Each check counts against the plan's monthly allowance. When the recall data cannot be reached, the API answers 503, records nothing and counts nothing: try again later.

From a label photo

POST /api/v1/check/photo with {"image": "<base64 JPEG or PNG>"}, at most 5 MB, plus any of the fields above that you already know (they win over what is read). The label is read on our server; the reply is a check, plus extracted (the fields read), ocr_confidence and photo_kept, which is true only when the store keeps label photos. When no brand or barcode can be read, the answer is 422 with what was read, and nothing is counted.

Batch CSV uploads

On plans that include batch uploads, POST /api/v1/check/batch takes a CSV file (content-type: text/csv) of up to 5,000 rows and 2 MB, with a header row of these columns, in any order (add ?location_id= to the upload to file its checks under one of the store's locations):

gtin,brand,model,description,category,manufacture_date,jurisdiction,sku

Rows are validated on upload, and the reply is 202 with {id, rows_total, invalid, status_url}. Each valid row becomes a counted check, worked through in the background; when the month's allowance runs out, the remaining rows are marked limit. GET /api/v1/check/batch/{id} gives progress and totals, and GET /api/v1/check/batch/{id}/results.csv the result of every row. Finished batches are kept for 30 days; their checks stay in the audit log.

The audit log and exports

The audit log can always be read and exported, whatever the plan, and also after a plan ends. Records are never changed or deleted.

Stock decisions

Record what the store did with a checked item, so that it can be checked again later:

On plans that include re-checks, items in stock are checked again when the recall data or a rule changes; a new RECALLED or DO_NOT_SELL is recorded in the audit log and sent to your webhooks.

Webhooks

On plans that include webhooks, an owner adds up to five on the portal's Webhooks page: an HTTPS address on the public internet, and the events to send. The signing secret is shown once, when the webhook is created. The page can send a test delivery and lists the last 50 deliveries with their status.

EventSent whendata
inventory.recalled An item in stock is checked again and its answer becomes RECALLED or DO_NOT_SELL. item (id, sku, location_id), previous_verdict, verdict, reason, product, recalls, rules, sources, data_as_of, lookup_id (the new check) and original_lookup_id.
batch.completed A batch upload has finished. batch_id, totals and results (the path of its results CSV).
webhook.test An owner sends a test delivery. Empty.

Each delivery is a POST of {"event": ..., "created_at": ..., "data": {...}} with these headers:

Answer with any 2xx status within 10 seconds, and do the work afterwards. Any other answer, a timeout or a refused connection is tried again after 1, 2, 4, 8, 16, 32 and 64 minutes: 8 attempts in all, over about two hours, and then the delivery is recorded as failed. Redirects are not followed.

Checking a signature

Compute the signature over the raw body, exactly as received, compare it in constant time, and reject a timestamp more than five minutes from your clock. In Node.js:

import { createHmac, timingSafeEqual } from 'node:crypto';

export function verify(secret, timestamp, signature, rawBody) {
  if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
  const mac = createHmac('sha256', secret).update(`${timestamp}.${rawBody}`).digest('hex');
  const expected = Buffer.from(`sha256=${mac}`);
  const given = Buffer.from(signature ?? '');
  return given.length === expected.length && timingSafeEqual(given, expected);
}

In Python:

import hashlib, hmac, time

def verify(secret: str, timestamp: str, signature: str, raw_body: bytes) -> bool:
    if abs(time.time() - int(timestamp)) > 300:
        return False
    mac = hmac.new(secret.encode(), timestamp.encode() + b"." + raw_body, hashlib.sha256)
    return hmac.compare_digest(signature, "sha256=" + mac.hexdigest())

Limits

Errors

Every error is JSON with a sentence in error that can be shown to a person; some add fields, such as problems (a list, for invalid input), feature and plan (a feature outside the plan), or plan, limit and allowance (an allowance used up).

{
  "error": "gtin is not a valid barcode (8, 12, 13 or 14 digits with a correct check digit)",
  "problems": ["gtin is not a valid barcode (8, 12, 13 or 14 digits with a correct check digit)"]
}
StatusMeaning
400The request is not valid; problems says why.
401No key, or a key that is unknown, revoked or malformed, or belongs to a closed account.
403The key's scopes do not allow this, or the plan does not include it (feature, plan).
404No such route, or nothing with that id in this store.
409The request conflicts with what is recorded, such as a second stock decision for one check.
413Too large: a photo over 5 MB, a batch file over 2 MB or 5,000 rows, any other request body over 256 KB, a CSV export over 50,000 rows (export a shorter period), or a PDF export over 5,000 rows (use CSV).
422A label photo from which no brand or barcode could be read.
429The month's checks are used up, or too many requests too quickly.
503Recall data or a needed service is unavailable for a moment; nothing was recorded.

Help

Write to support@resalewarden.drbyte.org with the request, the time, the response and, never the full key, the first characters of the key you used.