İndirimler API
İndirimler modülünün tüm işlemleri (12) ve veri modelleri (10): adresler, izinler, girdiler, ön koşullar, olaylar ve örnekler.
Kampanyalar ve indirim kodları — indirimli satışlar, sipariş fırsatları ve hediyeler.
Modül kodu discounts · 12 işlem · 10 veri modeli · 13 olay. Bir anahtar ya da token, arkasındaki kişinin bu modülde yapabildiğinden fazlasını asla yapamaz; satır düzeyindeki güvenlik uygulamadakiyle birebir aynıdır. Yetki kapsamları: discounts (hepsi), discounts:read (yalnız okuma) ya da discounts:<yetenek>.
Kaynaklar
| Kaynak | Tablo | Listeleme ve okuma | POST | PATCH | DELETE |
|---|---|---|---|---|---|
promotion_rule_channels | promotion_rule_channel | /api/v1/promotion_rule_channels | |||
promotion_rule_gifts | promotion_rule_gift | /api/v1/promotion_rule_gifts | |||
promotion_rule_targets | promotion_rule_target | /api/v1/promotion_rule_targets | |||
promotion_rules | promotion_rule | /api/v1/promotion_rules | discounts.save_promotion_rule | discounts.delete_promotion_rule | |
promotions | promotion | /api/v1/promotions | discounts.save_promotion | discounts.delete_promotion | |
voucher_catalogues | voucher_catalogue | /api/v1/voucher_catalogues | |||
voucher_channel_listings | voucher_channel_listing | /api/v1/voucher_channel_listings | |||
voucher_codes | voucher_code | /api/v1/voucher_codes | |||
voucher_customers | voucher_customer | /api/v1/voucher_customers | |||
vouchers | voucher | /api/v1/vouchers | discounts.save_voucher | discounts.delete_voucher |
Listeler limit (en çok 200), cursor, order (ör. -created_at), fields ve q alır; diğer her sorgu parametresi bir sütun süzgecidir: ?status=paid, ?total[gte]=100, ?id[in]=a,b, ?x=null.
İşlemler
| İşlem | Gereken izin | Ne yapar |
|---|---|---|
discounts.add_voucher_codes | discounts:write | Kupon kodu ekle |
discounts.announce_promotion | discounts:write | Kampanyanın başladığını veya bittiğini duyur |
discounts.delete_promotion | discounts:delete | Kampanyayı sil |
discounts.delete_promotion_rule | discounts:write | Kampanya kuralını sil |
discounts.delete_voucher | discounts:delete | Kuponu sil |
discounts.delete_voucher_codes | discounts:delete | Kupon kodlarını kaldır |
discounts.import_voucher_codes | discounts:write | Kupon kodlarını içe aktar |
discounts.save_promotion | discounts:write | Kampanyayı kaydet |
discounts.save_promotion_rule | discounts:write | Kampanya kuralını kaydet |
discounts.save_voucher | discounts:write | Kuponu kaydet |
discounts.set_voucher_catalogue | discounts:write | Kuponu kataloğun bir kısmıyla sınırla |
discounts.set_voucher_channels | discounts:write | Kuponun kanal değerini belirle |
discounts.add_voucher_codes
Kupon kodu ekle — Kodları yazın ya da isteğe bağlı bir önekle elliye kadar üretin.
Gereken izin discounts:write · veriyi değiştirir
https://app.getera.io/api/v1/voucher_codes/actions/add_voucher_codes- Asıl adres:
POST /api/v1/actions/discounts.add_voucher_codes
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
voucherId | uuid | evet | Kupon · kimliği: voucher |
codes | object / array | Kodlar | |
quantity | number | Oluşturulacak adet · en az 0 · en çok 50 | |
prefix | string | Önek · en çok 40 |
Ön koşullar
Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:
| Kod | Ne zaman reddedilir |
|---|---|
not_found | Kupon bulunmalı. |
no_codes | En az bir kod yazılmalı veya üretilmeli. |
too_many_codes | Tek seferde en fazla elli. |
duplicate_codes | Bir kod bir kez verilebilir. |
code_taken | Kod, büyük-küçük harf gözetmeksizin, bu çalışma alanında boşta olmalı. |
Yayımladığı olaylar: discounts.voucher_codes_added
Neye yazar: voucher_code (insert) — Writes the codes
curl -X POST https://app.getera.io/api/v1/voucher_codes/actions/add_voucher_codes \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"voucherId":"VOUCHER_ID"}'{
"ok": true,
"result": "…",
"events": [
"discounts.voucher_codes_added"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.voucherCodes.addVoucherCodes({
voucherId: "VOUCHER_ID"
})era voucher_codes add_voucher_codes \
--voucher-id "VOUCHER_ID"{
"name": "era__discounts__add_voucher_codes",
"arguments": {
"voucherId": "VOUCHER_ID"
}
}Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde discounts:write izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 409 not_found, no_codes, too_many_codes, duplicate_codes, code_taken · 429 çok sık istek
discounts.announce_promotion
Kampanyanın başladığını veya bittiğini duyur — Otomatik: mağaza taraması başlangıcı veya bitişi bir kez duyurur.
Gereken izin discounts:write · dışarıya ulaşır (gönderir, yayımlar ya da ücret alır)
https://app.getera.io/api/v1/promotions/{id}/actions/announce_promotion- Asıl adres:
POST /api/v1/actions/discounts.announce_promotion
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
id | uuid | evet | Doldurulduğu yer: adresteki {id} · Promosyon · kimliği: promotion |
Ön koşullar
Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:
| Kod | Ne zaman reddedilir |
|---|---|
not_found | Kampanya bulunmalı. |
nothing_to_announce | Son duyurudan bu yana bir başlangıç veya bitiş geçmiş olmalı. |
Yayımladığı olaylar: discounts.promotion_started, discounts.promotion_ended
Neye yazar: promotion (update) — Stamps when it was announced
curl -X POST https://app.getera.io/api/v1/promotions/PROMOTION_ID/actions/announce_promotion \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{}'{
"ok": true,
"result": "…",
"events": [
"discounts.promotion_started",
"discounts.promotion_ended"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.promotions.announcePromotion("PROMOTION_ID")era promotions announce_promotion PROMOTION_ID{
"name": "era__discounts__announce_promotion",
"arguments": {
"id": "PROMOTION_ID"
}
}Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde discounts:write izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 409 not_found, nothing_to_announce · 429 çok sık istek
discounts.delete_promotion
Kampanyayı sil — Kuralları da gider. Satılmış siparişler ödenen tutarı korur.
Gereken izin discounts:delete · siler ya da geri alınamaz · Era çalıştırırken bir kişiye onaylatır
https://app.getera.io/api/v1/promotions/{id}/actions/delete_promotion- REST kısayolu:
DELETE /api/v1/promotions/{id} - Asıl adres:
POST /api/v1/actions/discounts.delete_promotion
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
id | uuid | evet | Doldurulduğu yer: adresteki {id} · Promosyon · kimliği: promotion |
Ön koşullar
Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:
| Kod | Ne zaman reddedilir |
|---|---|
not_found | Kampanya bulunmalı. |
Yayımladığı olaylar: discounts.promotion_deleted
Neye yazar: promotion (delete) — Removes the promotion and its rules
curl -X POST https://app.getera.io/api/v1/promotions/PROMOTION_ID/actions/delete_promotion \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{}'{
"ok": true,
"result": "…",
"events": [
"discounts.promotion_deleted"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.promotions.deletePromotion("PROMOTION_ID")era promotions delete_promotion PROMOTION_ID{
"name": "era__discounts__delete_promotion",
"arguments": {
"id": "PROMOTION_ID"
}
}Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde discounts:delete izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 409 not_found · 429 çok sık istek
discounts.delete_promotion_rule
Kampanya kuralını sil — Değiştirdiği fiyatlar normale döner.
Gereken izin discounts:write · siler ya da geri alınamaz · Era çalıştırırken bir kişiye onaylatır
https://app.getera.io/api/v1/promotion_rules/{id}/actions/delete_promotion_rule- REST kısayolu:
DELETE /api/v1/promotion_rules/{id} - Asıl adres:
POST /api/v1/actions/discounts.delete_promotion_rule
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
id | uuid | evet | Doldurulduğu yer: adresteki {id} · Kural · kimliği: promotion_rule |
Ön koşullar
Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:
| Kod | Ne zaman reddedilir |
|---|---|
not_found | Kural bulunmalı. |
Yayımladığı olaylar: discounts.rule_deleted
Neye yazar: promotion_rule (delete) — Removes the rule
curl -X POST https://app.getera.io/api/v1/promotion_rules/PROMOTION_RULE_ID/actions/delete_promotion_rule \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{}'{
"ok": true,
"result": "…",
"events": [
"discounts.rule_deleted"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.promotionRules.deletePromotionRule("PROMOTION_RULE_ID")era promotion_rules delete_promotion_rule PROMOTION_RULE_ID{
"name": "era__discounts__delete_promotion_rule",
"arguments": {
"id": "PROMOTION_RULE_ID"
}
}Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde discounts:write izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 409 not_found · 429 çok sık istek
discounts.delete_voucher
Kuponu sil — Kodları çalışmaz olur. Siparişler satıldıkları kod metnini korur.
Gereken izin discounts:delete · siler ya da geri alınamaz · Era çalıştırırken bir kişiye onaylatır
https://app.getera.io/api/v1/vouchers/{id}/actions/delete_voucher- REST kısayolu:
DELETE /api/v1/vouchers/{id} - Asıl adres:
POST /api/v1/actions/discounts.delete_voucher
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
id | uuid | evet | Doldurulduğu yer: adresteki {id} · Kupon · kimliği: voucher |
Ön koşullar
Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:
| Kod | Ne zaman reddedilir |
|---|---|
not_found | Kupon bulunmalı. |
Yayımladığı olaylar: discounts.voucher_deleted
Neye yazar: voucher (delete) — Removes the voucher and its codes
curl -X POST https://app.getera.io/api/v1/vouchers/VOUCHER_ID/actions/delete_voucher \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{}'{
"ok": true,
"result": "…",
"events": [
"discounts.voucher_deleted"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.vouchers.deleteVoucher("VOUCHER_ID")era vouchers delete_voucher VOUCHER_ID{
"name": "era__discounts__delete_voucher",
"arguments": {
"id": "VOUCHER_ID"
}
}Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde discounts:delete izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 409 not_found · 429 çok sık istek
discounts.delete_voucher_codes
Kupon kodlarını kaldır — Kullanılmış olanlar da — sonuç kaç tanesinin kullanıldığını söyler.
Gereken izin discounts:delete · siler ya da geri alınamaz · Era çalıştırırken bir kişiye onaylatır
https://app.getera.io/api/v1/voucher_codes/actions/delete_voucher_codes- Asıl adres:
POST /api/v1/actions/discounts.delete_voucher_codes
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
voucherId | uuid | evet | Kupon · kimliği: voucher |
codeIds | object / array | evet | Kodlar |
Ön koşullar
Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:
| Kod | Ne zaman reddedilir |
|---|---|
not_found | Kupon bulunmalı. |
Yayımladığı olaylar: discounts.voucher_codes_deleted
Neye yazar: voucher_code (delete) — Removes the codes
curl -X POST https://app.getera.io/api/v1/voucher_codes/actions/delete_voucher_codes \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"voucherId":"VOUCHER_ID","codeIds":{}}'{
"ok": true,
"result": "…",
"events": [
"discounts.voucher_codes_deleted"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.voucherCodes.deleteVoucherCodes({
voucherId: "VOUCHER_ID",
codeIds: {}
})era voucher_codes delete_voucher_codes --data '{"voucherId":"VOUCHER_ID","codeIds":{}}'{
"name": "era__discounts__delete_voucher_codes",
"arguments": {
"voucherId": "VOUCHER_ID",
"codeIds": {}
}
}Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde discounts:delete izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 409 not_found · 429 çok sık istek
discounts.import_voucher_codes
Kupon kodlarını içe aktar — Bir CSV dosyasından kodlar — ilk sütun, başlık isteğe bağlı. Hepsi ya da hiçbiri.
Gereken izin discounts:write · veriyi değiştirir
https://app.getera.io/api/v1/voucher_codes/actions/import_voucher_codes- Asıl adres:
POST /api/v1/actions/discounts.import_voucher_codes
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
voucherId | uuid | evet | Kupon · kimliği: voucher |
codes | object / array | evet | Kodlar |
Ön koşullar
Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:
| Kod | Ne zaman reddedilir |
|---|---|
not_found | Kupon bulunmalı. |
no_codes | Dosyada en az bir kod olmalı. |
import_too_large | Dosya başına en fazla beş bin kod. |
duplicate_codes | Bir kod bir kez verilebilir. |
code_taken | Kod, büyük-küçük harf gözetmeksizin, bu çalışma alanında boşta olmalı. |
Yayımladığı olaylar: discounts.voucher_codes_added
Neye yazar: voucher_code (insert) — Writes the codes
curl -X POST https://app.getera.io/api/v1/voucher_codes/actions/import_voucher_codes \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"voucherId":"VOUCHER_ID","codes":{}}'{
"ok": true,
"result": "…",
"events": [
"discounts.voucher_codes_added"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.voucherCodes.importVoucherCodes({
voucherId: "VOUCHER_ID",
codes: {}
})era voucher_codes import_voucher_codes --data '{"voucherId":"VOUCHER_ID","codes":{}}'{
"name": "era__discounts__import_voucher_codes",
"arguments": {
"voucherId": "VOUCHER_ID",
"codes": {}
}
}Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde discounts:write izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 409 not_found, no_codes, import_too_large, duplicate_codes, code_taken · 429 çok sık istek
discounts.save_promotion
Kampanyayı kaydet — Fiyatları değiştiren bir katalog indirimi ya da sepet toplamında bir sipariş fırsatı.
Gereken izin discounts:write · veriyi değiştirir
https://app.getera.io/api/v1/promotions/{id}/actions/save_promotion- REST kısayolu:
PATCH /api/v1/promotions/{id} - Asıl adres:
POST /api/v1/actions/discounts.save_promotion
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
id | uuid | Doldurulduğu yer: adresteki {id} · Promosyon · kimliği: promotion | |
name | string | evet | Ad · en çok 255 |
type | string (enum) | Tür · İzin verilen değerler: catalogue, order | |
description | string | Açıklama · en çok 4000 | |
startDate | date-time | Başlangıç | |
endDate | date-time | Bitiş |
Ön koşullar
Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:
| Kod | Ne zaman reddedilir |
|---|---|
invalid_name | Kampanyanın bir adı olmalı. |
not_found | Düzenlenen kampanya bulunmalı. |
end_before_start | Başladıktan sonra bitmeli. |
Yayımladığı olaylar: discounts.promotion_created, discounts.promotion_updated
Neye yazar: promotion (upsert) — Creates or edits the promotion
curl -X POST https://app.getera.io/api/v1/promotions/PROMOTION_ID/actions/save_promotion \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"name":"Name"}'{
"ok": true,
"result": "…",
"events": [
"discounts.promotion_created",
"discounts.promotion_updated"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.promotions.savePromotion("PROMOTION_ID", {
name: "Name"
})era promotions save_promotion PROMOTION_ID \
--name "Name"{
"name": "era__discounts__save_promotion",
"arguments": {
"id": "PROMOTION_ID",
"name": "Name"
}
}Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde discounts:write izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 409 invalid_name, not_found, end_before_start · 429 çok sık istek
discounts.save_promotion_rule
Kampanya kuralını kaydet — Neyi kapsadığı, hangi kanallarda ve ne verdiği.
Gereken izin discounts:write · veriyi değiştirir
https://app.getera.io/api/v1/promotion_rules/{id}/actions/save_promotion_rule- REST kısayolu:
PATCH /api/v1/promotion_rules/{id} - Asıl adres:
POST /api/v1/actions/discounts.save_promotion_rule
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
id | uuid | Doldurulduğu yer: adresteki {id} · Kural · kimliği: promotion_rule | |
promotionId | uuid | Promosyon · kimliği: promotion | |
name | string | Ad · en çok 255 | |
description | string | Açıklama · en çok 2000 | |
channelIds | object / array | Kanallar | |
rewardValueType | string (enum) | İndirim · İzin verilen değerler: percentage, fixed | |
rewardValue | number | Değer · en az 0 | |
rewardType | string (enum) | Ödül · İzin verilen değerler: subtotal_discount, gift | |
targets | object / array | Kapsar | |
cataloguePredicate | object / array | Kapsam (VE / VEYA ağacı) | |
orderPredicate | object / array | Sipariş koşulu | |
giftVariantIds | object / array | Hediyeler |
Ön koşullar
Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:
| Kod | Ne zaman reddedilir |
|---|---|
not_found | Kampanya ve düzenlenen kural bulunmalı. |
channel_not_found | Her kanal bulunmalı. |
predicate_required | Katalog kuralı bir şeyi kapsar; sipariş kuralının bir toplam koşulu vardır. |
predicate_not_allowed | Kural yalnızca kendi kampanya türünün koşulunu taşır. |
invalid_range | Sipariş toplamı aralığı (kuruş) pozitiftir ve küçükten büyüğe gider. |
invalid_predicate | Koşul ağacı geçerli biçimde olmalı: kendi seviyesinde tek başına VE / VEYA grupları, bilinen yapraklar, kimlikler ve tutarlar. |
reward_type_not_allowed | Katalog kuralının ödül türü yoktur. |
reward_type_required | Sipariş kuralı para indirimi mi hediye mi olduğunu söyler. |
mixed_currencies | Tutarlar ve sipariş toplamı koşulları tek para biriminde kanallar gerektirir. |
gift_rule_invalid | Hediye kuralının hediyeleri vardır, değeri yoktur. |
reward_value_required | İndirim kuralının sıfırın üstünde bir değeri ve türü vardır. |
channels_required | Tutar indirimi en az bir kanal gerektirir. |
invalid_percentage | Yüzde en fazla 100’dür. |
Yayımladığı olaylar: discounts.rule_created, discounts.rule_updated
Neye yazar: promotion_rule (upsert) — Creates or edits the rule; promotion_rule_channel (insert) — Replaces its channels; promotion_rule_target (insert) — Replaces what it covers; promotion_rule_gift (insert) — Replaces its gifts
curl -X POST https://app.getera.io/api/v1/promotion_rules/PROMOTION_RULE_ID/actions/save_promotion_rule \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"promotionId":"PROMOTION_ID"}'{
"ok": true,
"result": "…",
"events": [
"discounts.rule_created",
"discounts.rule_updated"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.promotionRules.savePromotionRule("PROMOTION_RULE_ID", {
promotionId: "PROMOTION_ID"
})era promotion_rules save_promotion_rule PROMOTION_RULE_ID \
--promotion-id "PROMOTION_ID"{
"name": "era__discounts__save_promotion_rule",
"arguments": {
"id": "PROMOTION_RULE_ID",
"promotionId": "PROMOTION_ID"
}
}Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde discounts:write izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 409 not_found, channel_not_found, predicate_required, predicate_not_allowed, invalid_range, invalid_predicate, reward_type_not_allowed, reward_type_required, mixed_currencies, gift_rule_invalid, reward_value_required, channels_required, invalid_percentage · 429 çok sık istek
discounts.save_voucher
Kuponu kaydet — Müşterilerin yazdığı bir kod — kapsamı, sınırları, tarihleri.
Gereken izin discounts:write · veriyi değiştirir
https://app.getera.io/api/v1/vouchers/{id}/actions/save_voucher- REST kısayolu:
PATCH /api/v1/vouchers/{id} - Asıl adres:
POST /api/v1/actions/discounts.save_voucher
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
id | uuid | Doldurulduğu yer: adresteki {id} · Kupon · kimliği: voucher | |
name | string | Ad · en çok 255 | |
type | string (enum) | Uygulandığı yer · İzin verilen değerler: entire_order, shipping, specific_product | |
discountValueType | string (enum) | İndirim · İzin verilen değerler: fixed, percentage | |
usageLimit | number | Kullanım limiti · en az 1 | |
startDate | date-time | Başlangıç | |
endDate | date-time | Bitiş | |
applyOncePerOrder | boolean | Sipariş başına bir kez | |
applyOncePerCustomer | boolean | Müşteri başına bir kez | |
singleUse | boolean | Her kod bir kez | |
onlyForStaff | boolean | Yalnızca personel | |
minCheckoutItemsQuantity | number | En az ürün sayısı · en az 0 | |
countries | object / array | Ülkeler | |
codes | object / array | Kodlar |
Ön koşullar
Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:
| Kod | Ne zaman reddedilir |
|---|---|
not_found | Düzenlenen kupon bulunmalı. |
end_before_start | Başladıktan sonra bitmeli. |
invalid_percentage | Yüzdeye geçiş, her kanal değerinin en fazla 100 olmasını gerektirir. |
duplicate_codes | Bir kod bir kez verilebilir. |
code_taken | Kod, büyük-küçük harf gözetmeksizin, bu çalışma alanında boşta olmalı. |
Yayımladığı olaylar: discounts.voucher_created, discounts.voucher_updated
Neye yazar: voucher (upsert) — Creates or edits the voucher; voucher_code (insert) — Writes its first codes on create
curl -X POST https://app.getera.io/api/v1/vouchers/VOUCHER_ID/actions/save_voucher \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"name":"Name"}'{
"ok": true,
"result": "…",
"events": [
"discounts.voucher_created",
"discounts.voucher_updated"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.vouchers.saveVoucher("VOUCHER_ID", {
name: "Name"
})era vouchers save_voucher VOUCHER_ID \
--name "Name"{
"name": "era__discounts__save_voucher",
"arguments": {
"id": "VOUCHER_ID",
"name": "Name"
}
}Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde discounts:write izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 409 not_found, end_before_start, invalid_percentage, duplicate_codes, code_taken · 429 çok sık istek
discounts.set_voucher_catalogue
Kuponu kataloğun bir kısmıyla sınırla — Belirli ürün kuponunun kapsadığı ürünler, varyantlar, kategoriler ve koleksiyonlar.
Gereken izin discounts:write · veriyi değiştirir
https://app.getera.io/api/v1/voucher_catalogues/actions/set_voucher_catalogue- Asıl adres:
POST /api/v1/actions/discounts.set_voucher_catalogue
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
voucherId | uuid | evet | Kupon · kimliği: voucher |
itemIds | object / array | Ürünler | |
variantIds | object / array | Varyantlar | |
categoryIds | object / array | Kategoriler | |
collectionIds | object / array | Koleksiyonlar |
Ön koşullar
Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:
| Kod | Ne zaman reddedilir |
|---|---|
not_found | Kupon bulunmalı. |
catalogue_not_allowed | Yalnızca belirli ürün kuponunun bir kataloğu olur. |
Yayımladığı olaylar: discounts.voucher_updated
Neye yazar: voucher_catalogue (insert) — Replaces what it covers
curl -X POST https://app.getera.io/api/v1/voucher_catalogues/actions/set_voucher_catalogue \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"voucherId":"VOUCHER_ID"}'{
"ok": true,
"result": "…",
"events": [
"discounts.voucher_updated"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.voucherCatalogues.setVoucherCatalogue({
voucherId: "VOUCHER_ID"
})era voucher_catalogues set_voucher_catalogue \
--voucher-id "VOUCHER_ID"{
"name": "era__discounts__set_voucher_catalogue",
"arguments": {
"voucherId": "VOUCHER_ID"
}
}Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde discounts:write izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 409 not_found, catalogue_not_allowed · 429 çok sık istek
discounts.set_voucher_channels
Kuponun kanal değerini belirle — Her kanalda ne kadar düştüğü ve oradaki en düşük harcama.
Gereken izin discounts:write · veriyi değiştirir
https://app.getera.io/api/v1/voucher_channel_listings/actions/set_voucher_channels- Asıl adres:
POST /api/v1/actions/discounts.set_voucher_channels
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
voucherId | uuid | evet | Kupon · kimliği: voucher |
listings | object / array | evet | Kanallar |
Ön koşullar
Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:
| Kod | Ne zaman reddedilir |
|---|---|
not_found | Kupon bulunmalı. |
channel_not_found | Her kanal bulunmalı. |
value_required | Her kanalın sıfırın üstünde bir değeri olmalı. |
invalid_percentage | Yüzde en fazla 100’dür. |
Yayımladığı olaylar: discounts.voucher_updated
Neye yazar: voucher_channel_listing (upsert) — Replaces the per-channel values
curl -X POST https://app.getera.io/api/v1/voucher_channel_listings/actions/set_voucher_channels \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"voucherId":"VOUCHER_ID","listings":{}}'{
"ok": true,
"result": "…",
"events": [
"discounts.voucher_updated"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.voucherChannelListings.setVoucherChannels({
voucherId: "VOUCHER_ID",
listings: {}
})era voucher_channel_listings set_voucher_channels --data '{"voucherId":"VOUCHER_ID","listings":{}}'{
"name": "era__discounts__set_voucher_channels",
"arguments": {
"voucherId": "VOUCHER_ID",
"listings": {}
}
}Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde discounts:write izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 409 not_found, channel_not_found, value_required, invalid_percentage · 429 çok sık istek
Veri modelleri
PromotionRuleChannel
Tablo promotion_rule_channel · Kaynak promotion_rule_channels
GET /api/v1/promotion_rule_channelsGET /api/v1/promotion_rule_channels/{id}
| Sütun | Tür | Boş olabilir | İzin verilen değerler | Bağlı olduğu tablo |
|---|---|---|---|---|
id | string (uuid) · uuid | |||
organization_id | string (uuid) · uuid | organization | ||
workspace_id | string (uuid) · uuid | workspace | ||
rule_id | string (uuid) · uuid | promotion_rule | ||
channel_id | string (uuid) · uuid | channel |
Birincil anahtar: id
Tekil: rule_id, channel_id
PromotionRuleGift
Tablo promotion_rule_gift · Kaynak promotion_rule_gifts
GET /api/v1/promotion_rule_giftsGET /api/v1/promotion_rule_gifts/{id}
| Sütun | Tür | Boş olabilir | İzin verilen değerler | Bağlı olduğu tablo |
|---|---|---|---|---|
id | string (uuid) · uuid | |||
organization_id | string (uuid) · uuid | organization | ||
workspace_id | string (uuid) · uuid | workspace | ||
rule_id | string (uuid) · uuid | promotion_rule | ||
item_variant_id | string (uuid) · uuid | item_variant |
Birincil anahtar: id
Tekil: rule_id, item_variant_id
PromotionRuleTarget
Tablo promotion_rule_target · Kaynak promotion_rule_targets
GET /api/v1/promotion_rule_targetsGET /api/v1/promotion_rule_targets/{id}
| Sütun | Tür | Boş olabilir | İzin verilen değerler | Bağlı olduğu tablo |
|---|---|---|---|---|
id | string (uuid) · uuid | |||
organization_id | string (uuid) · uuid | organization | ||
workspace_id | string (uuid) · uuid | workspace | ||
rule_id | string (uuid) · uuid | promotion_rule | ||
item_id | string (uuid) · uuid | evet | item | |
item_variant_id | string (uuid) · uuid | evet | item_variant | |
category_id | string (uuid) · uuid | evet | item_category | |
collection_id | string (uuid) · uuid | evet | item_collection |
Birincil anahtar: id
Denetimler:
CHECK ((num_nonnulls(item_id, item_variant_id, category_id, collection_id) = 1))
PromotionRule
Tablo promotion_rule · Kaynak promotion_rules
GET /api/v1/promotion_rulesGET /api/v1/promotion_rules/{id}PATCH /api/v1/promotion_rules/{id}→discounts.save_promotion_ruleDELETE /api/v1/promotion_rules/{id}→discounts.delete_promotion_rule
| Sütun | Tür | Boş olabilir | İzin verilen değerler | Bağlı olduğu tablo |
|---|---|---|---|---|
id | string (uuid) · uuid | |||
organization_id | string (uuid) · uuid | organization | ||
workspace_id | string (uuid) · uuid | workspace | ||
promotion_id | string (uuid) · uuid | promotion | ||
name | string · text | evet | ||
description | string · text | evet | ||
reward_value_type | string · text | evet | fixed, percentage | |
reward_value | string (decimal) · numeric | evet | ||
reward_type | string · text | evet | subtotal_discount, gift | |
order_predicate | object · jsonb | |||
created_at | string (date-time) · timestamptz | |||
updated_at | string (date-time) · timestamptz | |||
catalogue_predicate | object · jsonb |
Birincil anahtar: id
Denetimler:
CHECK (((reward_value_type <> 'percentage'::text) OR (reward_value IS NULL) OR (reward_value <= (100)::numeric)))CHECK (((reward_value IS NULL) OR (reward_value >= (0)::numeric)))
Promotion
Tablo promotion · Kaynak promotions
GET /api/v1/promotionsGET /api/v1/promotions/{id}PATCH /api/v1/promotions/{id}→discounts.save_promotionDELETE /api/v1/promotions/{id}→discounts.delete_promotion
| Sütun | Tür | Boş olabilir | İzin verilen değerler | Bağlı olduğu tablo |
|---|---|---|---|---|
id | string (uuid) · uuid | |||
organization_id | string (uuid) · uuid | organization | ||
workspace_id | string (uuid) · uuid | workspace | ||
name | string · text | |||
description | string · text | evet | ||
type | string · text | catalogue, order | ||
start_date | string (date-time) · timestamptz | |||
end_date | string (date-time) · timestamptz | evet | ||
metadata | object · jsonb | |||
created_at | string (date-time) · timestamptz | |||
updated_at | string (date-time) · timestamptz | |||
last_notification_scheduled_at | string (date-time) · timestamptz | evet |
Birincil anahtar: id
Denetimler:
CHECK (((end_date IS NULL) OR (end_date > start_date)))
VoucherCatalogue
Tablo voucher_catalogue · Kaynak voucher_catalogues
GET /api/v1/voucher_cataloguesGET /api/v1/voucher_catalogues/{id}
| Sütun | Tür | Boş olabilir | İzin verilen değerler | Bağlı olduğu tablo |
|---|---|---|---|---|
id | string (uuid) · uuid | |||
organization_id | string (uuid) · uuid | organization | ||
workspace_id | string (uuid) · uuid | workspace | ||
voucher_id | string (uuid) · uuid | voucher | ||
item_id | string (uuid) · uuid | evet | item | |
item_variant_id | string (uuid) · uuid | evet | item_variant | |
category_id | string (uuid) · uuid | evet | item_category | |
collection_id | string (uuid) · uuid | evet | item_collection |
Birincil anahtar: id
Denetimler:
CHECK ((num_nonnulls(item_id, item_variant_id, category_id, collection_id) = 1))
VoucherChannelListing
Tablo voucher_channel_listing · Kaynak voucher_channel_listings
GET /api/v1/voucher_channel_listingsGET /api/v1/voucher_channel_listings/{id}
| Sütun | Tür | Boş olabilir | İzin verilen değerler | Bağlı olduğu tablo |
|---|---|---|---|---|
id | string (uuid) · uuid | |||
organization_id | string (uuid) · uuid | organization | ||
workspace_id | string (uuid) · uuid | workspace | ||
voucher_id | string (uuid) · uuid | voucher | ||
channel_id | string (uuid) · uuid | channel | ||
discount_value | string (decimal) · numeric | |||
currency | string · bpchar | en çok 3 | ||
min_spent_amount | string (int64) · int8 | evet |
Birincil anahtar: id
Tekil: voucher_id, channel_id
Denetimler:
CHECK ((currency ~ '^[A-Z]{3}$'::text))CHECK ((discount_value > (0)::numeric))CHECK (((min_spent_amount IS NULL) OR (min_spent_amount >= 0)))
VoucherCode
Tablo voucher_code · Kaynak voucher_codes
GET /api/v1/voucher_codesGET /api/v1/voucher_codes/{id}
| Sütun | Tür | Boş olabilir | İzin verilen değerler | Bağlı olduğu tablo |
|---|---|---|---|---|
id | string (uuid) · uuid | |||
organization_id | string (uuid) · uuid | organization | ||
workspace_id | string (uuid) · uuid | workspace | ||
voucher_id | string (uuid) · uuid | voucher | ||
code | string · text | |||
used | integer · int4 | |||
is_active | boolean · bool | |||
created_at | string (date-time) · timestamptz |
Birincil anahtar: id
Denetimler:
CHECK (((length(code) >= 1) AND (length(code) <= 255)))CHECK ((used >= 0))
VoucherCustomer
Tablo voucher_customer · Kaynak voucher_customers
GET /api/v1/voucher_customersGET /api/v1/voucher_customers/{id}
| Sütun | Tür | Boş olabilir | İzin verilen değerler | Bağlı olduğu tablo |
|---|---|---|---|---|
id | string (uuid) · uuid | |||
organization_id | string (uuid) · uuid | organization | ||
workspace_id | string (uuid) · uuid | workspace | ||
voucher_code_id | string (uuid) · uuid | voucher_code | ||
customer_email | string · text | evet | ||
order_id | string (uuid) · uuid | |||
created_at | string (date-time) · timestamptz |
Birincil anahtar: id
Tekil: voucher_code_id, order_id
Voucher
Tablo voucher · Kaynak vouchers
GET /api/v1/vouchersGET /api/v1/vouchers/{id}PATCH /api/v1/vouchers/{id}→discounts.save_voucherDELETE /api/v1/vouchers/{id}→discounts.delete_voucher
| Sütun | Tür | Boş olabilir | İzin verilen değerler | Bağlı olduğu tablo |
|---|---|---|---|---|
id | string (uuid) · uuid | |||
organization_id | string (uuid) · uuid | organization | ||
workspace_id | string (uuid) · uuid | workspace | ||
name | string · text | evet | ||
type | string · text | entire_order, shipping, specific_product | ||
discount_value_type | string · text | fixed, percentage | ||
usage_limit | integer · int4 | evet | ||
start_date | string (date-time) · timestamptz | |||
end_date | string (date-time) · timestamptz | evet | ||
apply_once_per_order | boolean · bool | |||
apply_once_per_customer | boolean · bool | |||
single_use | boolean · bool | |||
only_for_staff | boolean · bool | |||
min_checkout_items_quantity | integer · int4 | evet | ||
countries | string[] · bpchar[] | |||
metadata | object · jsonb | |||
created_at | string (date-time) · timestamptz | |||
updated_at | string (date-time) · timestamptz |
Birincil anahtar: id
Denetimler:
CHECK (((end_date IS NULL) OR (end_date > start_date)))CHECK (((min_checkout_items_quantity IS NULL) OR (min_checkout_items_quantity >= 0)))CHECK (((usage_limit IS NULL) OR (usage_limit >= 1)))
Olaylar
İş akışları ve webhook'lar bu olaylara tepki verir.
| Olay | Ne olur | Taşıdığı alanlar |
|---|---|---|
discounts.promotion_created | Bir promosyon oluşturuldu. | id, type |
discounts.promotion_deleted | Bir promosyon kaldırıldı. | id, type |
discounts.promotion_ended | Bir promosyonun bitiş tarihi geçti. | id, type, endDate |
discounts.promotion_started | Bir promosyonun başlangıç tarihi geçti. | id, type, startDate |
discounts.promotion_updated | Bir promosyon düzenlendi. | id, type |
discounts.rule_created | Bir promosyon kuralı eklendi. | id, promotionId, type, channelIds |
discounts.rule_deleted | Bir promosyon kuralı kaldırıldı. | id, promotionId, type |
discounts.rule_updated | Bir promosyon kuralı düzenlendi. | id, promotionId, type, channelIds |
discounts.voucher_codes_added | Bir kupona kodlar eklendi. | voucherId, count |
discounts.voucher_codes_deleted | Bir kupondan kodlar kaldırıldı. | voucherId, count, used |
discounts.voucher_created | Bir kupon oluşturuldu. | id, codes |
discounts.voucher_deleted | Bir kupon kaldırıldı. | id |
discounts.voucher_updated | Bir kupon düzenlendi. | id |