# कम्युनिटी कमेंट बनाएँ

कैनोनिकल URL: https://sosoapi.ai/hi/docs/api/community-engagement-api-comments-create

कॉन्ट्रैक्ट: sha256:563d2d581da0ad29

कैनोनिकल पोस्ट या कमेंट लक्ष्य पर एक निश्चित कमेंट कतार में डालें; स्थिति प्रोवाइडर की सफलता का प्रमाण नहीं है।

POST /community-engagement-api/comments/create

## प्रमाणीकरण और अनुमतियाँ

- **स्वीकार्य क्रेडेंशियल श्रेणियाँ:** user_session, delegated_oauth, personal_access_token

- **प्रत्यायोजित क्षमता:** agent:engage

- **न्यूनतम वर्कस्पेस भूमिका:** editor

- **एक्सेस का दायरा:** वे संसाधन जिनके एक्सेस के लिए यह यूज़र अधिकृत है

- **सभी वर्कस्पेस के लिए सहमति आवश्यक:** नहीं

- **स्थिति बदलता है:** हाँ

- **ऑपरेशन पूरा होने पर:** terminal provider receipt

टोकन केवल मालिक के अधिकार इस्तेमाल कर सकता है। हर अनुरोध वर्कस्पेस सदस्यता, संसाधन स्वामित्व, चुने वर्कस्पेस और दी क्षमताएँ जाँचता है। Core और full प्रोफ़ाइल दिखने वाले टूल बदलते हैं; एक्सेस नहीं देते।

## अनुरोध के फ़ील्ड

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "workspace_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)$"
    },
    "social_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)$"
    },
    "target": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "post"
            },
            "social_post_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)$"
            }
          },
          "required": [
            "kind",
            "social_post_id"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "comment"
            },
            "social_comment_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)$"
            }
          },
          "required": [
            "kind",
            "social_comment_id"
          ],
          "additionalProperties": false
        }
      ]
    },
    "message": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2000
    },
    "idempotency_key": {
      "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)$"
    }
  },
  "required": [
    "workspace_id",
    "social_account_id",
    "target",
    "message",
    "idempotency_key"
  ],
  "additionalProperties": false
}
```

## रिस्पॉन्स और पूर्णता

सफल HTTP स्टेटस: 200, 202

सफल HTTP रिस्पॉन्स का अर्थ अनुरोध पूरा होने के बजाय स्वीकार होना हो सकता है। बैकग्राउंड काम में लौटाई ID सहेजें और समाप्ति तक वही ऑपरेशन जाँचें। निर्धारित या स्वीकृत पोस्ट प्लेटफ़ॉर्म की पुष्टि पर ही प्रकाशित है; क्लाइंट टाइमआउट परिणाम सिद्ध नहीं करता।

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "contract_version": {
      "type": "string",
      "const": "community-engagement/v1"
    },
    "replayed": {
      "type": "boolean"
    },
    "action": {
      "type": "object",
      "properties": {
        "action_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)$"
        },
        "workspace_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)$"
        },
        "social_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)$"
        },
        "target": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "const": "post"
                },
                "social_post_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)$"
                }
              },
              "required": [
                "kind",
                "social_post_id"
              ]
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "const": "comment"
                },
                "social_post_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)$"
                },
                "social_comment_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)$"
                }
              },
              "required": [
                "kind",
                "social_post_id",
                "social_comment_id"
              ]
            }
          ]
        },
        "content_sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "idempotency_key": {
          "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)$"
        },
        "status": {
          "type": "string",
          "enum": [
            "queued",
            "executing",
            "succeeded",
            "attention",
            "failed"
          ]
        },
        "poll_after_ms": {
          "type": "integer",
          "minimum": 0,
          "maximum": 300000
        }
      },
      "required": [
        "action_id",
        "workspace_id",
        "social_account_id",
        "target",
        "content_sha256",
        "idempotency_key",
        "status",
        "poll_after_ms"
      ]
    }
  },
  "required": [
    "contract_version",
    "replayed",
    "action"
  ]
}
```

## त्रुटियाँ और सुरक्षित पुनः प्रयास

HTTP स्टेटस और रिस्पॉन्स बॉडी जाँचें। 400 वैलिडेशन त्रुटि में ZodError हो सकता है; हैंडलर त्रुटियाँ error, message और code फ़ील्ड इस्तेमाल करती हैं। जाँच के लिए request_id या x-request-id रखें, क्रेडेंशियल के बिना। फिर प्रयास से पहले 401/403 एक्सेस त्रुटियाँ ठीक करें और 429 के लिए Retry-After का पालन करें। राइट अनिश्चित हो या 5xx लौटाए, तो पहले मौजूदा परिणाम पढ़ें। idempotency key केवल समर्थित स्थान पर दोबारा इस्तेमाल करें; पुनः प्रयास का व्यवहार ऑपरेशन के अनुसार बदलता है और ठीक एक बार डिलीवरी की गारंटी नहीं देता।

## उदाहरण

उदाहरणों में स्कीमा से जाँचे काल्पनिक मान हैं। IDs को अधिकृत IDs, मीडिया को तैयार एसेट और तारीखों को पुष्ट प्रकाशन समय से बदलें। राइट सबमिट करने से पहले खाते की पात्रता जाँचें। यह पेज API अनुरोध नहीं भेजता।

सर्वर पर SOSOAPI_ACCESS_TOKEN को इस ऑपरेशन के स्वीकार्य क्रेडेंशियल से सेट करें और ब्राउज़र कोड से बाहर रखें। एजेंट के लिए sosoapi auth login से ब्राउज़र साइन-इन करें और CLI को क्रेडेंशियल रिफ़्रेश करने दें।

request.json

```json
{
  "workspace_id": "11111111-1111-4111-8111-111111111111",
  "social_account_id": "11111111-1111-4111-8111-111111111111",
  "target": {
    "kind": "post",
    "social_post_id": "11111111-1111-4111-8111-111111111111"
  },
  "message": "example",
  "idempotency_key": "11111111-1111-4111-8111-111111111111"
}
```

cURL

```bash
curl --request POST \
  "https://gqeshlawtcexsapabaui.supabase.co/functions/v1/community-engagement-api/comments/create" \
  -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/community-engagement-api/comments/create", {
  method: "POST",
  headers: { "Content-Type": "application/json", Authorization: "Bearer " + token },
  body: JSON.stringify({
  "workspace_id": "11111111-1111-4111-8111-111111111111",
  "social_account_id": "11111111-1111-4111-8111-111111111111",
  "target": {
    "kind": "post",
    "social_post_id": "11111111-1111-4111-8111-111111111111"
  },
  "message": "example",
  "idempotency_key": "11111111-1111-4111-8111-111111111111"
})
});
const result = await response.json();
// Check response.ok, the operation-specific body and completion state before continuing.
```

CLI

```bash
npx sosoapi api post /community-engagement-api/comments/create < request.json
```

कृत्रिम रिस्पॉन्स का उदाहरण

```json
{
  "contract_version": "community-engagement/v1",
  "replayed": false,
  "action": {
    "action_id": "11111111-1111-4111-8111-111111111111",
    "workspace_id": "11111111-1111-4111-8111-111111111111",
    "social_account_id": "11111111-1111-4111-8111-111111111111",
    "target": {
      "kind": "post",
      "social_post_id": "11111111-1111-4111-8111-111111111111"
    },
    "content_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "idempotency_key": "11111111-1111-4111-8111-111111111111",
    "status": "queued",
    "poll_after_ms": 0
  }
}
```

## संबंधित टूल और गाइड

MCP: sosoapi_create_comment

[API संदर्भ](https://sosoapi.ai/hi/docs/api)
