Cria ou executa coupons
POST/api/coupons
- Auth
- Exige token
- X-CommunityId
X-CommunityIdEnvie o X-CommunityId da comunidade em que a operação acontece.
Headers
| Nome | Tipo | Descrição |
|---|---|---|
X-CommunityIdopcional | string (uuid) | ID da comunidade em que a operação acontece. Obrigatório na maioria dos endpoints com escopo de comunidade. |
Corpo da requisição application/json
| Nome | Tipo | Descrição |
|---|---|---|
codeobrigatório | string | Coupon code is required |
nameobrigatório | string | Name is required |
descriptionopcional | string | |
typeobrigatório | PERCENTAGE | FIXED | FREE_TRIAL | Invalid coupon type |
discountValueobrigatório | number | Discount value must be positive |
maxDiscountopcional | number | |
trialExtensionDaysopcional | integer | |
durationobrigatório | ONCE | FOREVER | REPEATING | Invalid duration |
durationInMonthsopcional | integer | |
maxUsesopcional | integer | |
maxUsesPerUseropcional | integer | |
startDateobrigatório | string (date-time) | Valid start date required |
endDateopcional | string (date-time) | |
restrictionopcional | NONE | FIRST_PURCHASE | NEW_CUSTOMER | |
minPurchaseAmountopcional | number | |
applicableProductsopcional | —[] | |
excludedProductsopcional | —[] | |
applicableToOneTimeopcional | boolean | |
applicableToSubscriptionopcional | boolean | |
applicableToInstallmentopcional | boolean | |
isStackableopcional | boolean |
Respostas
| Código | Descrição |
|---|---|
201 | Operação realizada com sucesso. |
400 | Requisição inválida — falha de validação. |
401 | Token ausente, inválido ou expirado. |
403 | Autenticado, mas sem permissão para esta operação. |
404 | Recurso não encontrado. |
500 | Erro interno do servidor. |
Exemplo com curl
curl -X POST "https://api.memberfy.net/api/coupons" \
-H "Authorization: Bearer $TOKEN" \
-H "X-CommunityId: $COMMUNITY_ID" \
-H "Content-Type: application/json" \
-d '{"code":"string","name":"string","type":"PERCENTAGE","discountValue":10,"duration":"ONCE","startDate":"2026-01-01T12:00:00.000Z"}'