Skip to main content

Create Lab Coupon (v1)

Method & Path

POST /api/v1/workspace/:workspaceId/labs/coupons

Actual backend path: /v1/workspace/:workspaceId/labs/coupons

Description

Create a new lab coupon in the workspace.

Authentication

Required: JWT token in Authorization header

Required Permissions:

  • labs.manage

Headers

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token: Bearer <token>
Content-TypestringYesapplication/json

Path Parameters

ParameterTypeRequiredDescription
workspaceIdstringYesWorkspace identifier (MongoDB ObjectId)

Request Body

{
"couponTitle": "Summer Sale 2025",
"couponCode": "SUMMER25",
"couponType": "percentage",
"couponValue": 15,
"couponStatus": "active"
}
FieldTypeRequiredDescription
couponTitlestringYesCoupon title (1-500 characters)
couponCodestringYesUnique coupon code (1-100 characters)
couponTypestringYesCoupon type: "percentage" or "currency"
couponValuenumberYesDiscount value (must be >= 0). For percentage: 0-100, for currency: amount in workspace currency
couponStatusstringNoCoupon status: "active" or "inactive" (default: "active")

Response 201 Created

{
"labCoupon": {
"id": "507f1f77bcf86cd799439011",
"workspaceId": "507f1f77bcf86cd799439012",
"couponTitle": "Summer Sale 2025",
"couponCode": "SUMMER25",
"couponType": "percentage",
"couponValue": 15,
"couponStatus": "active",
"createdAt": "2025-01-15T10:00:00.000Z",
"updatedAt": "2025-01-15T10:00:00.000Z",
"deletedAt": null
}
}

Common Errors

400 Bad Request: Invalid request body or missing required fields

401 Unauthorized: Missing or invalid authentication token

403 Forbidden: Insufficient permissions (labs.manage required)

404 Not Found: Workspace not found

409 Conflict: Lab coupon with the same code already exists

422 Validation Error: Invalid workspace ID format or validation errors