# קבלת מצב חיוב

כתובת URL קנונית: https://sosoapi.ai/he/docs/api/identity-api-billing-status

Contract: sha256:563d2d581da0ad29

קריאת מסלול החיוב, מצב התשלום, תאריכי המחזור הנוכחי וניצול המכסות של המשתמש (פרסומים מוצלחים, פוסטים מתוזמנים ממתינים, חשבונות מחוברים). בדקו לפני סבבי תזמון גדולים.

POST /identity-api/billing/status

## אימות והרשאות

- **סוגי אמצעי גישה מתקבלים:** user_session, delegated_oauth, personal_access_token

- **יכולת מואצלת:** agent:operate

- **תפקיד מינימלי בסביבת העבודה:** בחוזה הזה אין תפקיד מינימלי בסביבת העבודה; בדיקות בעלות והרשאות עדיין חלות.

- **היקף הגישה:** משאבים שהמשתמש הזה מורשה לגשת אליהם

- **נדרשת הסכמה לכל סביבות העבודה:** לא

- **משנה מצב:** לא

- **מתי הפעולה הושלמה:** synchronous_http_response

אסימון יכול להשתמש רק בזכויות שיש לבעליו. כל בקשה בודקת חברות בסביבת העבודה, בעלות על משאבים, סביבות עבודה נבחרות ויכולות שהוענקו. הפרופילים core ו-full משנים אילו כלים מוצגים; הם אינם מעניקים גישה.

## שדות הבקשה

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {},
  "additionalProperties": false
}
```

## תגובה והשלמה

סטטוסי HTTP להצלחה: 200

תגובת HTTP מוצלחת עשויה לציין שבקשה התקבלה, ולא שהושלמה. בעבודת רקע, שמרו את המזהה שהוחזר ובדקו את אותה פעולה עד שתסתיים. פוסט שתוזמן או התקבל נחשב שפורסם רק כשהפלטפורמה מאשרת זאת; חריגה מזמן ההמתנה אצל הלקוח אינה קובעת מה התוצאה.

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "billing_account_id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "plan_key": {
      "type": "string",
      "enum": [
        "free",
        "founding_pro"
      ]
    },
    "plan_version": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    },
    "payment_state": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64
    },
    "entitlement_source": {
      "type": "string",
      "enum": [
        "default",
        "stripe",
        "internal_test",
        "reconciliation",
        "manual"
      ]
    },
    "has_stripe_customer": {
      "type": "boolean"
    },
    "checkout_enabled": {
      "type": "boolean"
    },
    "cycle": {
      "type": "object",
      "properties": {
        "period_start": {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
        },
        "period_end": {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
        },
        "reset_at": {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
        }
      },
      "required": [
        "period_start",
        "period_end",
        "reset_at"
      ]
    },
    "quota": {
      "type": "object",
      "properties": {
        "successful_destination_publishes": {
          "type": "object",
          "properties": {
            "limit": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "reserved": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "consumed": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "remaining": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "limit",
            "reserved",
            "consumed",
            "remaining"
          ]
        },
        "pending_scheduled_posts": {
          "type": "object",
          "properties": {
            "limit": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "active": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "remaining": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "limit",
            "active",
            "remaining"
          ]
        },
        "connected_social_accounts": {
          "type": "object",
          "properties": {
            "limit": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "active": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "remaining": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "limit",
            "active",
            "remaining"
          ]
        }
      },
      "required": [
        "successful_destination_publishes",
        "pending_scheduled_posts",
        "connected_social_accounts"
      ]
    },
    "history_days": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    },
    "capabilities": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {}
    }
  },
  "required": [
    "billing_account_id",
    "plan_key",
    "plan_version",
    "payment_state",
    "entitlement_source",
    "has_stripe_customer",
    "checkout_enabled",
    "cycle",
    "quota",
    "history_days",
    "capabilities"
  ]
}
```

## שגיאות וניסיונות חוזרים בטוחים

בדקו את סטטוס ה-HTTP ואת גוף התגובה. שגיאת אימות 400 עשויה להכיל ZodError; שגיאות מטפל משתמשות בשדות error, ‏message ו-code. שמרו request_id או x-request-id לאבחון, ללא אמצעי גישה. תקנו שגיאות גישה 401/403 לפני ניסיון חוזר, ופעלו לפי Retry-After עבור 429. אם תוצאת כתיבה אינה ודאית או שמוחזר 5xx, קראו תחילה את התוצאה הקיימת. השתמשו שוב במפתח אידמפוטנטיות רק במקומות הנתמכים; התנהגות הניסיון החוזר משתנה בין פעולות ואינה מבטיחה מסירה בדיוק פעם אחת.

## דוגמאות

הדוגמאות משתמשות בערכים בדויים שנבדקו מול הסכמות. החליפו את המזהים בכאלה שאתם מורשים להשתמש בהם, את המדיה בנכסים מוכנים ואת התאריכים במועד הפרסום שאישרתם. בדקו את התאמת החשבון לפני שליחת כתיבה. העמוד הזה אינו שולח בקשות API.

הגדירו בשרת שלכם SOSOAPI_ACCESS_TOKEN לאמצעי גישה שהפעולה הזו מקבלת, והשאירו אותו מחוץ לקוד הדפדפן. עבור סוכן, השתמשו ב-sosoapi auth login כדי להיכנס דרך הדפדפן ולאפשר ל-CLI לרענן את אמצעי הגישה שלו.

request.json

```json
{}
```

cURL

```bash
curl --request POST \
  "https://gqeshlawtcexsapabaui.supabase.co/functions/v1/identity-api/billing/status" \
  -H "Authorization: Bearer $SOSOAPI_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  --data-binary @request.json
```

JavaScript

```js
// Server-side JavaScript. Do not print tokens or credential-bearing responses.
const token = process.env.SOSOAPI_ACCESS_TOKEN;
if (!token) throw new Error("Set an accepted credential for this operation");
const response = await fetch("https://gqeshlawtcexsapabaui.supabase.co/functions/v1/identity-api/billing/status", {
  method: "POST",
  headers: { "Content-Type": "application/json", Authorization: "Bearer " + token },
  body: JSON.stringify({})
});
const result = await response.json();
// Check response.ok, the operation-specific body and completion state before continuing.
```

CLI

```bash
npx sosoapi api post /identity-api/billing/status < request.json
```

דוגמת תגובה סינתטית

```json
{
  "billing_account_id": "11111111-1111-4111-8111-111111111111",
  "plan_key": "free",
  "plan_version": 1,
  "payment_state": "example",
  "entitlement_source": "default",
  "has_stripe_customer": false,
  "checkout_enabled": false,
  "cycle": {
    "period_start": "2099-01-15T09:00:00Z",
    "period_end": "2099-01-15T09:00:00Z",
    "reset_at": "2099-01-15T09:00:00Z"
  },
  "quota": {
    "successful_destination_publishes": {
      "limit": 0,
      "reserved": 0,
      "consumed": 0,
      "remaining": 0
    },
    "pending_scheduled_posts": {
      "limit": 0,
      "active": 0,
      "remaining": 0
    },
    "connected_social_accounts": {
      "limit": 0,
      "active": 0,
      "remaining": 0
    }
  },
  "history_days": 1,
  "capabilities": {}
}
```

## כלים ומדריכים קשורים

MCP: sosoapi_get_billing_status

[תיעוד API](https://sosoapi.ai/he/docs/api)
