Place an order
POST
/api/website/orders
const url = 'https://api.petanqueai.com/api/website/orders';const options = { method: 'POST', headers: { 'x-storefront-token': '<x-storefront-token>', 'Content-Type': 'application/json' }, body: '{"lines":[{"productId":"example","quantity":1}],"customer":{"name":"example","email":"hello@example.com","phone":"example"},"shipping":{"fullName":"example","phone":"example","email":"hello@example.com","city":"example","district":"example","addressLine":"example","postalCode":"example"},"billing":{"fullName":"example","phone":"example","email":"hello@example.com","city":"example","district":"example","addressLine":"example","postalCode":"example"},"promoCode":"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://api.petanqueai.com/api/website/orders \ --header 'Content-Type: application/json' \ --header 'x-storefront-token: <x-storefront-token>' \ --data '{ "lines": [ { "productId": "example", "quantity": 1 } ], "customer": { "name": "example", "email": "hello@example.com", "phone": "example" }, "shipping": { "fullName": "example", "phone": "example", "email": "hello@example.com", "city": "example", "district": "example", "addressLine": "example", "postalCode": "example" }, "billing": { "fullName": "example", "phone": "example", "email": "hello@example.com", "city": "example", "district": "example", "addressLine": "example", "postalCode": "example" }, "promoCode": "example" }'Creates an order for the given basket, buyer and delivery address. Prices are set by Petanque AI, never by your request. billing defaults to the delivery address; promoCode is optional.
If your shop takes card payment, the order comes back AWAITING_PAYMENT: continue with Start payment. Otherwise it is PENDING_APPROVAL and your team approves it in Petanque AI.
Shipping is a flat ₺150, free from ₺2,000 of products after discount. Stock is not reserved here; it is deducted when the order is approved. Do not retry blindly: every call creates a new order.
A problem with a product, the address or the promo code answers 422 with error.details.field naming the field.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
lines
required
Array<object>
object
productId
required
string
quantity
required
integer
customer
required
object
name
required
string
email
required
string format: email
phone
string
shipping
required
object
fullName
required
string
phone
required
string
email
string format: email
city
required
string
district
required
string
addressLine
required
string
postalCode
string
billing
object
fullName
required
string
phone
required
string
email
string format: email
city
required
string
district
required
string
addressLine
required
string
postalCode
string
promoCode
string
Example generated
{ "lines": [ { "productId": "example", "quantity": 1 } ], "customer": { "name": "example", "email": "hello@example.com", "phone": "example" }, "shipping": { "fullName": "example", "phone": "example", "email": "hello@example.com", "city": "example", "district": "example", "addressLine": "example", "postalCode": "example" }, "billing": { "fullName": "example", "phone": "example", "email": "hello@example.com", "city": "example", "district": "example", "addressLine": "example", "postalCode": "example" }, "promoCode": "example"}object
lines
required
Array<object>
object
productId
required
string
quantity
required
integer
customer
required
object
name
required
string
email
required
string format: email
phone
string
shipping
required
object
fullName
required
string
phone
required
string
email
string format: email
city
required
string
district
required
string
addressLine
required
string
postalCode
string
billing
object
fullName
required
string
phone
required
string
email
string format: email
city
required
string
district
required
string
addressLine
required
string
postalCode
string
promoCode
string
Example generated
lines=%7B%22productId%22%3A%22example%22%2C%22quantity%22%3A1%7D&name=example&email=hello%40example.com&phone=example&fullName=example&phone=example&email=hello%40example.com&city=example&district=example&addressLine=example&postalCode=example&fullName=example&phone=example&email=hello%40example.com&city=example&district=example&addressLine=example&postalCode=example&promoCode=exampleobject
lines
required
Array<object>
object
productId
required
string
quantity
required
integer
customer
required
object
name
required
string
email
required
string format: email
phone
string
shipping
required
object
fullName
required
string
phone
required
string
email
string format: email
city
required
string
district
required
string
addressLine
required
string
postalCode
string
billing
object
fullName
required
string
phone
required
string
email
string format: email
city
required
string
district
required
string
addressLine
required
string
postalCode
string
promoCode
string