Orders and CSV upload

An order is the record of one customer purchase (or a custom case). Chats run against orders, and what each chat learns is saved back to the order.

You do not have to create orders yourself: launching a chat with an order number finds or creates the matching order. Use the endpoints here when you want to manage orders directly or import many at once.

Create an order

curl https://api.refundhunter.io/api/orders \
  -H "Authorization: Bearer $CHATTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Cracked screen refund",
    "retailer": "bestbuy",
    "orderNumber": "BBY01-806912345678",
    "customerName": "Jordan Lee",
    "customerEmail": "jordan@example.com",
    "customerPhone": "555-010-2030",
    "issueSummary": "Item arrived with a cracked screen",
    "desiredResolution": "refund"
  }'

Creating a second order with the same retailer and order number returns 409.

Then launch a chat on it by passing orderId to POST /api/tasks. Customer details are filled in from the order.

Import a CSV

POST /api/orders/bulk-upload creates one order and one draft chat per row.

{
  "taskType": "bestbuypricematch",
  "csv": "order number,product name,best buy price,competitor price,competitor url\nBBY01-1,TV,999.99,849.99,https://example.com/tv",
  "taskFields": {
    "customerName": "Jordan Lee",
    "customerEmail": "jordan@example.com",
    "customerPhone": "555-010-2030"
  }
}
  • csv is the file contents as text, with a header row. Common header spellings are recognised (Order #, order_number, Competitor Price, Match Price, ...).
  • taskFields supplies values for anything the CSV does not have. Every row needs a customer name, email and phone from one place or the other.
  • The response lists the created orders and drafts, and errors with a line number for each row that was skipped.
  • Uploading the same orders again does not create duplicates.

Then launch the drafts with POST /api/drafts/deploy.

Find orders

GET /api/orders supports status, retailer, recordType, from, to, q (search) and needsReview. Results come 50 at a time (set limit up to 200). Pass the response's nextCursor as cursor to get the next page.

Order status is one of draft, in_progress, resolved, unresolved, follow_up_needed, closed.

What a chat found out

EndpointReturns
GET /api/orders/{id}The order, with keyDetails (latest case number, rep name, refund amount, ...)
GET /api/orders/{id}/attemptsEvery chat run on the order and how each ended. agentId is the task id
GET /api/orders/{id}/detailsEach extracted fact, with a confidence score and whether it has been confirmed
GET /api/orders/{id}/eventsThe order's history

Extracted facts start as pending. Confirm or reject one with POST /api/orders/{id}/details/{detailId}/confirm or /reject.

Update and delete

  • PATCH /api/orders/{id} updates one order; PATCH /api/orders updates up to 500 (ids plus updates).
  • DELETE /api/orders with ids removes orders for good, with their history, and cancels any chats still running on them. POST /api/orders/check-delete tells you first how many orders and live chats that would affect.