{"openapi":"3.0.3","info":{"title":"AfraCC","description":"Third Party Integration Docs","version":"2.0.0","contact":{"url":"https://afracc.com"}},"servers":[{"url":"https://ir.afracc.ir/","description":"Trough CDN"},{"url":"https://de.afracc.com/","description":"Cloudflare CDN"},{"url":"https://direct.afracc.ir/","description":"Direct Access"}],"paths":{"/api/shops/{shop_id}/customers/find":{"get":{"summary":"Find Customer","operationId":"findCustomer","description":"Find Customer by either phone or id","parameters":[{"schema":{"type":"string","example":"09123456789"},"in":"query","name":"phone","description":"Customer phone number, Required without customer_id"},{"schema":{"type":"string","format":"uuid","example":"5E996F36-5205-4EEE-9BA2-4716287321DC"},"in":"query","name":"customer_id","description":"Afra Customer ID, Required without phone"}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","example":{"customer":{"id":null,"name":"بامیک قانونی","phone":"05449391055","orders_count":0,"orders_total":0,"orders_avg":0,"badge":"silver","rfm_score":0,"rates_avg":0,"satisfaction":"none","last_order_date":null,"birthday":null,"points":0,"wallet_balance":0,"min_wallet_transaction":0,"rfm_label":"uncertain","first_order_date":null,"created_at":null}},"properties":{"customer":{"type":"object","properties":{"id":{"type":"string","example":null},"name":{"type":"string","example":"بامیک قانونی"},"phone":{"type":"string","example":"05449391055"},"orders_count":{"type":"integer","example":0},"orders_total":{"type":"integer","example":0},"orders_avg":{"type":"integer","example":0},"badge":{"type":"string","example":"silver"},"rfm_score":{"type":"integer","example":0},"rates_avg":{"type":"integer","example":0},"satisfaction":{"type":"string","example":"none"},"last_order_date":{"type":"string","example":null},"birthday":{"type":"string","example":null},"points":{"type":"integer","example":0},"wallet_balance":{"type":"integer","example":0},"min_wallet_transaction":{"type":"integer","example":0},"rfm_label":{"type":"string","example":"uncertain"},"first_order_date":{"type":"string","example":null},"created_at":{"type":"string","example":null}}}}}}}},"404":{"description":"Customer not found","content":{"application/json":{"schema":{"type":"object","example":{"message":"Customer not found"},"properties":{"message":{"type":"string","example":"Customer not found"}}}}}}},"tags":["Customers"]},"parameters":[{"in":"path","name":"shop_id","description":"The ID of the shop.","example":"5E996F36-5205-4EEE-9BA2-4716287321DC","required":true,"schema":{"type":"string","format":"uuid","example":"5E996F36-5205-4EEE-9BA2-4716287321DC"}}]},"/api/shops/{shop_id}/orders":{"post":{"summary":"Create Customer and Order","operationId":"createCustomerAndOrder","description":"","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","example":{"order":{"id":null,"number":null,"customer":{"id":"9e0d49d0-9bec-4c35-9fa5-dd577968fea1","name":"دکتر هلاله فریاد","phone":"07109932710","orders_count":0,"orders_total":0,"orders_avg":0,"badge":"bronze","rfm_score":0,"rates_avg":0,"satisfaction":"none","last_order_date":null},"status":null,"amount":98,"discount":10,"reception_channel":null,"branch_name":null,"created_at":null,"updated_at":null}},"properties":{"order":{"type":"object","properties":{"id":{"type":"string","example":null},"number":{"type":"string","example":null},"customer":{"type":"object","properties":{"id":{"type":"string","example":"9e0d49d0-9bec-4c35-9fa5-dd577968fea1"},"name":{"type":"string","example":"دکتر هلاله فریاد"},"phone":{"type":"string","example":"07109932710"},"orders_count":{"type":"integer","example":0},"orders_total":{"type":"integer","example":0},"orders_avg":{"type":"integer","example":0},"badge":{"type":"string","example":"bronze"},"rfm_score":{"type":"integer","example":0},"rates_avg":{"type":"integer","example":0},"satisfaction":{"type":"string","example":"none"},"last_order_date":{"type":"string","example":null}}},"status":{"type":"string","example":null},"amount":{"type":"integer","example":98},"discount":{"type":"integer","example":10},"reception_channel":{"type":"string","example":null},"branch_name":{"type":"string","example":null},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","example":null,"format":"date-time"}}}}}}}}},"tags":["Orders"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["amount","items"],"properties":{"customer_name":{"type":"string","description":"Must not be greater than 120 characters.","example":"solebfjkenowwovthw"},"customer_phone":{"type":"string","description":"Find customer using phone. not required when customer_id is provided.","example":null},"customer_id":{"type":"string","description":"This field is required when customer_phone is not present.  Must be a valid UUID.","example":"09875238-645d-32d9-82df-f4b9783bc467","format":"uuid"},"number":{"type":"integer","description":"Local id of the order. If already exists, the order will be updated. Update only includes these fields: 'status', 'product_count', 'reception_channel', 'branch_name'","example":null},"status":{"type":"string","example":"processing","enum":["processing","completed"]},"amount":{"type":"integer","description":"Total of the customers cart (**excluding** tax, fees, discounts, shipping costs, etc.)","example":null},"discount":{"type":"integer","description":"Total amount of discount given for the order.","example":null},"total":{"type":"integer","x-stoplight":{"id":"ms7equrrgmlku"},"description":"The actual price paid by customer (**including** tax, shipping, discounts, fees, etc.)"},"product_count":{"type":"integer","description":"Must be at least 1. not needed if you are sending the complete list of items.","example":33},"promo_code":{"type":"string","description":"Promo Code that should be applied on the order.","example":null},"use_wallet":{"type":"boolean","description":"Indicates if customers wallet should be used or not. Default: false","example":null},"created_at":{"type":"string","description":"Must be a valid datetime (rfc 3339) or timestamp. If not provided current time will be used.","example":"2025-01-25T09:58:21Z","format":"date-time"},"reception_channel":{"type":"string","example":"vel"},"branch_name":{"type":"string","example":"vel"},"items":{"type":"array","example":null,"items":{"type":"object","required":["title"],"properties":{"local_id":{"type":"integer","description":"Local product ID from the source.","example":null},"title":{"type":"string","description":"Must not be greater than 128 characters.","example":"olebfjkenowwovthwu"},"price":{"type":"integer","description":"Unit price of an item.","example":null},"count":{"type":"integer","description":"Item count.","example":null},"discount":{"type":"integer","description":"Item discount.","example":null},"total":{"type":"integer","description":"Item total including tax and discoutns.","example":null},"cat_id":{"type":"string","x-stoplight":{"id":"vc1u1sxkugy0p"},"description":"Item's category id"},"cat_title":{"type":"string","x-stoplight":{"id":"mlsott0ivj21t"},"description":"Item's category title"}}}},"address":{"type":"object","x-stoplight":{"id":"7nqar9f29a35b"},"properties":{"city":{"type":"string","x-stoplight":{"id":"y2zq7nriaj3dm"}},"state":{"type":"string","x-stoplight":{"id":"sjypnvn562zwp"}}}},"coupon_id":{"type":"string","x-stoplight":{"id":"qrr6875vrpl8o"},"format":"uuid","description":"see Coupons section"}}}}},"description":"This single request handles all of the processes related to placement of an order.\nIncluding creation of a new customer (if none exists) with the given phone number.\nConsumption of any incentive including wallet balance, coupons and promo-codes are done accordingly. "}},"parameters":[{"in":"path","name":"shop_id","description":"UUID of the shop.","example":null,"required":true,"schema":{"type":"string","format":"uuid","example":"A492D5C5-58A0-4830-AD46-131DFD9B835F"}}]},"/api/shops/{shop_id}/orders/{id}":{"delete":{"summary":"Delete Shop Order","operationId":"deleteShopOrder","description":"Cancellation of an order. \nThis process will **refund** all incentives used in the process of placing the order.\n","parameters":[],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"type":"object","example":{"message":"Order Deleted","status":"ok"},"properties":{"message":{"type":"string","example":"Order Deleted"},"status":{"type":"string","example":"ok"}}}}}},"404":{"description":"Order/Shop not found","content":{"application/json":{"schema":{"type":"object","example":{"message":"..."},"properties":{"message":{"type":"string","example":"..."}}}}}}},"tags":["Orders"]},"parameters":[{"in":"path","name":"shop_id","description":"The UUID of the shop","example":"5E996F36-5205-4EEE-9BA2-4716287321DC","required":true,"schema":{"type":"string"}},{"in":"path","name":"id","description":"The UUID of the order","example":"5E996F36-5205-4EEE-9BA2-4716287321DC","required":true,"schema":{"type":"string"}}]},"/api/shops/{shop_id}/promo_codes/redeem":{"post":{"summary":"Check Promo Code","operationId":"redeemPromoCode","description":"check if promo code is redeemable","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","example":{"code_title":"Code Title","code_expiration":null,"customer_id":"09875238-645d-32d9-82df-f4b9783bc467","percentage":0,"min_price":1000,"max_price":10000,"variant":"public","order_subtotal":10000},"properties":{"code_title":{"type":"string","example":"Code Title","description":"Campaign title"},"code_expiration":{"type":"string","example":null,"description":"Datetime indicating end of campaign"},"customer_id":{"type":"string","example":"09875238-645d-32d9-82df-f4b9783bc467","description":"UUID of customer if campaign is targeted"},"percentage":{"type":"integer","example":0,"description":"Promo Codes amount percentage (up to max_price)"},"min_price":{"type":"integer","example":1000,"description":"Minimum applicable order subtotal"},"max_price":{"type":"integer","example":10000,"description":"Maximum amount of discount"},"variant":{"type":"string","example":"public","description":"Promo Code type. Enum: discount, invitation, automation, public"},"order_subtotal":{"type":"integer","example":10000,"description":"Calculated subtotal based on given subtotal, campaign, and wallet balance"}}}}}},"400":{"description":"Invalid code provided","content":{"application/json":{"schema":{"type":"object","example":{"message":"[localized error message]"},"properties":{"message":{"type":"string","example":"[localized error message]"}}}}}},"404":{"description":"Customer not found","content":{"application/json":{"schema":{"type":"object","example":{"message":"Customer not found"},"properties":{"message":{"type":"string","example":"Customer not found"}}}}}}},"tags":["Promo Code"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"promo_code":{"type":"string","description":"Promo Code.","example":"testcode"},"customer_phone":{"type":"string","description":"This field is required when <code>customer_id</code> is not present.  Must match the regex /[0-9]{10}/.","example":"09123456789"},"customer_id":{"type":"string","description":"This field is required when <code>customer_phone</code> is not present.  Must be a valid UUID.","example":"300db7de-747d-33a9-9c5b-0479238d834a"},"order_subtotal":{"type":"number","description":"Total sum of order including discounts.","example":12345},"use_wallet":{"type":"boolean","description":"Indicates if wallet balance should be used or not. Default: false","example":false},"branch_name":{"type":"string","description":"Name of the branch.","example":null},"discount":{"type":"number","description":"Amount of discount given to customer.","example":null}},"required":["promo_code"]}}}}},"parameters":[{"in":"path","name":"shop_id","description":"UUID of the shop.","example":"5E996F36-5205-4EEE-9BA2-4716287321DC","required":true,"schema":{"type":"string"}}]},"/api/shops/{shop_id}/coupons/available":{"parameters":[{"schema":{"type":"string","format":"uuid","example":"5E996F36-5205-4EEE-9BA2-4716287321DC"},"name":"shop_id","in":"path","required":true,"description":"UUID of the shop"}],"get":{"summary":"Available Coupons","tags":["Coupons"],"responses":{"2XX":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","x-stoplight":{"id":"64i4uzft910c3"},"format":"uuid"},"active":{"type":"boolean","x-stoplight":{"id":"pchkctcnqj5e4"}},"condition":{"type":"string","x-stoplight":{"id":"c9v8reo6r9mnp"},"description":"one of:\n- badge: if customer has a certain badge\n- min_price: if order_subtotal is more that min_price\n- order_count: if customer has minimum of order_count orders \n- product: if customer has a certain product in cart\n- category: if customer has a product from a certain category in cart\n- tag: if customer has a certain tag"},"condition_options":{"type":"string","x-stoplight":{"id":"iqjha635l0zbg"}},"action":{"type":"string","x-stoplight":{"id":"w969p21ncj123"},"description":"one of: award,free_shipping,cart_discount"},"action_options":{"type":"string","x-stoplight":{"id":"m4hdldaskef5z"}},"order_subtotal":{"type":"string","x-stoplight":{"id":"4ic13opjcnhe1"}}}}}}}},"operationId":"get-api-shops-shop-coupons-available","description":"Get list of available coupons for a given customer.\nProviding orders' subtotal (sum of the price of all cart items, excluding tax, shipping costs, fees, etc.) is recommanded.","parameters":[{"schema":{"type":"string","example":"09123456789"},"in":"query","name":"customer_phone","description":"get by customer phone"},{"schema":{"type":"string","format":"uuid","example":"5E996F36-5205-4EEE-9BA2-4716287321DC"},"in":"query","name":"customer_id","description":"get by customer id"},{"schema":{"type":"integer"},"in":"query","name":"order_total","description":"order amount if available"}]}}},"tags":[{"name":"Customers","description":""},{"name":"Orders","description":""},{"name":"Promo Code","description":""},{"name":"Coupons","description":""}],"components":{"securitySchemes":{"default":{"type":"http","scheme":"bearer","description":""}}},"security":[{"default":[]}]}