Cria ou executa coupons
POST/api/coupons
- Auth
- Jeton requis
- Clé d’API:
- store:write
- X-CommunityId
X-CommunityIdEnvoyez le X-CommunityId de la communauté où l’opération a lieu.
Les descriptions des endpoints viennent directement de la spécification de l’API et sont en portugais pour l’instant. L’interface autour est traduite.
En-têtes
| Nom | Type | Description |
|---|---|---|
X-CommunityIdfacultatif | string (uuid) | ID da comunidade em que a operação acontece. Obrigatório na maioria dos endpoints com escopo de comunidade. |
Corps de la requête application/json
| Nom | Type | Description |
|---|---|---|
codeobligatoire | string | Coupon code is required |
nameobligatoire | string | Name is required |
descriptionfacultatif | string | |
typeobligatoire | PERCENTAGE | FIXED | FREE_TRIAL | Invalid coupon type |
discountValueobligatoire | number | Discount value must be positive |
maxDiscountfacultatif | number | |
trialExtensionDaysfacultatif | integer | |
durationobligatoire | ONCE | FOREVER | REPEATING | Invalid duration |
durationInMonthsfacultatif | integer | |
maxUsesfacultatif | integer | |
maxUsesPerUserfacultatif | integer | |
startDateobligatoire | string (date-time) | Valid start date required |
endDatefacultatif | string (date-time) | |
restrictionfacultatif | NONE | FIRST_PURCHASE | NEW_CUSTOMER | |
minPurchaseAmountfacultatif | number | |
applicableProductsfacultatif | —[] | |
excludedProductsfacultatif | —[] | |
applicableToOneTimefacultatif | boolean | |
applicableToSubscriptionfacultatif | boolean | |
applicableToInstallmentfacultatif | boolean | |
isStackablefacultatif | boolean |
Réponses
| Statut | Description |
|---|---|
201 | Operação realizada com sucesso. |
400 | Requisição inválida — falha de validação. |
401 | Token ausente, inválido ou expirado; token de outra comunidade (o `X-CommunityId` ou o `communityId` do corpo não é o do token); token antigo ou de uma sessão encerrada (troca de senha, convite aceito). Nesses casos a mensagem pede para entrar de novo (`auth.signInAgain`). |
403 | Autenticado, mas sem permissão para esta operação. |
404 | Recurso não encontrado. |
500 | Erro interno do servidor. |
Exemple 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"}'