الانتقال إلى المحتوى الرئيسي
PATCH
/
workspaces
/
{workspaceId}
/
billing-accounts
/
{billingAccountId}
/
subscriptions
/
{subscriptionId}
تحديث اشتراك
curl --request PATCH \
  --url https://api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/subscriptions/{subscriptionId} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "action": "pause",
  "product_quantities": {
    "locations": 20,
    "users": 100
  },
  "add_products": {
    "sso": 1
  },
  "remove_products": [
    "sso"
  ],
  "metadata": {
    "project_id": "proj_def456"
  }
}'
{
  "id": "sub_a1b2c3d4e5f6g7h8",
  "billing_account_id": "cus_a1b2c3d4e5f6g7h8",
  "status": "active",
  "currency": "usd",
  "product_quantities": {
    "locations": {
      "price_id": "price_123abc",
      "quantity": 10,
      "interval": "month"
    },
    "users": {
      "price_id": "price_456def",
      "quantity": 50,
      "interval": "month"
    }
  },
  "metadata": {
    "order_id": "6735"
  },
  "current_period_start": "2025-10-15T00:00:00Z",
  "current_period_end": "2025-11-15T00:00:00Z",
  "created_at": "2025-10-15T12:30:00Z",
  "updated_at": "2025-10-20T09:00:00Z"
}

Authorizations

Authorization
string
header
required

أدخل JWT الخاص بك بالتنسيق: Bearer {token}

Path Parameters

workspaceId
string
required

معرّف مساحة العمل.

Example:

"ws_a1b2c3d4e5f6g7h8"

billingAccountId
string
required

معرّف حساب الفوترة، والذي يتوافق مع معرّف عميل Stripe (cus_...).

Example:

"cus_a1b2c3d4e5f6g7h8"

subscriptionId
string
required

معرّف اشتراك Stripe (sub_...).

Example:

"sub_a1b2c3d4e5f6g7h8"

Body

application/json

حدد إحدى العمليات التالية: action, product_quantities, add_products, أو remove_products. يمكن دمج metadata مع product_quantities.

action
enum<string>

تنفيذ إجراء تغيير حالة على الاشتراك.

الخيارات المتاحة:
pause,
resume,
sync
product_quantities
object

استبدال جميع كميات المنتجات الحالية بهذه المجموعة الجديدة. لإزالة منتج، احذفه من هذا الكائن. الكمية 0 غير مسموح بها؛ احذف المفتاح للإزالة.

Example:
{ "locations": 20, "users": 100 }
add_products
object

إضافة منتجات جديدة إلى الاشتراك أو زيادة كمية المنتجات الحالية.

Example:
{ "sso": 1 }
remove_products
enum<string>[]

قائمة بأنواع المنتجات التي سيتم إزالتها من الاشتراك.

Example:
["sso"]
metadata
object

مجموعة من أزواج المفاتيح والقيم لتخزينها مع الاشتراك. سيتم دمجها مع البيانات الوصفية الحالية.

Example:
{ "project_id": "proj_def456" }

Response

تم تحديث الاشتراك بنجاح.

id
string

معرّف فريد للاشتراك (معرّف اشتراك Stripe)، يبدأ بالبادئة sub_.

Example:

"sub_a1b2c3d4e5f6g7h8"

billing_account_id
string

معرّف حساب الفوترة الذي ينتمي إليه هذا الاشتراك.

Example:

"cus_a1b2c3d4e5f6g7h8"

status
enum<string>

حالة الاشتراك.

الخيارات المتاحة:
active,
past_due,
unpaid,
canceled,
incomplete,
incomplete_expired,
trialing,
paused
Example:

"active"

currency
enum<string>

رمز العملة ISO المكون من ثلاثة أحرف للاشتراك.

الخيارات المتاحة:
usd,
zar,
eur,
gbp,
aud
Example:

"usd"

product_quantities
object

خريطة لأنواع المنتجات القابلة للقياس وكمياتها المشترك بها وتفاصيل أسعارها.

Example:
{
"locations": {
"price_id": "price_123abc",
"quantity": 10,
"interval": "month"
},
"users": {
"price_id": "price_456def",
"quantity": 50,
"interval": "month"
}
}
metadata
object

مجموعة من أزواج المفاتيح والقيم التي يمكنك إرفاقها بكائن.

Example:
{ "order_id": "6735" }
current_period_start
string<date-time> | null

بداية فترة الفوترة الحالية.

Example:

"2025-10-15T00:00:00Z"

current_period_end
string<date-time> | null

نهاية فترة الفوترة الحالية.

Example:

"2025-11-15T00:00:00Z"

created_at
string<date-time> | null

الطابع الزمني لإنشاء الاشتراك.

Example:

"2025-10-15T12:30:00Z"

updated_at
string<date-time> | null

الطابع الزمني لآخر تحديث للاشتراك في نظامنا.

Example:

"2025-10-20T09:00:00Z"