Generate a draft offer
POST
/api/offers
const url = 'https://example.com/api/offers';const options = { method: 'POST', headers: { cookie: 'better-auth.session_token=<better-auth.session_token>', 'Content-Type': 'application/json' }, body: '{"customerId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","customerName":"example","clientRequest":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/api/offers \ --header 'Content-Type: application/json' \ --cookie better-auth.session_token=<better-auth.session_token> \ --data '{ "customerId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "customerName": "example", "clientRequest": "example" }'AI-assisted offer generation backed by the products table.
Authorizations
Section titled “Authorizations ”Request Body
Section titled “Request Body ”Customer name and request text for the new offer.
Media type application/json
Input accepted when generating a new draft offer.
object
customerId
string | null format: uuid
customerName
string
clientRequest
required
string
Example generated
{ "customerId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "customerName": "example", "clientRequest": "example"}Responses
Section titled “ Responses ”A newly persisted draft offer.
Media type application/json
object
offer
required
Persisted offer shape returned by creation endpoints.
object
id
required
string
customerId
required
string | null
requestId
required
string | null
userId
required
string | null
name
required
string
status
required
string
currency
required
string
discountPercent
required
number
discountAmount
required
number
notes
required
Array<string>
unmatched
required
Array<string>
items
required
Array<object>
A product line item included in an offer.
object
id
string
offerId
string
productId
required
string | null
name
required
string
description
required
string
quantity
required
number
unitPriceNet
required
number
vatRate
required
number
unitGrossPrice
required
number
totalNet
required
number
totalGross
required
number
requestItem
required
string
rationale
required
string
matchSource
required
string | null
matchScore
required
number | null
position
required
integer
product
Product snapshot used to render an offer line without frontend fixture lookup.
object
id
required
string
sku
string
name
required
string
description
string
createdAt
required
string format: date-time
updatedAt
required
string format: date-time
customerName
string | null
clientRequest
string | null
userName
string | null
Example
{ "offer": { "id": "offer-demo-001", "status": "draft", "items": [ { "matchSource": "exact" } ] }}The request body could not be parsed or validated.
Media type application/json
Standard API error payload.
object
error
required
object
code
required
string
message
required
string
issues
Array<string>
Example generated
{ "error": { "code": "example", "message": "example", "issues": [ "example" ] }}No valid Better Auth session was present.
Media type application/json
Returned when no valid Better Auth session is present.
object
error
required
string
Example generated
{ "error": "example"}