POST

AppointmentCoupon.Add

Create one appointment coupon for a customer. Same fields as the dashboard Add/Edit Coupon modal (Advance → Appointment Coupon Report → ADD COUPONS). Returns coupon_id and structured data.

Permissions

  • User must be logged in with a valid bearer token.
  • Returned or changed records are limited by the user permissions, team access, folder access, and account settings.

Action

  • Creates a AppointmentCoupon record or sends the requested data after validation.

Push Service

No push is sent because this function only reads data or returns helper information.

Automation

No automation is run for this function.

Special Instructions

  • Staff/org token required. Customer portal alias (cust_id from JWT): Customer.Appointments.Coupon.Add.

Required Parameters

NameTypeSampleExplanation
customer_id
post
int108545Customer id. Aliases: cust_id, coupon_cust.
coupon_code
post
string12345Unique coupon code for this organization.
appointment_type_id
post
int697doctor_appointments_type id. Alias: coupon_appo_type_id.

Optional Parameters

NameTypeSampleWhat it gives
insurance
post
int2appointment_insurance_company id. Alias: coupon_insurance_company.
amount
post
number100Coupon amount. Alias: coupon_amount.
left_amount
post
number50Left amount. Alias: coupon_left_amount.
notes
post
stringthis coupon offer youNotes. Alias: coupon_note.
coupon_date
post
date2026-02-17Coupon date Y-m-d. Defaults to today. Send date filters and date values as UTC Y-m-d H:i:s when the route accepts date/time; date-only table columns store the Y-m-d date part.
order_id
post
int0Optional coupon order id.

Authentication

Send the bearer token returned by Login in the request header.

Authorization: Bearer YOUR TOKEN

Sample Request

{
    "url": "\/app\/AppointmentCoupon.Add",
    "method": "POST",
    "headers": {
        "Authorization": "Bearer YOUR TOKEN"
    },
    "body": {
        "customer_id": "108545",
        "coupon_code": "12345",
        "appointment_type_id": "697",
        "insurance": "2",
        "amount": "100",
        "left_amount": "50",
        "notes": "this coupon offer you",
        "coupon_date": "2026-02-17"
    },
    "url_user": "https:\/\/{user}.bull36.com\/app\/AppointmentCoupon.Add",
    "url_domain": "https:\/\/{domain}\/app\/AppointmentCoupon.Add"
}

Endpoint

POST /app/AppointmentCoupon.Add
POST https://{user}.bull36.com/app/AppointmentCoupon.Add
POST https://{domain}/app/AppointmentCoupon.Add

Sample Output

{
    "success": 1,
    "message": "Customer Coupon added",
    "coupon_id": 388,
    "data": {
        "id": 388,
        "coupon_code": "12345",
        "customer_id": 108545,
        "status_label": "unused"
    }
}

JavaScript Example

const token = 'YOUR TOKEN';
const body = new URLSearchParams({ customer_id: '108545', coupon_code: '12345', appointment_type_id: '697', amount: '100', left_amount: '50' });
const res = await fetch('/app/AppointmentCoupon.Add', { method: 'POST', headers: { Authorization: 'Bearer ' + token }, body });
console.log(await res.json());

Error Example

{
    "success": 2,
    "error": "coupon_code_exists",
    "message": "This coupons already exists : 12345"
}