Discount Codes (Kortingscodes) ============================== Current version: 1.0.0 Create ------ .. http:post:: /api2/kortingscodes Create a new discount code **Example request**: .. sourcecode:: http POST /api2/kortingscodes HTTP/1.1 Host: demo.recras.nl Accept: application/json { "naam": "Summer Sale", "code": "SUMMER2026", "datum_begin": "2026-06-01", "datum_eind": "2026-08-31", "kortingspercentage": 15, "toepasbaar_zonder_arrangement": false, "valid_days": {"1": true, "2": true, "3": true, "4": true, "5": true, "6": true, "7": true}, "Arrangementen": [1, 2], "BookProcesses": [3], "Products": [] } **Example response**: .. sourcecode:: http HTTP/1.1 201 Created Content-Type: application/json Location: /api2/kortingscodes/5 { "id": 5, "naam": "Summer Sale", "code": "SUMMER2026", "datum_begin": "2026-06-01", "datum_eind": "2026-08-31", "kortingspercentage": 15, "toepasbaar_zonder_arrangement": false, "valid_days": {"1": true, "2": true, "3": true, "4": true, "5": true, "6": true, "7": true}, "Arrangementen": [1, 2], "BookProcesses": [3], "Products": [], "created_at": "2026-06-01 10:00:00", "updated_at": "2026-06-01 10:00:00" } :json string naam: **Required** Name of the discount code (`naam` means name) :json string code: **Required** Unique discount code. Must be unique across both discount codes and vouchers. :json string datum_begin: **Required** Start date in ISO 8601 format (YYYY-MM-DD) (`datum_begin` means start_date) :json string datum_eind: **Required** End date in ISO 8601 format (YYYY-MM-DD), must be on or after ``datum_begin`` (`datum_eind` means end_date) :json int kortingspercentage: **Required** Discount percentage, 0-100 (`kortingspercentage` means discount_percentage) :json boolean toepasbaar_zonder_arrangement: **Deprecated** — will be removed in a future version. Whether the discount code can be applied without a package (`toepasbaar_zonder_arrangement` means applicable_without_package) :json object valid_days: Weekdays when the discount is valid. Object with day numbers 1 (Monday) through 7 (Sunday) as keys, mapping to booleans. :json array Arrangementen: List of package IDs this discount code applies to. Use ``[]`` to clear. :json array BookProcesses: List of book process IDs this discount code applies to. Use ``[]`` to clear. :json array Products: List of product IDs this discount code applies to. Use ``[]`` to clear. :resheader Location: The location of the new discount code :statuscode 201: Discount code created :statuscode 406: Error in the input :statuscode 409: A discount code or voucher with this ``code`` already exists :statuscode 403: User does not have the ``beheerKortingscodes`` (manageDiscountCodes) permission Read ---- .. http:get:: /api2/kortingscodes List all discount codes **Example request**: .. sourcecode:: http GET /api2/kortingscodes HTTP/1.1 Host: demo.recras.nl Accept: application/json **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Content-Type: application/json [ { "id": 5, "naam": "Summer Sale", "code": "SUMMER2026", "datum_begin": "2026-06-01", "datum_eind": "2026-08-31", "kortingspercentage": 15, "toepasbaar_zonder_arrangement": false, "valid_days": {"1": true, "2": true, "3": true, "4": true, "5": true, "6": true, "7": true}, "Arrangementen": [1, 2], "BookProcesses": [3], "Products": [], "created_at": "2026-06-01 10:00:00", "updated_at": "2026-06-01 10:00:00" } ] :reqheader Authorization: mandatory Basic authentication :statuscode 200: no error .. http:get:: /api2/kortingscodes/(int:id) A specific discount code **Example request**: .. sourcecode:: http GET /api2/kortingscodes/5 HTTP/1.1 Host: demo.recras.nl Accept: application/json **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Content-Type: application/json { "id": 5, "naam": "Summer Sale", "code": "SUMMER2026", "datum_begin": "2026-06-01", "datum_eind": "2026-08-31", "kortingspercentage": 15, "toepasbaar_zonder_arrangement": false, "valid_days": {"1": true, "2": true, "3": true, "4": true, "5": true, "6": true, "7": true}, "Arrangementen": [1, 2], "BookProcesses": [3], "Products": [], "created_at": "2026-06-01 10:00:00", "updated_at": "2026-06-01 10:00:00" } :reqheader Authorization: mandatory Basic authentication :statuscode 200: OK :statuscode 404: No discount code with this ``id`` Update ------ .. http:put:: /api2/kortingscodes/(int:id) **Example request**: .. sourcecode:: http PUT /api2/kortingscodes/5 HTTP/1.1 Host: demo.recras.nl Accept: application/json { "id": 5, "naam": "Summer Sale Extended", "code": "SUMMER2026", "datum_begin": "2026-06-01", "datum_eind": "2026-09-30", "kortingspercentage": 20, "toepasbaar_zonder_arrangement": false, "valid_days": {"1": true, "2": true, "3": true, "4": true, "5": true, "6": false, "7": false}, "Arrangementen": [1, 2, 3], "BookProcesses": [], "Products": [] } **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Content-Type: application/json { "id": 5, "naam": "Summer Sale Extended", "code": "SUMMER2026", "datum_begin": "2026-06-01", "datum_eind": "2026-09-30", "kortingspercentage": 20, "toepasbaar_zonder_arrangement": false, "valid_days": {"1": true, "2": true, "3": true, "4": true, "5": true, "6": false, "7": false}, "Arrangementen": [1, 2, 3], "BookProcesses": [], "Products": [], "created_at": "2026-06-01 10:00:00", "updated_at": "2026-06-15 14:30:00" } :json int id: ID number, may not be changed :json string naam: **Required** Name of the discount code (`naam` means name) :json string code: **Required** Unique discount code. Must be unique across both discount codes and vouchers. :json string datum_begin: **Required** Start date in ISO 8601 format (YYYY-MM-DD) (`datum_begin` means start_date) :json string datum_eind: **Required** End date in ISO 8601 format (YYYY-MM-DD), must be on or after ``datum_begin`` (`datum_eind` means end_date) :json int kortingspercentage: **Required** Discount percentage, 0-100 (`kortingspercentage` means discount_percentage) :json boolean toepasbaar_zonder_arrangement: **Deprecated** — will be removed in a future version. Whether the discount code can be applied without a package (`toepasbaar_zonder_arrangement` means applicable_without_package) :json object valid_days: Weekdays when the discount is valid. Object with day numbers 1 (Monday) through 7 (Sunday) as keys, mapping to booleans. :json array Arrangementen: List of package IDs this discount code applies to. Use ``[]`` to clear. :json array BookProcesses: List of book process IDs this discount code applies to. Use ``[]`` to clear. :json array Products: List of product IDs this discount code applies to. Use ``[]`` to clear. :statuscode 200: Discount code updated :statuscode 406: Error in the input :statuscode 409: A discount code or voucher with this ``code`` already exists :statuscode 403: User does not have the ``beheerKortingscodes`` (manageDiscountCodes) permission Delete ------ .. http:delete:: /api2/kortingscodes/(int:id) **Example request**: .. sourcecode:: http DELETE /api2/kortingscodes/5 HTTP/1.1 Host: demo.recras.nl **Example response**: .. sourcecode:: http HTTP/1.1 200 OK :statuscode 200: Discount code deleted :statuscode 403: User does not have the ``beheerKortingscodes`` (manageDiscountCodes) permission