İ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

KaynakTabloListeleme ve okumaPOSTPATCHDELETE
promotion_rule_channelspromotion_rule_channel/api/v1/promotion_rule_channels
promotion_rule_giftspromotion_rule_gift/api/v1/promotion_rule_gifts
promotion_rule_targetspromotion_rule_target/api/v1/promotion_rule_targets
promotion_rulespromotion_rule/api/v1/promotion_rulesdiscounts.save_promotion_rulediscounts.delete_promotion_rule
promotionspromotion/api/v1/promotionsdiscounts.save_promotiondiscounts.delete_promotion
voucher_cataloguesvoucher_catalogue/api/v1/voucher_catalogues
voucher_channel_listingsvoucher_channel_listing/api/v1/voucher_channel_listings
voucher_codesvoucher_code/api/v1/voucher_codes
voucher_customersvoucher_customer/api/v1/voucher_customers
vouchersvoucher/api/v1/vouchersdiscounts.save_voucherdiscounts.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

İşlemGereken izinNe yapar
discounts.add_voucher_codesdiscounts:writeKupon kodu ekle
discounts.announce_promotiondiscounts:writeKampanyanın başladığını veya bittiğini duyur
discounts.delete_promotiondiscounts:deleteKampanyayı sil
discounts.delete_promotion_rulediscounts:writeKampanya kuralını sil
discounts.delete_voucherdiscounts:deleteKuponu sil
discounts.delete_voucher_codesdiscounts:deleteKupon kodlarını kaldır
discounts.import_voucher_codesdiscounts:writeKupon kodlarını içe aktar
discounts.save_promotiondiscounts:writeKampanyayı kaydet
discounts.save_promotion_rulediscounts:writeKampanya kuralını kaydet
discounts.save_voucherdiscounts:writeKuponu kaydet
discounts.set_voucher_cataloguediscounts:writeKuponu kataloğun bir kısmıyla sınırla
discounts.set_voucher_channelsdiscounts:writeKuponun 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

POSThttps://app.getera.io/api/v1/voucher_codes/actions/add_voucher_codes
API anahtarı ya da OAuth token · discounts:write
  • Asıl adres: POST /api/v1/actions/discounts.add_voucher_codes

Girdi

AlanTürZorunluAçıklama
voucherIduuidevetKupon · kimliği: voucher
codesobject / arrayKodlar
quantitynumberOluşturulacak adet · en az 0 · en çok 50
prefixstringÖnek · en çok 40

Ön koşullar

Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:

KodNe zaman reddedilir
not_foundKupon bulunmalı.
no_codesEn az bir kod yazılmalı veya üretilmeli.
too_many_codesTek seferde en fazla elli.
duplicate_codesBir kod bir kez verilebilir.
code_takenKod, 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"}'
Yanıt
{
  "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"
tools/call
{
  "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)

POSThttps://app.getera.io/api/v1/promotions/{id}/actions/announce_promotion
API anahtarı ya da OAuth token · discounts:write
  • Asıl adres: POST /api/v1/actions/discounts.announce_promotion

Girdi

AlanTürZorunluAçıklama
iduuidevetDoldurulduğu yer: adresteki {id} · Promosyon · kimliği: promotion

Ön koşullar

Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:

KodNe zaman reddedilir
not_foundKampanya bulunmalı.
nothing_to_announceSon 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 '{}'
Yanıt
{
  "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
tools/call
{
  "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

POSThttps://app.getera.io/api/v1/promotions/{id}/actions/delete_promotion
API anahtarı ya da OAuth token · discounts:delete
  • REST kısayolu: DELETE /api/v1/promotions/{id}
  • Asıl adres: POST /api/v1/actions/discounts.delete_promotion

Girdi

AlanTürZorunluAçıklama
iduuidevetDoldurulduğu yer: adresteki {id} · Promosyon · kimliği: promotion

Ön koşullar

Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:

KodNe zaman reddedilir
not_foundKampanya 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 '{}'
Yanıt
{
  "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
tools/call
{
  "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

POSThttps://app.getera.io/api/v1/promotion_rules/{id}/actions/delete_promotion_rule
API anahtarı ya da OAuth token · discounts:write
  • REST kısayolu: DELETE /api/v1/promotion_rules/{id}
  • Asıl adres: POST /api/v1/actions/discounts.delete_promotion_rule

Girdi

AlanTürZorunluAçıklama
iduuidevetDoldurulduğu yer: adresteki {id} · Kural · kimliği: promotion_rule

Ön koşullar

Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:

KodNe zaman reddedilir
not_foundKural 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 '{}'
Yanıt
{
  "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
tools/call
{
  "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

POSThttps://app.getera.io/api/v1/vouchers/{id}/actions/delete_voucher
API anahtarı ya da OAuth token · discounts:delete
  • REST kısayolu: DELETE /api/v1/vouchers/{id}
  • Asıl adres: POST /api/v1/actions/discounts.delete_voucher

Girdi

AlanTürZorunluAçıklama
iduuidevetDoldurulduğu yer: adresteki {id} · Kupon · kimliği: voucher

Ön koşullar

Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:

KodNe zaman reddedilir
not_foundKupon 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 '{}'
Yanıt
{
  "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
tools/call
{
  "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

POSThttps://app.getera.io/api/v1/voucher_codes/actions/delete_voucher_codes
API anahtarı ya da OAuth token · discounts:delete
  • Asıl adres: POST /api/v1/actions/discounts.delete_voucher_codes

Girdi

AlanTürZorunluAçıklama
voucherIduuidevetKupon · kimliği: voucher
codeIdsobject / arrayevetKodlar

Ön koşullar

Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:

KodNe zaman reddedilir
not_foundKupon 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":{}}'
Yanıt
{
  "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":{}}'
tools/call
{
  "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

POSThttps://app.getera.io/api/v1/voucher_codes/actions/import_voucher_codes
API anahtarı ya da OAuth token · discounts:write
  • Asıl adres: POST /api/v1/actions/discounts.import_voucher_codes

Girdi

AlanTürZorunluAçıklama
voucherIduuidevetKupon · kimliği: voucher
codesobject / arrayevetKodlar

Ön koşullar

Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:

KodNe zaman reddedilir
not_foundKupon bulunmalı.
no_codesDosyada en az bir kod olmalı.
import_too_largeDosya başına en fazla beş bin kod.
duplicate_codesBir kod bir kez verilebilir.
code_takenKod, 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":{}}'
Yanıt
{
  "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":{}}'
tools/call
{
  "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

POSThttps://app.getera.io/api/v1/promotions/{id}/actions/save_promotion
API anahtarı ya da OAuth token · discounts:write
  • REST kısayolu: PATCH /api/v1/promotions/{id}
  • Asıl adres: POST /api/v1/actions/discounts.save_promotion

Girdi

AlanTürZorunluAçıklama
iduuidDoldurulduğu yer: adresteki {id} · Promosyon · kimliği: promotion
namestringevetAd · en çok 255
typestring (enum)Tür · İzin verilen değerler: catalogue, order
descriptionstringAçıklama · en çok 4000
startDatedate-timeBaşlangıç
endDatedate-timeBitiş

Ön koşullar

Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:

KodNe zaman reddedilir
invalid_nameKampanyanın bir adı olmalı.
not_foundDüzenlenen kampanya bulunmalı.
end_before_startBaş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"}'
Yanıt
{
  "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"
tools/call
{
  "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

POSThttps://app.getera.io/api/v1/promotion_rules/{id}/actions/save_promotion_rule
API anahtarı ya da OAuth token · discounts:write
  • REST kısayolu: PATCH /api/v1/promotion_rules/{id}
  • Asıl adres: POST /api/v1/actions/discounts.save_promotion_rule

Girdi

AlanTürZorunluAçıklama
iduuidDoldurulduğu yer: adresteki {id} · Kural · kimliği: promotion_rule
promotionIduuidPromosyon · kimliği: promotion
namestringAd · en çok 255
descriptionstringAçıklama · en çok 2000
channelIdsobject / arrayKanallar
rewardValueTypestring (enum)İndirim · İzin verilen değerler: percentage, fixed
rewardValuenumberDeğer · en az 0
rewardTypestring (enum)Ödül · İzin verilen değerler: subtotal_discount, gift
targetsobject / arrayKapsar
cataloguePredicateobject / arrayKapsam (VE / VEYA ağacı)
orderPredicateobject / arraySipariş koşulu
giftVariantIdsobject / arrayHediyeler

Ön koşullar

Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:

KodNe zaman reddedilir
not_foundKampanya ve düzenlenen kural bulunmalı.
channel_not_foundHer kanal bulunmalı.
predicate_requiredKatalog kuralı bir şeyi kapsar; sipariş kuralının bir toplam koşulu vardır.
predicate_not_allowedKural yalnızca kendi kampanya türünün koşulunu taşır.
invalid_rangeSipariş toplamı aralığı (kuruş) pozitiftir ve küçükten büyüğe gider.
invalid_predicateKoşul ağacı geçerli biçimde olmalı: kendi seviyesinde tek başına VE / VEYA grupları, bilinen yapraklar, kimlikler ve tutarlar.
reward_type_not_allowedKatalog kuralının ödül türü yoktur.
reward_type_requiredSipariş kuralı para indirimi mi hediye mi olduğunu söyler.
mixed_currenciesTutarlar ve sipariş toplamı koşulları tek para biriminde kanallar gerektirir.
gift_rule_invalidHediye 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_requiredTutar indirimi en az bir kanal gerektirir.
invalid_percentageYü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"}'
Yanıt
{
  "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"
tools/call
{
  "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

POSThttps://app.getera.io/api/v1/vouchers/{id}/actions/save_voucher
API anahtarı ya da OAuth token · discounts:write
  • REST kısayolu: PATCH /api/v1/vouchers/{id}
  • Asıl adres: POST /api/v1/actions/discounts.save_voucher

Girdi

AlanTürZorunluAçıklama
iduuidDoldurulduğu yer: adresteki {id} · Kupon · kimliği: voucher
namestringAd · en çok 255
typestring (enum)Uygulandığı yer · İzin verilen değerler: entire_order, shipping, specific_product
discountValueTypestring (enum)İndirim · İzin verilen değerler: fixed, percentage
usageLimitnumberKullanım limiti · en az 1
startDatedate-timeBaşlangıç
endDatedate-timeBitiş
applyOncePerOrderbooleanSipariş başına bir kez
applyOncePerCustomerbooleanMüşteri başına bir kez
singleUsebooleanHer kod bir kez
onlyForStaffbooleanYalnızca personel
minCheckoutItemsQuantitynumberEn az ürün sayısı · en az 0
countriesobject / arrayÜlkeler
codesobject / arrayKodlar

Ön koşullar

Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:

KodNe zaman reddedilir
not_foundDüzenlenen kupon bulunmalı.
end_before_startBaşladıktan sonra bitmeli.
invalid_percentageYüzdeye geçiş, her kanal değerinin en fazla 100 olmasını gerektirir.
duplicate_codesBir kod bir kez verilebilir.
code_takenKod, 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"}'
Yanıt
{
  "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"
tools/call
{
  "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

POSThttps://app.getera.io/api/v1/voucher_catalogues/actions/set_voucher_catalogue
API anahtarı ya da OAuth token · discounts:write
  • Asıl adres: POST /api/v1/actions/discounts.set_voucher_catalogue

Girdi

AlanTürZorunluAçıklama
voucherIduuidevetKupon · kimliği: voucher
itemIdsobject / arrayÜrünler
variantIdsobject / arrayVaryantlar
categoryIdsobject / arrayKategoriler
collectionIdsobject / arrayKoleksiyonlar

Ön koşullar

Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:

KodNe zaman reddedilir
not_foundKupon bulunmalı.
catalogue_not_allowedYalnı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"}'
Yanıt
{
  "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"
tools/call
{
  "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

POSThttps://app.getera.io/api/v1/voucher_channel_listings/actions/set_voucher_channels
API anahtarı ya da OAuth token · discounts:write
  • Asıl adres: POST /api/v1/actions/discounts.set_voucher_channels

Girdi

AlanTürZorunluAçıklama
voucherIduuidevetKupon · kimliği: voucher
listingsobject / arrayevetKanallar

Ön koşullar

Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:

KodNe zaman reddedilir
not_foundKupon bulunmalı.
channel_not_foundHer kanal bulunmalı.
value_requiredHer kanalın sıfırın üstünde bir değeri olmalı.
invalid_percentageYü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":{}}'
Yanıt
{
  "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":{}}'
tools/call
{
  "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_channels
  • GET /api/v1/promotion_rule_channels/{id}
SütunTürBoş olabilirİzin verilen değerlerBağlı olduğu tablo
idstring (uuid) · uuid
organization_idstring (uuid) · uuidorganization
workspace_idstring (uuid) · uuidworkspace
rule_idstring (uuid) · uuidpromotion_rule
channel_idstring (uuid) · uuidchannel

Birincil anahtar: id

Tekil: rule_id, channel_id

PromotionRuleGift

Tablo promotion_rule_gift · Kaynak promotion_rule_gifts

  • GET /api/v1/promotion_rule_gifts
  • GET /api/v1/promotion_rule_gifts/{id}
SütunTürBoş olabilirİzin verilen değerlerBağlı olduğu tablo
idstring (uuid) · uuid
organization_idstring (uuid) · uuidorganization
workspace_idstring (uuid) · uuidworkspace
rule_idstring (uuid) · uuidpromotion_rule
item_variant_idstring (uuid) · uuiditem_variant

Birincil anahtar: id

Tekil: rule_id, item_variant_id

PromotionRuleTarget

Tablo promotion_rule_target · Kaynak promotion_rule_targets

  • GET /api/v1/promotion_rule_targets
  • GET /api/v1/promotion_rule_targets/{id}
SütunTürBoş olabilirİzin verilen değerlerBağlı olduğu tablo
idstring (uuid) · uuid
organization_idstring (uuid) · uuidorganization
workspace_idstring (uuid) · uuidworkspace
rule_idstring (uuid) · uuidpromotion_rule
item_idstring (uuid) · uuidevetitem
item_variant_idstring (uuid) · uuidevetitem_variant
category_idstring (uuid) · uuidevetitem_category
collection_idstring (uuid) · uuidevetitem_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

SütunTürBoş olabilirİzin verilen değerlerBağlı olduğu tablo
idstring (uuid) · uuid
organization_idstring (uuid) · uuidorganization
workspace_idstring (uuid) · uuidworkspace
promotion_idstring (uuid) · uuidpromotion
namestring · textevet
descriptionstring · textevet
reward_value_typestring · textevetfixed, percentage
reward_valuestring (decimal) · numericevet
reward_typestring · textevetsubtotal_discount, gift
order_predicateobject · jsonb
created_atstring (date-time) · timestamptz
updated_atstring (date-time) · timestamptz
catalogue_predicateobject · 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

SütunTürBoş olabilirİzin verilen değerlerBağlı olduğu tablo
idstring (uuid) · uuid
organization_idstring (uuid) · uuidorganization
workspace_idstring (uuid) · uuidworkspace
namestring · text
descriptionstring · textevet
typestring · textcatalogue, order
start_datestring (date-time) · timestamptz
end_datestring (date-time) · timestamptzevet
metadataobject · jsonb
created_atstring (date-time) · timestamptz
updated_atstring (date-time) · timestamptz
last_notification_scheduled_atstring (date-time) · timestamptzevet

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_catalogues
  • GET /api/v1/voucher_catalogues/{id}
SütunTürBoş olabilirİzin verilen değerlerBağlı olduğu tablo
idstring (uuid) · uuid
organization_idstring (uuid) · uuidorganization
workspace_idstring (uuid) · uuidworkspace
voucher_idstring (uuid) · uuidvoucher
item_idstring (uuid) · uuidevetitem
item_variant_idstring (uuid) · uuidevetitem_variant
category_idstring (uuid) · uuidevetitem_category
collection_idstring (uuid) · uuidevetitem_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_listings
  • GET /api/v1/voucher_channel_listings/{id}
SütunTürBoş olabilirİzin verilen değerlerBağlı olduğu tablo
idstring (uuid) · uuid
organization_idstring (uuid) · uuidorganization
workspace_idstring (uuid) · uuidworkspace
voucher_idstring (uuid) · uuidvoucher
channel_idstring (uuid) · uuidchannel
discount_valuestring (decimal) · numeric
currencystring · bpcharen çok 3
min_spent_amountstring (int64) · int8evet

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_codes
  • GET /api/v1/voucher_codes/{id}
SütunTürBoş olabilirİzin verilen değerlerBağlı olduğu tablo
idstring (uuid) · uuid
organization_idstring (uuid) · uuidorganization
workspace_idstring (uuid) · uuidworkspace
voucher_idstring (uuid) · uuidvoucher
codestring · text
usedinteger · int4
is_activeboolean · bool
created_atstring (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_customers
  • GET /api/v1/voucher_customers/{id}
SütunTürBoş olabilirİzin verilen değerlerBağlı olduğu tablo
idstring (uuid) · uuid
organization_idstring (uuid) · uuidorganization
workspace_idstring (uuid) · uuidworkspace
voucher_code_idstring (uuid) · uuidvoucher_code
customer_emailstring · textevet
order_idstring (uuid) · uuid
created_atstring (date-time) · timestamptz

Birincil anahtar: id

Tekil: voucher_code_id, order_id

Voucher

Tablo voucher · Kaynak vouchers

SütunTürBoş olabilirİzin verilen değerlerBağlı olduğu tablo
idstring (uuid) · uuid
organization_idstring (uuid) · uuidorganization
workspace_idstring (uuid) · uuidworkspace
namestring · textevet
typestring · textentire_order, shipping, specific_product
discount_value_typestring · textfixed, percentage
usage_limitinteger · int4evet
start_datestring (date-time) · timestamptz
end_datestring (date-time) · timestamptzevet
apply_once_per_orderboolean · bool
apply_once_per_customerboolean · bool
single_useboolean · bool
only_for_staffboolean · bool
min_checkout_items_quantityinteger · int4evet
countriesstring[] · bpchar[]
metadataobject · jsonb
created_atstring (date-time) · timestamptz
updated_atstring (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.

OlayNe olurTaşıdığı alanlar
discounts.promotion_createdBir promosyon oluşturuldu.id, type
discounts.promotion_deletedBir promosyon kaldırıldı.id, type
discounts.promotion_endedBir promosyonun bitiş tarihi geçti.id, type, endDate
discounts.promotion_startedBir promosyonun başlangıç tarihi geçti.id, type, startDate
discounts.promotion_updatedBir promosyon düzenlendi.id, type
discounts.rule_createdBir promosyon kuralı eklendi.id, promotionId, type, channelIds
discounts.rule_deletedBir promosyon kuralı kaldırıldı.id, promotionId, type
discounts.rule_updatedBir promosyon kuralı düzenlendi.id, promotionId, type, channelIds
discounts.voucher_codes_addedBir kupona kodlar eklendi.voucherId, count
discounts.voucher_codes_deletedBir kupondan kodlar kaldırıldı.voucherId, count, used
discounts.voucher_createdBir kupon oluşturuldu.id, codes
discounts.voucher_deletedBir kupon kaldırıldı.id
discounts.voucher_updatedBir kupon düzenlendi.id
Bu sayfa yardımcı oldu mu?