Discounts
This section covers the API endpoints for managing discounts in the admin panel.
List Discounts
GET /v1/admin/discounts
Returns a list of discounts with pagination support.
Query Parameters
| Parameter | Type | Description | Validation Rules |
|---|---|---|---|
search_text | string | Search in discount names | Optional |
filter[active] | string | Filter by active status | Optional, values: true, false |
filter[trashed] | string | Filter by trashed status | Optional |
sort | string | Sort field | Optional, values: name, amount, active |
per_page | integer | Number of items per page | Optional, default: 10 |
Response
{
"success": true,
"message": "تم جلب البيانات بنجاح.",
"data": {
"current_page": 1,
"first_page_url": "http://testing-api.sumaya369.net/v1/admin/discounts?per_page=50&page=1",
"from": 1,
"last_page": 3,
"last_page_url": "http://testing-api.sumaya369.net/v1/admin/discounts?per_page=50&page=3",
"links": [
{
"url": null,
"label": "« السابق",
"active": false
},
{
"url": "http://testing-api.sumaya369.net/v1/admin/discounts?per_page=50&page=1",
"label": "1",
"active": true
},
{
"url": "http://testing-api.sumaya369.net/v1/admin/discounts?per_page=50&page=2",
"label": "2",
"active": false
},
{
"url": "http://testing-api.sumaya369.net/v1/admin/discounts?per_page=50&page=3",
"label": "3",
"active": false
},
{
"url": "http://testing-api.sumaya369.net/v1/admin/discounts?per_page=50&page=2",
"label": "التالي »",
"active": false
}
],
"next_page_url": "http://testing-api.sumaya369.net/v1/admin/discounts?per_page=50&page=2",
"path": "http://testing-api.sumaya369.net/v1/admin/discounts",
"per_page": 50,
"prev_page_url": null,
"to": 50,
"total": 132,
"discounts": [
{
"id": "ade63e40-abfd-11ef-a755-97b4e945593d",
"name": "mazen",
"code": "wwww",
"amount": "100.00 ر.س",
"product": "1",
"customer": "ذوي الاحتياجات الخاصة",
"active": true
},
{
"id": "3e6d33e0-9208-11ef-a4b3-396dbb8180c6",
"name": "رسريسريسر",
"code": "بيسبسيب",
"amount": "2.00 ر.س",
"product": "كل المنتجات",
"customer": "0",
"active": true
},
{
"id": "8e00aee0-9205-11ef-8186-ff3a5845ab38",
"name": "amaaa1",
"code": "xxxx",
"amount": "100.00 ر.س",
"product": "كل المنتجات",
"customer": "كل العملاء",
"active": false
},
{
"id": "53f47340-9205-11ef-81d4-8d162b3c8cd6",
"name": "amaaa1",
"code": "amaa7772",
"amount": "5.00 ر.س",
"product": "كل المنتجات",
"customer": "0",
"active": true
},
]
},
"status_code": 200
}
Get Discount Statistics
GET /v1/admin/statistics/discount
Returns aggregated statistics for discounts.
Response
{
"success": true,
"message": "تم جلب البيانات بنجاح.",
"data": {
"total_discounts": "20.7K",
"discounts_count": "133/16",
"most_used_discounts": [
{
"id": "5cd34b80-b2f9-11ef-be0b-51cf0a48dcf9",
"name": "كود خصم المؤثرة شهد محمد",
"uses": "50M"
},
{
"id": "b237a820-4fa6-11ee-b893-fb237d93468e",
"name": "sumaya_gift",
"uses": "10M"
},
{
"id": "1461f0e0-99c0-11ef-ab55-918807ddcf30",
"name": "كود خصم الين سليمان شهر نوفمبر",
"uses": "500K"
},
{
"id": "9243f3e0-7f1f-11ef-a532-2ff92193929b",
"name": "خصم ذوي الاحتياجات الخاصة",
"uses": "200K"
}
],
"best_used_products": [
{
"name": "none",
"price": 0
}
]
},
"status_code": 200
}
Get Products List
GET /v1/admin/discounts/products
Returns a list of all products (courses, ebooks, bundles) that can be used with discounts.
Response
{
{
"success": true,
"message": "تم جلب البيانات بنجاح.",
"data": [
{
"id": "4fe39f30-ded2-11ef-9139-db8d8413d447",
"name": "نسخة من (نسخة من (for load test))",
"type": "course",
"price": 99999,
"has_certificate": false,
"has_summary": false,
"product_id": null
},
{
"id": "204d9ae0-7532-11ed-82db-4994ff7b9907",
"name": "أهداف 2023",
"type": "course",
"price": 0,
"has_certificate": false,
"has_summary": false,
"product_id": null
},
{
"id": "b7f77b70-6f16-11ed-a597-b56bc8f8c67e",
"name": "قفزة 2023",
"type": "course",
"price": 90.44,
"has_certificate": false,
"has_summary": false,
"product_id": null
},
{
"id": "1ab0a790-6f1b-11ed-b447-6d37ecfb06a6",
"name": "حماية الذات",
"type": "course",
"price": 190.44,
"has_certificate": false,
"has_summary": false,
"product_id": null
},
{
"id": "16139dc0-b67b-11ec-80bd-69703754a901",
"name": "الرسائل الكونية",
"type": "course",
"price": 390.44,
"has_certificate": false,
"has_summary": false,
"product_id": 208777
},
{
"id": "272bc8b0-dedf-11ef-8311-5f9852bea80c",
"name": "نسخة من (وعي الضحك)",
"type": "course",
"price": 190.44,
"has_certificate": false,
"has_summary": false,
"product_id": 115842
},
{
"id": "0e88e000-b67b-11ec-857f-4779cc02f175",
"name": "شفرة كاليوبـي",
"type": "course",
"price": 390.44,
"has_certificate": false,
"has_summary": false,
"product_id": 203516
},
{
"id": "4b12a910-8dc4-11ee-834e-e9639325d547",
"name": "الكبرياء",
"type": "course",
"price": 260.87,
"has_certificate": false,
"has_summary": false,
"product_id": null
},
{
"id": "6a9a3cd0-6f1c-11ed-b3bb-b7db1a5a5fb4",
"name": "اليأس",
"type": "course",
"price": 290.44,
"has_certificate": false,
"has_summary": false,
"product_id": null
},
{
"id": "19ea7880-b67b-11ec-b223-b3816b83703a",
"name": "عمر الروح",
"type": "course",
"price": 60,
"has_certificate": false,
"has_summary": false,
"product_id": 218747
},
{
"id": "ef987f80-2ea9-11ee-a25d-4feef67b585b",
"name": "الغراب الاسود",
"type": "course",
"price": 230.44,
"has_certificate": false,
"has_summary": false,
"product_id": null
},
{
"id": "0f35b180-b67b-11ec-913b-27291b8dcad2",
"name": "قانون المسؤولية",
"type": "course",
"price": 190.44,
"has_certificate": false,
"has_summary": false,
"product_id": 203521
},
],
"status_code": 200
}
Create Discount
POST /v1/admin/discounts
Creates a new discount.
Request Body
| Parameter | Type | Description | Validation Rules |
|---|---|---|---|
name | string | Discount name | Required, min: 3 |
description | string | Discount description | Required, min: 3 |
method | string | Discount method | Required, values: percentage, value |
amount | number | Discount amount | Required, greater than 0 |
uses | integer | Total number of uses allowed | Required, greater than 0 |
uses_per_customer | integer | Uses allowed per customer | Required, greater than 0 |
code | string | Discount code | Required, min: 3, unique |
active | string | Discount status | Required, values: true, false |
from | string | Start date | Required, format: Y-m-d, before:to |
to | string | End date | Required, format: Y-m-d, after:from |
all_products | string | Apply to all products | Required without product_ids, values: true, false |
all_customers | string | Apply to all customers | Required without other customer filters, values: true, false |
customers_has_student_gar | string | Apply to students with guarantees | Optional, values: true, false |
customers_has_pupils_gar | string | Apply to pupils with guarantees | Optional, values: true, false |
customers_has_special_needs | string | Apply to special needs customers | Optional, values: true, false |
customers_has_social_security_gar | string | Apply to social security customers | Optional, values: true, false |
customers_in_bronze_level | string | Apply to bronze level customers | Optional, values: true, false |
customers_in_silver_level | string | Apply to silver level customers | Optional, values: true, false |
customers_in_golden_level | string | Apply to golden level customers | Optional, values: true, false |
customers_in_diamond_level | string | Apply to diamond level customers | Optional, values: true, false |
country_ids | array | Array of country UUIDs | Optional |
customers_excel_file | file | Excel file with customer emails | Optional, format: xlsx |
customer_ids | array | Array of customer UUIDs | Required if specific customers selected |
product_ids | array | Array of product objects | Required if all_products is false |
product_ids.*.id | string | Product UUID | Required with product_ids |
product_ids.*.type | string | Product type | Required with product_ids, values: ebook, course, bundle |
display_in_cart | string | Show discount in cart | Required, values: true, false |
Response
{
"success": true,
"message": "تم حفظ البيانات بنجاح.",
"data": {
"id": "4bb79850-07ef-11f0-a1f7-ed1e3344ae5b",
"name": "amaaa1",
"description": "amaaa1amaaa1",
"method": "percentage",
"amount": "5",
"uses": "2",
"used": null,
"uses_per_customer": "1",
"code": "amaa11",
"from": "2025-03-25",
"to": "2025-04-27",
"active": true,
"display_in_cart": true,
"all_products": true,
"target_customer": [
"",
"",
"",
"customers_has_pupils_gar",
"",
"",
"",
"",
""
],
"countries": [],
"products": [],
"customers": []
},
"status_code": 200
}
Update Discount
PATCH /v1/admin/discounts/{id}
Updates an existing discount.
Request Body
Same parameters as Create Discount, but all fields are optional.
Response
{
"success": true,
"message": "تم تحديث البيانات بنجاح.",
"data": {
"id": "4bb79850-07ef-11f0-a1f7-ed1e3344ae5b",
"name": "amaaa1",
"description": "amaaa1amaaa1",
"method": "percentage",
"amount": "5.00",
"uses": 2,
"used": 0,
"uses_per_customer": 1,
"code": "amaa11",
"from": "2025-03-25",
"to": "2025-04-27",
"active": true,
"display_in_cart": true,
"all_products": true,
"target_customer": [
"",
"",
"",
"customers_has_pupils_gar",
"",
"",
"",
"",
""
],
"countries": [],
"products": [],
"customers": []
},
"status_code": 200
}
Delete Discounts
DELETE /v1/admin/discounts
Deletes multiple discounts by their IDs.
Request Body
| Parameter | Type | Description | Validation Rules |
|---|---|---|---|
ids | array | Array of discount IDs to delete | Required |
ids.* | string | Discount UUID | Required, UUID format |
Response
{
"success": true,
"message": "تم حذف البيانات بنجاح.",
"data": null,
"status_code": 200
}
Get Customers List
GET /v1/admin/discounts/customers
Returns a list of customers that can be assigned to discounts.
Query Parameters
| Parameter | Type | Description | Validation Rules |
|---|---|---|---|
search_text | string | Search in customer names and emails | Optional |
sort | string | Sort direction | Optional, default: desc |
orderBy | string | Sort field | Optional, default: created_at |
per_page | integer | Number of items per page | Optional, default: 10 |
Response
{
"success": true,
"message": "تم جلب البيانات بنجاح.",
"data": {
"current_page": 1,
"first_page_url": "http://testing-api.sumaya369.net/v1/admin/discounts/customers?search_text=Ahmed&page=1",
"from": 1,
"last_page": 187,
"last_page_url": "http://testing-api.sumaya369.net/v1/admin/discounts/customers?search_text=Ahmed&page=187",
"links": [
{
"url": null,
"label": "« السابق",
"active": false
},
{
"url": "http://testing-api.sumaya369.net/v1/admin/discounts/customers?search_text=Ahmed&page=1",
"label": "1",
"active": true
},
{
"url": "http://testing-api.sumaya369.net/v1/admin/discounts/customers?search_text=Ahmed&page=2",
"label": "2",
"active": false
},
{
"url": "http://testing-api.sumaya369.net/v1/admin/discounts/customers?search_text=Ahmed&page=3",
"label": "3",
"active": false
},
{
"url": null,
"label": "...",
"active": false
},
{
"url": "http://testing-api.sumaya369.net/v1/admin/discounts/customers?search_text=Ahmed&page=186",
"label": "186",
"active": false
},
{
"url": "http://testing-api.sumaya369.net/v1/admin/discounts/customers?search_text=Ahmed&page=187",
"label": "187",
"active": false
},
{
"url": "http://testing-api.sumaya369.net/v1/admin/discounts/customers?search_text=Ahmed&page=2",
"label": "التالي »",
"active": false
}
],
"next_page_url": "http://testing-api.sumaya369.net/v1/admin/discounts/customers?search_text=Ahmed&page=2",
"path": "http://testing-api.sumaya369.net/v1/admin/discounts/customers",
"per_page": 10,
"prev_page_url": null,
"to": 10,
"total": 1864,
"customers": [
{
"id": "d84c3ff0-f3b0-11ef-ab50-1fd283e04550",
"name": "Ahmed Mohammad",
"email": "tesvting@gmail.com"
},
{
"id": "0a79add0-f3ae-11ef-bee7-8bfdde00797d",
"name": "Ahmed Mohammad",
"email": "testing@gmail.com"
},
{
"id": "33e96f80-dd6b-11ef-8b82-c3297a6cb0cb",
"name": "AHmed Mohammmd",
"email": "aalbaiti3601@gmail.com"
},
{
"id": "9d824df0-ce5e-11ef-a252-c56db276a1d4",
"name": "Ahmed11",
"email": "aalbaiti36033@gmail.com"
},
{
"id": "adaab340-cd9a-11ef-b5dc-891169bda0e0",
"name": "Ahmed Mohammed",
"email": "wz@dd.com"
},
{
"id": "233082a0-aaf3-11ef-a330-bb73a43d47be",
"name": "Ahmed Mohammed",
"email": "wz@yahoo.com"
},
{
"id": "8d321df0-8ef2-11ef-ac52-cb5831469809",
"name": "احمد مازن",
"email": "ahmedmaz@good.com"
},
]
},
"status_code": 200
}
Notes
-
Discounts can target specific customer segments through multiple filters:
- Student guarantee holders
- Pupil guarantee holders
- Social security guarantee holders
- Special needs customers
- Loyalty level members (Bronze, Silver, Gold, Diamond)
- Specific countries
- Individual customers via email list
-
Product targeting options:
- All products (courses, ebooks, bundles)
- Specific products by type and ID
- Products can be mixed across different types
-
Usage tracking:
- Tracks total uses across all customers
- Tracks uses per individual customer
- Provides statistics on most used discounts