Creating Coupons
POST /api/v1/courses/:course_id/products/:product_id/coupons/
Parameters
| Name |
Description |
|
id
|
coupon id
|
|
is_primary
|
primary coupon?
|
|
code
|
:text
|
|
currency
|
:string(255)
|
|
discount_amount
|
:integer
|
|
discount_in_months
|
:integer
|
|
discount_percent
|
:float
|
|
duration_kind
|
forever, once, or repeating
|
|
expiration_date
|
:date
|
|
is_published
|
:boolean
|
|
name
|
:text
|
|
number_available
|
:integer
|
|
number_of_uses
|
:integer
|
|
product_id
|
id
|
|
course_id
|
course id
|
Request
Headers
Route
POST /api/v1/courses/36/products/32/coupons/
Body
{"id":39,"code":"FOO","discount_percent":0.2,"duration_kind":"forever","expiration_date":"2019-11-30"}
cURL
curl "http://localhost:3000/api/v1/courses/36/products/32/coupons/" -d '{"id":39,"code":"FOO","discount_percent":0.2,"duration_kind":"forever","expiration_date":"2019-11-30"}' -X POST \
-H "Accept: application/json" \
-H "X-Api-Token: vRcPLGqTuU2nxGQQf3Gt7sfVZj8LK4VeNw" \
-H "X-Api-Email: user-105@example.com" \
-H "Content-Type: application/json" \
-H "Host: school.worksonmy.computer"
Response
Headers
Status
201 Created
Body
{
"created_at": "2019-10-31T21:59:11Z",
"new_purchase_price": 1000,
"formatted_discount": "$2",
"formatted_price": "$8",
"calculated_discount": 200,
"currency": "USD",
"discount_percent": 0.2,
"discount_amount": null,
"number_available": null,
"code": "FOO",
"name": null,
"expiration_date": "2019-11-29T19:00:00-05:00",
"product_id": 32,
"is_published": true,
"duration_kind": "forever",
"number_of_uses": null,
"class_period_id": null,
"site_wide": null,
"id": 40,
"meta": {
"class": "coupon",
"url": null,
"name": null,
"description": "",
"image_url": null
},
"product": {
"created_at": "2019-10-31T21:59:11Z",
"formatted_price": "$10",
"name": "product name",
"description": "product description",
"billing_interval": "month",
"detailed_description": null,
"currency": "USD",
"position": 1,
"price": 1000,
"is_recurring": false,
"is_published": true,
"course_id": 36,
"author_revenue_share": null,
"num_payments_required": null,
"id": 32,
"meta": {
"class": "product",
"url": "/courses/36/products/32",
"name": "product name",
"description": "product description",
"image_url": null
}
}
}