Skip to content

Vendor Coupon Management API

This API allows vendor to manage coupon.


Endpoints Overview

Method Endpoint Description
GET /api/v1/checkout/vendor/coupons/ List all coupons belonging to the logged-in vendor.
POST /api/v1/checkout/vendor/coupons/ Create a new coupon for the vendor's shop.
GET /api/v1/checkout/vendor/coupons/<int:id>/ Retrieve details of a specific coupon.
PUT /api/v1/checkout/vendor/coupons/<int:id>/ Update details of a specific coupon.
DELETE /api/v1/checkout/vendor/coupons/<int:id>/ Delete a coupon belonging to the vendor.

Vendor Coupon API

1. List All Coupons

Endpoint

  • URL: /api/v1/checkout/vendor/coupons/
  • Method: GET
  • Permission Required: IsAuthenticated (Vendor Only)

Description

Retrieves a list of all coupons belonging to the authenticated vendor.

Example Request

This is the example request

GET /api/v1/checkout/vendor/coupons/


Success

{
    "pageSize": 20,
    "count": 2,
    "page_count": 1,
    "active_page": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 66,
            "code": "WINE0",
            "description": "Discount on winter clothing",
            "discount_percent": "20.00",
            "money_value_off": "0.00",
            "total_issues": 50,
            "coupon_limit_per_customer": 2,
            "used_count": 0,
            "start_at": "02-01-2025 00:00:00",
            "end_at": "02-28-2025 23:59:59",
            "min_purchase": "100.00",
            "is_active": true,
            "coupon_type": "Percentage Discount"
        },
        {
            "id": 65,
            "code": "WINE200",
            "description": "Discount on winter clothing",
            "discount_percent": "20.00",
            "money_value_off": "0.00",
            "total_issues": 50,
            "coupon_limit_per_customer": 2,
            "used_count": 0,
            "start_at": "02-01-2025 00:00:00",
            "end_at": "02-28-2025 23:59:59",
            "min_purchase": "100.00",
            "is_active": true,
            "coupon_type": "Percentage Discount"
        }
    ]
}


2. Create Coupons

Endpoint

  • URL: /api/v1/checkout/vendor/coupons/
  • Method: POST
  • Permission Required: IsAuthenticated (Vendor Only)

Description

Allows vendors to create a new coupon for their shop.

Example Request

This is the example request

POST /api/v1/checkout/vendor/coupons/


Request Body

This is the request body

{
  "code": "SALE220",
  "description": "Discount on winter clothing",
  "discount_percent": 20.00,
  "total_issues": 50,
  "coupon_limit_per_customer": 2,
  "start_at": "2025-02-01T00:00:00Z",
  "end_at": "2025-02-28T23:59:59Z",
  "min_purchase": 100.00,
  "is_active": true
}


Success

{
    "id": 70,
    "code": "SALE220",
    "description": "Discount on winter clothing",
    "discount_percent": "20.00",
    "money_value_off": "0.00",
    "total_issues": 50,
    "coupon_limit_per_customer": 2,
    "used_count": 0,
    "start_at": "02-01-2025 00:00:00",
    "end_at": "02-28-2025 23:59:59",
    "min_purchase": "100.00",
    "is_active": true,
    "coupon_type": "Percentage Discount"
}


Error

{
  "error": "Coupon code already exists."
}


3. Retrieve a Specific Coupon

Endpoint

  • URL: /api/v1/checkout/vendor/coupons/<int:id>/
  • Method: GET
  • Permission Required: IsAuthenticated (Vendor Only)

Description

Fetches details of a specific coupon.

Example Request

This is the example request

GET /api/v1/checkout/vendor/coupons/2/


Success

{
    "id": 70,
    "code": "SALE220",
    "description": "Discount on winter clothing",
    "discount_percent": "20.00",
    "money_value_off": "0.00",
    "total_issues": 50,
    "coupon_limit_per_customer": 2,
    "used_count": 0,
    "start_at": "02-01-2025 00:00:00",
    "end_at": "02-28-2025 23:59:59",
    "min_purchase": "100.00",
    "is_active": true,
    "coupon_type": "Percentage Discount"
}


Error

{
  "error": "Coupon not found."
}


4. Update a Coupon

Endpoint

  • URL: /api/v1/checkout/vendor/coupons/<int:id>/
  • Method: PUT
  • Permission Required: IsAuthenticated (Vendor Only)

Description

Allows vendors to update an existing coupon.

Example Request

This is the example request

PUT /api/v1/checkout/vendor/coupons/2/


Request Body

This is the request body

{
  "code": "SALE220",
  "description": "Discount on winter clothing",
  "discount_percent": 20.00,
  "total_issues": 50,
  "coupon_limit_per_customer": 2,
  "start_at": "2025-02-01T00:00:00Z",
  "end_at": "2025-02-28T23:59:59Z",
  "min_purchase": 100.00,
  "is_active": true
}


Success

{
    "id": 70,
    "code": "SALE220",
    "description": "Discount on winter clothing",
    "discount_percent": "20.00",
    "money_value_off": "0.00",
    "total_issues": 50,
    "coupon_limit_per_customer": 2,
    "used_count": 0,
    "start_at": "02-01-2025 00:00:00",
    "end_at": "02-28-2025 23:59:59",
    "min_purchase": "100.00",
    "is_active": true,
    "coupon_type": "Percentage Discount"
}


Error

{
  "error": "Coupon not found or you don't have permission to edit this coupon."
}


5. Delete a Coupon

Endpoint

  • URL: /api/v1/checkout/vendor/coupons/<int:id>/
  • Method: DELETE
  • Permission Required: IsAuthenticated (Vendor Only)

Description

Deletes a coupon belonging to the vendor.

Example Request

This is the example request

DELETE /api/v1/checkout/vendor/coupons/2/


Success

{
  "message": "Coupon deleted successfully."
}


Error

{
  "error": "Coupon not found or you don't have permission to delete this coupon."
}