tokens
Online learning is not just a platform; it's the bridge between curiosity and understanding.
To get access to API, you need to generate a token for your schools.
Then, you can use it like this :
fetch(`https://codeline.app/api/v1/products`, {
method: 'GET',
headers: {
Authorization: `Bearer ${environment.codelineApiToken}`,
},
});
The following endpoint are available :
/api/v1/products/:productId/coupons
POST
Create a coupon for a product.
fetch(`https://codeline.app/api/v1/products/:productId/coupons`, {
method: 'POST',
headers: {
Authorization: `Bearer ${environment.codelineApiToken}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
discountAmount: promo.amount, // 10000 = 100.00
maxUsage: 1, // The maximum number of times the coupon can be used
archivedAt: new Date() + 1000 * 60 * 60 * 24 * 30, // The date at which the coupon will be archived
}),
});
You can't choose the coupon code, you will receive it in the response.
If the coupon is created, you will receive a response that match this schema :
export const ResponseSchema = z.object({
coupon: z.object({
id: z.string(),
code: z.string(),
archivedAt: z.string().nullable(),
}),
});
/api/v1/products/:productId/users
TODO