سنوقف ميزة "الرسائل التجارية من Google" نهائيًا في 31 يوليو 2024. يمكنك الاطّلاع على مزيد من المعلومات
هنا.
OpenAPI
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
OpenAPI هي واجهة
مواصفات وصف واجهات برمجة تطبيقات REST. استخدام
الإصدار 2.0 من مواصفات OpenAPI
يمكنك إنشاء مستندات OpenAPI الخاصة بميزة "الرسائل التجارية" و"الرسائل التجارية"
واجهات برمجة التطبيقات للاتصالات لوصف بنيتها.
ويسمح لك هذا الإجراء بما يلي:
- إنشاء مكتبات العملاء بلغتك المفضّلة
- إنشاء رموز بديلة للخادم
- استخدام أدوات إدارة واجهة برمجة التطبيقات
البنية الأساسية لمستند OpenAPI
يصف مستند OpenAPI سطح واجهة برمجة تطبيقات REST. يحدد المستند
اسم ووصف واجهة برمجة التطبيقات، ونقاط النهاية الفردية (المسارات) في
واجهة برمجة التطبيقات وكيفية مصادقة المتصلين والمزيد.
انقر أدناه لعرض مثال لهذه البنية الأساسية.
JSON
{
"swagger": "2.0",
"host": "businessmessages.googleapis.com",
"info": {
"title": "Business Messages API",
"description": "",
"version": "v1"
},
"paths": {
"/v1/conversations/{conversationsId}/messages": {
"post": {
"description": "Sends a message from an agent to a user.",
"parameters": [
{
"description": "Part of `parent`. Required. The conversation that contains the message. Resolves to \"conversations/{conversationId}\".",
"type": "string",
"in": "path",
"required": true,
"name": "conversationsId"
},
{
"description": "Optional. A flag to send the specified fallback text instead of other message content.",
"name": "forceFallback",
"type": "boolean",
"in": "query"
},
{
"name": "message",
"schema": {
"$ref": "#/definitions/BusinessMessagesMessage"
},
"in": "body",
"description": "Required. The content of a message."
}
],
"tags": [
"businessmessages"
],
"operationId": "CreateMessage",
"responses": {
"default": {
"schema": {
"$ref": "#/definitions/BusinessMessagesMessage"
},
"description": "Successful operation"
}
}
}
}
}
}
لمعرفة المزيد عن بنية مستند OpenAPI، يمكنك الاطلاع على
موقع Swagger الإلكتروني.
كيفية الوصول إلى مستندات OpenAPI
للوصول إلى مستندات OpenAPI، يجب أن يكون لديك مفتاح واجهة برمجة تطبيقات من Google Cloud.
مشروع المنصة (GCP) مع ميزة "الرسائل التجارية" و"اتصالات النشاط التجاري"
تم تفعيل واجهات برمجة التطبيقات.
اتّبِع الأقسام التالية من أجل:
- إنشاء مشروع Google Cloud Platform
- إنشاء مفتاح واجهة برمجة التطبيقات
- تفعيل Business Message API وBusiness Communications API
بعد إكمال هذه الخطوات، يمكنك الوصول إلى مستندات OpenAPI.
إنشاء مشروع Google Cloud Platform
إذا كان لديك مشروع Google Cloud Platform من قبل، يمكنك استخدامه من أجل إنشاء مفتاح واجهة برمجة تطبيقات.
لإنشاء مشروع Google Cloud Platform جديد، اتّبِع الخطوات التالية:
- انتقِل إلى صفحة إدارة الموارد.
صفحة في وحدة تحكُّم Google Cloud Platform.
- في القائمة المنسدلة اختيار مؤسسة في أعلى الصفحة،
حدد المؤسسة التي تريد إنشاء المشروع لها.
إذا كنت تستخدم الفترة التجريبية المجانية، يمكنك تخطّي هذه الخطوة.
- انقر على إنشاء مشروع.
- في نافذة مشروع جديد، أدخِل اسم مشروع واختَر
حساب الفوترة حسب الاقتضاء. لا يمكن أن يحتوي اسم المشروع إلا على أحرف أو أرقام أو فردية
علامات الاقتباس أو الواصلات أو المسافات أو علامات التعجب، ويجب أن يتراوح طولها بين 4 أحرف و30 حرفًا.
في حقل الموقع الجغرافي، أدخِل المؤسسة أو المجلد الرئيسي للمشروع الجديد.
انقر على إنشاء.
إنشاء مفتاح واجهة برمجة التطبيقات
الانتقال إلى
صفحة بيانات الاعتماد
في وحدة تحكُّم Google Cloud Platform.
انقر على إنشاء بيانات اعتماد، ثم اختَر مفتاح واجهة برمجة التطبيقات.
يعرض مربّع الحوار تم إنشاء مفتاح واجهة برمجة التطبيقات المفتاح الذي تم إنشاؤه حديثًا.
انسخ مفتاحك وحافِظ على أمانه. لمزيد من المعلومات حول مفاتيح واجهة برمجة التطبيقات، يُرجى الاطّلاع على
المستندات حول مفتاح واجهة برمجة التطبيقات:
تفعيل Business Communications API وBusiness Message API
لتفعيل واجهات برمجة التطبيقات هذه في مشروع Google Cloud Platform، عليك إجراء ما يلي:
- انتقِل إلى واجهات برمجة التطبيقات الخدمات في وحدة تحكُّم Google Cloud Platform.
- في القائمة المنسدلة اختيار مشروع، اختَر
المشروع الذي تريد تفعيل واجهات برمجة التطبيقات له.
- انقر على تفعيل واجهات برمجة التطبيقات والخدمات.
- في الحقل البحث عن واجهات برمجة التطبيقات والخدمات، أدخِل الرسائل التجارية.
- اختَر واجهة برمجة تطبيقات ميزة "الرسائل التجارية".
- انقر على تفعيل.
- انقر على تفعيل واجهات برمجة التطبيقات والخدمات.
- في الحقل البحث عن واجهات برمجة التطبيقات والخدمات، أدخِل Business Communications.
- اختَر Business Communications API.
- انقر على تفعيل.
أصبح لدى مفتاح واجهة برمجة التطبيقات الآن أذونات للوصول إلى مستندات OpenAPI
واجهات برمجة تطبيقات "الرسائل التجارية" و"مراسلات النشاط التجاري"
الوصول إلى مستندات OpenAPI
شغِّل الأمر التالي للوصول إلى مستند OpenAPI الخاص بواجهة برمجة تطبيقات "الرسائل التجارية":
curl "https://businessmessages.googleapis.com/$discovery/swagger2?version=v1&key=API_KEY"
شغِّل هذا الأمر للوصول إلى مستند OpenAPI الخاص بواجهة Business Communications API:
curl "https://businesscommunications.googleapis.com/$discovery/swagger2?version=v1&key=API_KEY"
استبدِل API_KEY بمفتاح واجهة برمجة التطبيقات الخاص بك.
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-25 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-25 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eOpenAPI specification enables creation of descriptive documents for Business Messages and Business Communications APIs, facilitating client library and server stub development and API management tool usage.\u003c/p\u003e\n"],["\u003cp\u003eOpenAPI documents outline the structure of a REST API, including its name, endpoints, authentication methods, and other details.\u003c/p\u003e\n"],["\u003cp\u003eAccessing OpenAPI documents requires an API key from a Google Cloud Platform (GCP) project with the Business Messages and Business Communications APIs enabled.\u003c/p\u003e\n"],["\u003cp\u003eUsers need to create a GCP project, generate an API key, and enable both Business Messages and Business Communications APIs within the project for document access.\u003c/p\u003e\n"],["\u003cp\u003eOpenAPI documents for both APIs can be retrieved using specific curl commands with the user's API key.\u003c/p\u003e\n"]]],[],null,["# OpenAPI\n\n[OpenAPI](https://swagger.io/docs/specification/about/) is a\nspecification for describing REST APIs. Using\n[OpenAPI specification 2.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md),\nyou can create OpenAPI documents for the Business Messages and Business\nCommunications APIs to describe their structure.\n\nThis allows you to do the following:\n\n- Create client libraries in your preferred language\n- Create server stubs\n- Use API management tools\n\nBasic structure of an OpenAPI document\n--------------------------------------\n\nAn OpenAPI document describes the surface of a REST API. The document defines\nthe name and description of the API, the individual endpoints (paths) in the\nAPI, how the callers are authenticated, and more.\n\nClick below to see an example of this basic structure. \n\n#### JSON\n\n```mysql\n {\n \"swagger\": \"2.0\",\n \"host\": \"businessmessages.googleapis.com\",\n \"info\": {\n \"title\": \"Business Messages API\",\n \"description\": \"\",\n \"version\": \"v1\"\n },\n \"paths\": {\n \"/v1/conversations/{conversationsId}/messages\": {\n \"post\": {\n \"description\": \"Sends a message from an agent to a user.\",\n \"parameters\": [\n {\n \"description\": \"Part of `parent`. Required. The conversation that contains the message. Resolves to \\\"conversations/{conversationId}\\\".\",\n \"type\": \"string\",\n \"in\": \"path\",\n \"required\": true,\n \"name\": \"conversationsId\"\n },\n {\n \"description\": \"Optional. A flag to send the specified fallback text instead of other message content.\",\n \"name\": \"forceFallback\",\n \"type\": \"boolean\",\n \"in\": \"query\"\n },\n {\n \"name\": \"message\",\n \"schema\": {\n \"$ref\": \"#/definitions/BusinessMessagesMessage\"\n },\n \"in\": \"body\",\n \"description\": \"Required. The content of a message.\"\n }\n ],\n \"tags\": [\n \"businessmessages\"\n ],\n \"operationId\": \"CreateMessage\",\n \"responses\": {\n \"default\": {\n \"schema\": {\n \"$ref\": \"#/definitions/BusinessMessagesMessage\"\n },\n \"description\": \"Successful operation\"\n }\n }\n }\n }\n }\n }\n \n```\n\nTo learn more about the structure of an OpenAPI document, see the\n[Swagger website](https://swagger.io/docs/specification/2-0/basic-structure/).\n\nHow to access the OpenAPI documents\n-----------------------------------\n\nTo access the OpenAPI documents, you must have an API key from a Google Cloud\nPlatform (GCP) project with the Business Messages and Business Communications\nAPIs enabled.\n\nFollow the sections below to\n\n- create a GCP project\n- create an API key\n- enable the Business Messages API and Business Communications API\n\nWith these steps completed, you can [access the OpenAPI documents](#access_the_openapi_documents).\n\n### Create a GCP project\n\nIf you already have a GCP project, you can use it to [create an API key](#create_an_api_key).\n\nTo create a new GCP project, do the following:\n\n1. Navigate to the [Manage resources](https://console.cloud.google.com/cloud-resource-manager) page in the GCP console.\n2. In the **Select organization** drop-down list at the top of the page, select the organization that you want to create the project for. If you are a free-trial user, skip this step.\n3. Click **Create Project**.\n4. In the **New Project** window, enter a project name and select a billing account as applicable. A project name can contain only letters, numbers, single quotes, hyphens, spaces, or exclamation points, and must be between 4 and 30 characters.\n5. For **Location**, enter the parent organization or folder for the new project.\n\n6. Click **Create**.\n\n### Create an API key\n\n1. Navigate to the\n [Credentials page](https://console.cloud.google.com/apis/credentials)\n in the GCP console.\n\n2. Click **Create credentials** , then select **API key**.\n\n The **API key created** dialog box displays your newly created key.\n Copy your key and keep it secure. To learn more about API keys, see the\n [API key documentation](https://cloud.google.com/api-keys/docs).\n\n### Enable the Business Communications API and Business Messages API\n\nTo enable these APIs in your GCP project, do the following:\n\n1. Go to the [APIs \\& Services](https://console.cloud.google.com/apis) page in the GCP console.\n2. In the **Select project** drop-down list, select the project you want to enable the APIs for.\n3. Click **Enable APIs and Services**.\n4. In the **Search for APIs and Services** field, enter **Business Messages**.\n5. Select **Business Messages API**.\n6. Click **Enable**.\n7. Click **Enable APIs and Services**.\n8. In the **Search for APIs and Services** field, enter **Business Communications**.\n9. Select **Business Communications API**.\n10. Click **Enable**.\n\nNow your API key has permissions to access the OpenAPI documents for the\nBusiness Messages and Business Communications APIs.\n\n### Access the OpenAPI documents\n\nRun this command to access the OpenAPI document for the Business Messages API: \n\n```scdoc\ncurl \"https://businessmessages.googleapis.com/$discovery/swagger2?version=v1&key=API_KEY\"\n```\n\n\u003cbr /\u003e\n\nRun this command to access the OpenAPI document for the Business Communications API: \n\n```scdoc\ncurl \"https://businesscommunications.googleapis.com/$discovery/swagger2?version=v1&key=API_KEY\"\n```\n\n\u003cbr /\u003e\n\nReplace the \u003cvar translate=\"no\"\u003eAPI_KEY\u003c/var\u003e with your API key."]]