Abonelikler API
Abonelikler modülünün tüm işlemleri (9) ve veri modelleri (2): adresler, izinler, girdiler, ön koşullar, olaylar ve örnekler.
Sabit fiyatlı, her dönem yenilenip faturalanan tekrarlayan planlar.
Modül kodu subscriptions · 9 işlem · 2 veri modeli · 9 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ı: subscriptions (hepsi), subscriptions:read (yalnız okuma) ya da subscriptions:<yetenek>.
Kaynaklar
| Kaynak | Tablo | Listeleme ve okuma | POST | PATCH | DELETE |
|---|---|---|---|---|---|
subscription_periods | subscription_period | /api/v1/subscription_periods | |||
subscriptions | subscription | /api/v1/subscriptions |
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 |
|---|---|---|
subscriptions.buy_package_online | subscriptions:write | Online paket satın al |
subscriptions.cancel | subscriptions:write | İptal et |
subscriptions.pause | subscriptions:write | Duraklat |
subscriptions.raise_ending_notices | subscriptions:write | “Yakında bitiyor” bildirimlerini oluştur |
subscriptions.renew | subscriptions:write | Şimdi yenile |
subscriptions.renew_due | subscriptions:manage | Yenileme zamanı gelenleri yenile |
subscriptions.resume | subscriptions:write | Devam ettir |
subscriptions.set_auto_renew | subscriptions:write | Yenileme |
subscriptions.start | subscriptions:write | Abonelik başlat |
subscriptions.buy_package_online
Online paket satın al — Giriş yapmış müşteri siteden bir paket başlatır: paketin fiyatıyla bir abonelik, ilk dönemi bugünden başlar.
Gereken izin subscriptions:write · veriyi değiştirir · Yayındaki bir siteden de çağrılabilir (customer)
/api/site/v1/{siteId}, örneğin @getera/storefront ile). API anahtarı ya da token ile istek reddedilir (403 site_only).https://app.getera.io/api/v1/subscriptions/actions/buy_package_online- Asıl adres:
POST /api/v1/actions/subscriptions.buy_package_online
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
packageId | uuid | evet | Paket · kimliği: package |
autoRenew | boolean | Otomatik yenilenir |
Ön koşullar
Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:
| Kod | Ne zaman reddedilir |
|---|---|
package_not_found | Bu paket satışta değil. |
subscription_already_active | Bu kişinin bu pakette zaten etkin bir aboneliği var. |
Yayımladığı olaylar: subscriptions.started, subscriptions.period_started
Neye yazar: subscription (insert) — Starts the subscription; subscription_period (insert) — Opens the first period
Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde subscriptions:write izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 409 package_not_found, subscription_already_active · 429 çok sık istek
subscriptions.cancel
İptal et — Şimdi ya da ödenmiş dönemin sonunda bitirir.
Gereken izin subscriptions:write · siler ya da geri alınamaz · Era çalıştırırken bir kişiye onaylatır
https://app.getera.io/api/v1/subscriptions/{id}/actions/cancel- Asıl adres:
POST /api/v1/actions/subscriptions.cancel
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
id | uuid | evet | Doldurulduğu yer: adresteki {id} · Abonelik · kimliği: subscription |
atPeriodEnd | boolean | Bu dönemin sonunda | |
reason | string | Neden · en çok 2000 |
Ön koşullar
Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:
| Kod | Ne zaman reddedilir |
|---|---|
subscription_not_found | Abonelik bulunmalı. |
subscription_already_ended | Bitmiş bir abonelik yeniden iptal edilmez. |
Yayımladığı olaylar: subscriptions.cancelled
Neye yazar: subscription (update) — Cancels it; subscription_period (update) — Cancels a period that has not started
curl -X POST https://app.getera.io/api/v1/subscriptions/SUBSCRIPTION_ID/actions/cancel \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"atPeriodEnd":true}'{
"ok": true,
"result": "…",
"events": [
"subscriptions.cancelled"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.subscriptions.cancel("SUBSCRIPTION_ID", {
atPeriodEnd: true
})era subscriptions cancel SUBSCRIPTION_ID \
--at-period-end true{
"name": "era__subscriptions__cancel",
"arguments": {
"id": "SUBSCRIPTION_ID",
"atPeriodEnd": true
}
}Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde subscriptions:write izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 409 subscription_not_found, subscription_already_ended · 429 çok sık istek
subscriptions.pause
Duraklat — Aboneliği bitirmeden yenilemeleri durdurur.
Gereken izin subscriptions:write · veriyi değiştirir
https://app.getera.io/api/v1/subscriptions/{id}/actions/pause- Asıl adres:
POST /api/v1/actions/subscriptions.pause
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
id | uuid | evet | Doldurulduğu yer: adresteki {id} · Abonelik · kimliği: subscription |
Ön koşullar
Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:
| Kod | Ne zaman reddedilir |
|---|---|
subscription_not_found | Abonelik bulunmalı. |
subscription_not_active | Yalnızca aktif bir abonelik duraklatılır. |
Yayımladığı olaylar: subscriptions.paused
Neye yazar: subscription (update) — Pauses it
curl -X POST https://app.getera.io/api/v1/subscriptions/SUBSCRIPTION_ID/actions/pause \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{}'{
"ok": true,
"result": "…",
"events": [
"subscriptions.paused"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.subscriptions.pause("SUBSCRIPTION_ID")era subscriptions pause SUBSCRIPTION_ID{
"name": "era__subscriptions__pause",
"arguments": {
"id": "SUBSCRIPTION_ID"
}
}Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde subscriptions:write izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 409 subscription_not_found, subscription_not_active · 429 çok sık istek
subscriptions.raise_ending_notices
“Yakında bitiyor” bildirimlerini oluştur — Günlük iş: yenilenmeyecek ve süre içinde bitecek her abonelik dönem başına bir kez bildirilir.
Gereken izin subscriptions:write · veriyi değiştirir
403 machine_only).https://app.getera.io/api/v1/subscriptions/actions/raise_ending_notices- Asıl adres:
POST /api/v1/actions/subscriptions.raise_ending_notices
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
asOf | date | Geçerlilik tarihi |
Yayımladığı olaylar: subscriptions.ending_soon
Neye yazar: subscription (update) — Records that the ending notice was raised
Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde subscriptions:write izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 429 çok sık istek
subscriptions.renew
Şimdi yenile — Sonraki dönemi açar — ya da süresi veya iptali öyle diyorsa aboneliği bitirir.
Gereken izin subscriptions:write · veriyi değiştirir
https://app.getera.io/api/v1/subscriptions/{id}/actions/renew- Asıl adres:
POST /api/v1/actions/subscriptions.renew
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
id | uuid | evet | Doldurulduğu yer: adresteki {id} · Abonelik · kimliği: subscription |
Ön koşullar
Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:
| Kod | Ne zaman reddedilir |
|---|---|
subscription_not_found | Abonelik bulunmalı. |
subscription_not_renewable | Yalnızca aktif veya denemedeki bir abonelik yenilenir. |
Yayımladığı olaylar: subscriptions.renewed, subscriptions.period_started, subscriptions.cancelled, subscriptions.expired
Neye yazar: subscription (update) — Moves it onto the next period; subscription_period (insert) — Opens the period
curl -X POST https://app.getera.io/api/v1/subscriptions/SUBSCRIPTION_ID/actions/renew \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{}'{
"ok": true,
"result": "…",
"events": [
"subscriptions.renewed",
"subscriptions.period_started",
"subscriptions.cancelled",
"subscriptions.expired"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.subscriptions.renew("SUBSCRIPTION_ID")era subscriptions renew SUBSCRIPTION_ID{
"name": "era__subscriptions__renew",
"arguments": {
"id": "SUBSCRIPTION_ID"
}
}Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde subscriptions:write izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 409 subscription_not_found, subscription_not_renewable · 429 çok sık istek
subscriptions.renew_due
Yenileme zamanı gelenleri yenile — Yenileme tarihi gelen her otomatik aboneliği yeniler.
Gereken izin subscriptions:manage · veriyi değiştirir
https://app.getera.io/api/v1/subscription_periods/actions/renew_due- Asıl adres:
POST /api/v1/actions/subscriptions.renew_due
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
asOf | date | Geçerlilik tarihi |
Yayımladığı olaylar: subscriptions.renewed, subscriptions.period_started, subscriptions.cancelled, subscriptions.expired
Neye yazar: subscription (update) — Moves each onto its next period; subscription_period (insert) — Opens the periods
curl -X POST https://app.getera.io/api/v1/subscription_periods/actions/renew_due \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"asOf":"2026-11-02"}'{
"ok": true,
"result": "…",
"events": [
"subscriptions.renewed",
"subscriptions.period_started",
"subscriptions.cancelled",
"subscriptions.expired"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.subscriptionPeriods.renewDue({
asOf: "2026-11-02"
})era subscription_periods renew_due \
--as-of "2026-11-02"{
"name": "era__subscriptions__renew_due",
"arguments": {
"asOf": "2026-11-02"
}
}Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde subscriptions:manage izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 429 çok sık istek
subscriptions.resume
Devam ettir — Duraklatılmış aboneliği yeniden başlatır; sonraki yenileme en erken bugündür.
Gereken izin subscriptions:write · veriyi değiştirir
https://app.getera.io/api/v1/subscriptions/{id}/actions/resume- Asıl adres:
POST /api/v1/actions/subscriptions.resume
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
id | uuid | evet | Doldurulduğu yer: adresteki {id} · Abonelik · kimliği: subscription |
Ön koşullar
Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:
| Kod | Ne zaman reddedilir |
|---|---|
subscription_not_found | Abonelik bulunmalı. |
subscription_not_paused | Yalnızca duraklatılmış bir abonelik devam ettirilir. |
Yayımladığı olaylar: subscriptions.resumed
Neye yazar: subscription (update) — Resumes it
curl -X POST https://app.getera.io/api/v1/subscriptions/SUBSCRIPTION_ID/actions/resume \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{}'{
"ok": true,
"result": "…",
"events": [
"subscriptions.resumed"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.subscriptions.resume("SUBSCRIPTION_ID")era subscriptions resume SUBSCRIPTION_ID{
"name": "era__subscriptions__resume",
"arguments": {
"id": "SUBSCRIPTION_ID"
}
}Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde subscriptions:write izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 409 subscription_not_found, subscription_not_paused · 429 çok sık istek
subscriptions.set_auto_renew
Yenileme — Dönem bittiğinde kendiliğinden yenilenip yenilenmeyeceği; yenilenmeyen abonelik günlük kontrolde sonlandırılır.
Gereken izin subscriptions:write · veriyi değiştirir
https://app.getera.io/api/v1/subscriptions/{id}/actions/set_auto_renew- Asıl adres:
POST /api/v1/actions/subscriptions.set_auto_renew
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
id | uuid | evet | Doldurulduğu yer: adresteki {id} · Abonelik · kimliği: subscription |
autoRenew | boolean | evet | Otomatik yenile |
Ön koşullar
Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:
| Kod | Ne zaman reddedilir |
|---|---|
subscription_not_found | Abonelik bulunmalı. |
subscription_already_ended | Bitmiş bir abonelik yenilenmez. |
Yayımladığı olaylar: subscriptions.auto_renew_changed
Neye yazar: subscription (update) — Sets auto_renew
curl -X POST https://app.getera.io/api/v1/subscriptions/SUBSCRIPTION_ID/actions/set_auto_renew \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"autoRenew":true}'{
"ok": true,
"result": "…",
"events": [
"subscriptions.auto_renew_changed"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.subscriptions.setAutoRenew("SUBSCRIPTION_ID", {
autoRenew: true
})era subscriptions set_auto_renew SUBSCRIPTION_ID \
--auto-renew true{
"name": "era__subscriptions__set_auto_renew",
"arguments": {
"id": "SUBSCRIPTION_ID",
"autoRenew": true
}
}Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde subscriptions:write izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 409 subscription_not_found, subscription_already_ended · 429 çok sık istek
subscriptions.start
Abonelik başlat — Sabitlenmiş fiyatla tekrarlayan bir dönem. İlk dönem şimdi ya da deneme bitince açılır.
Gereken izin subscriptions:write · veriyi değiştirir
https://app.getera.io/api/v1/subscriptions/actions/start- Asıl adres:
POST /api/v1/actions/subscriptions.start
Girdi
| Alan | Tür | Zorunlu | Açıklama |
|---|---|---|---|
customerId | uuid | evet | Abone · kimliği: customer |
name | string | evet | Plan · en çok 255 |
amount | number (money) | evet | Dönem başına fiyat |
currency | string | Para birimi · en çok 3 | |
billingCycle | string (enum) | Her · İzin verilen değerler: weekly, monthly, quarterly, yearly | |
startDate | date | Başlangıç | |
trialDays | number | Deneme günleri · en az 0 · en çok 365 | |
endDate | date | Bitiş | |
autoRenew | boolean | Otomatik yenilenir | |
itemModule | string | Ürünün modülü · en çok 40 | |
itemRecordId | uuid | Kalem | |
periodMonths | number | Dönem başına ay · Tam aylar hâlinde satılan bir plan (paket); dönem ayarının yerine geçer. · en az 1 · en çok 120 | |
notes | string | Notlar · en çok 4000 |
Ön koşullar
Koşul tutmazsa işlem 409 ve şu kodlardan biriyle reddedilir:
| Kod | Ne zaman reddedilir |
|---|---|
customer_not_found | Kişi bulunmalı. |
customer_archived | Arşivlenmiş bir kişi abone olamaz. |
invalid_currency | Para birimi bir ISO-4217 kodu olmalı. |
subscription_amount_not_positive | Aboneliğin bedeli sıfırdan büyüktür. |
subscription_already_active | Kişi ve plan başına tek geçerli abonelik. |
subscription_end_before_start | Dönem başlamadan bitemez. |
Yayımladığı olaylar: subscriptions.started, subscriptions.period_started
Neye yazar: subscription (insert) — Starts the subscription; subscription_period (insert) — Opens the first period
curl -X POST https://app.getera.io/api/v1/subscriptions/actions/start \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"customerId":"CUSTOMER_ID","name":"Plan","amount":1}'{
"ok": true,
"result": "…",
"events": [
"subscriptions.started",
"subscriptions.period_started"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.subscriptions.start({
customerId: "CUSTOMER_ID",
name: "Plan",
amount: 1
})era subscriptions start \
--customer-id "CUSTOMER_ID" \
--name "Plan" \
--amount 1{
"name": "era__subscriptions__start",
"arguments": {
"customerId": "CUSTOMER_ID",
"name": "Plan",
"amount": 1
}
}Hatalar: 401 kimlik bilgisi yok ya da süresi dolmuş · 403 kimlik bilgisinde subscriptions:write izni yok · 404 kayıt ya da modül erişim dışında · 422 geçersiz girdi (problems[]) · 409 customer_not_found, customer_archived, invalid_currency, subscription_amount_not_positive, subscription_already_active, subscription_end_before_start · 429 çok sık istek
Veri modelleri
SubscriptionPeriod
Tablo subscription_period · Kaynak subscription_periods
GET /api/v1/subscription_periodsGET /api/v1/subscription_periods/{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 | ||
subscription_id | string (uuid) · uuid | subscription | ||
sequence | integer · int4 | |||
period_start | string (date) · date | |||
period_end | string (date) · date | |||
currency | string · bpchar | en çok 3 | ||
amount | string (int64) · int8 | |||
status | string · text | current, completed, cancelled | ||
created_at | string (date-time) · timestamptz |
Birincil anahtar: id
Tekil: subscription_id, sequence
Denetimler:
CHECK ((amount >= 0))CHECK ((currency ~ '^[A-Z]{3}$'::text))CHECK ((period_end >= period_start))CHECK ((sequence > 0))
Subscription
Tablo subscription · Kaynak subscriptions
GET /api/v1/subscriptionsGET /api/v1/subscriptions/{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 | ||
customer_id | string (uuid) · uuid | customer | ||
name | string · text | |||
item_module | string · text | evet | ||
item_record_id | string (uuid) · uuid | evet | ||
status | string · text | trialing, active, paused, cancelled, expired | ||
billing_cycle | string · text | weekly, monthly, quarterly, yearly | ||
currency | string · bpchar | en çok 3 | ||
amount | string (int64) · int8 | |||
start_date | string (date) · date | |||
trial_ends_at | string (date) · date | evet | ||
end_date | string (date) · date | evet | ||
current_period_start | string (date) · date | evet | ||
current_period_end | string (date) · date | evet | ||
next_renewal_date | string (date) · date | evet | ||
auto_renew | boolean · bool | |||
cancel_at_period_end | boolean · bool | |||
cancelled_at | string (date-time) · timestamptz | evet | ||
cancel_reason | string · text | evet | ||
paused_at | string (date-time) · timestamptz | evet | ||
notes | string · text | evet | ||
created_by_user_id | string (uuid) · uuid | evet | app_user | |
created_at | string (date-time) · timestamptz | |||
updated_at | string (date-time) · timestamptz | |||
period_months | integer · int4 | evet | ||
renewals | integer · int4 | |||
ending_notice_at | string (date-time) · timestamptz | evet |
Birincil anahtar: id
Denetimler:
CHECK ((amount >= 0))CHECK ((currency ~ '^[A-Z]{3}$'::text))CHECK (((end_date IS NULL) OR (end_date >= start_date)))CHECK ((length(TRIM(BOTH FROM name)) > 0))CHECK (((period_months IS NULL) OR (period_months > 0)))CHECK ((renewals >= 0))
Olaylar
İş akışları ve webhook'lar bu olaylara tepki verir.
| Olay | Ne olur | Taşıdığı alanlar |
|---|---|---|
subscriptions.auto_renew_changed | Bir aboneliğin yenileme ayarı değişti. | id, autoRenew |
subscriptions.cancelled | Bir abonelik iptal edildi. | id, atPeriodEnd, customerId, itemModule |
subscriptions.ending_soon | Yenilenmeyecek bir abonelik yakında bitiyor. | id, customerId, customerName, name, endsOn, daysLeft, itemModule, itemRecordId |
subscriptions.expired | Süreli bir aboneliğin süresi doldu. | id, customerId, autoRenew, itemModule, itemRecordId |
subscriptions.paused | Bir abonelik duraklatıldı. | id |
subscriptions.period_started | Ücretli bir dönem başladı — finans sözleşmesini açar. | id, subscriptionId, customerId, name, sequence, periodStart, periodEnd, amount, currency, itemModule, itemRecordId |
subscriptions.renewed | Bir abonelik yenilendi. | id, count |
subscriptions.resumed | Bir abonelik sürdürüldü. | id |
subscriptions.started | Bir abonelik başladı. | id, customerId, trialEndsAt, name, startsOn, endsOn, itemModule, itemRecordId |