"description": "# Send Message with a published post\n\nTo send a message that contains an app user's Instagram post, send a `POST` request to the `//messages` endpoint with the `recipient` parameter containing the Instagram-scoped ID () and the `message` parameter containing an `attachment` object with the `type` set to `MEDIA_SHARE` and `payload` containing the Meta ID for the post.\n\nThe app user must own the post to be used in the message. Learn how to \n\n[Learn how to fetch the media owned by the business.](https://developers.facebook.com/docs/instagram/platform/instagram-api/get-started#get-the-instagram-professional-account-s-media-objects)\n\n## HTTP Method\n\n`POST`\n\n## Endpoint\n\n`https://graph.instagram.com/{{api_version}}/{{ig_user_id}}/messages`\n\n## Request Parameters\n\n### Body\n\nThe request body must be in JSON format and includes the following parameters:\n\n- **recipient** (object): This object specifies the recipient of the message.\n \n - **id** (string): The unique identifier of the recipient (Instagram user) to whom the message will be sent. This should be the `{{ig_scoped_id}}`.\n \n- **message** (object): This object contains the message details.\n \n - **attachment** (object): This object specifies the type of attachment included in the message.\n \n - **type** (string): The type of the attachment. For this request, it should be set to `\"MEDIA_SHARE\"`.\n \n - **payload** (object): This object contains the details of the attachment.\n \n - **id** (string): The unique identifier of the media post being shared. This should be the `{{post_id}}`.\n \n\n### Example Request Body\n\n``` json\n{\n \"recipient\": {\n \"id\": \"{{ig_scoped_id}}\"\n },\n \"message\": {\n \"attachment\": {\n \"type\": \"MEDIA_SHARE\",\n \"payload\": {\n \"id\": \"{{post_id}}\"\n }\n }\n }\n}\n\n ```\n\n## Expected Response\n\nUpon a successful request, the API will return a response with the following structure:\n\n- **recipient_id** (string): The ID of the recipient to whom the message was sent.\n \n- **message_id** (string): The ID of the sent message.\n \n\n### Example Response\n\n``` json\n{\n \"recipient_id\": \"{{ig_scoped_id}}\",\n \"message_id\": \"\"\n}\n\n ```\n\n## Notes\n\n- Ensure that the `{{api_version}}`, `{{ig_user_id}}`, `{{ig_scoped_id}}`, and `{{post_id}}` placeholders are replaced with valid values before making the request.\n \n- A successful response will have a status code of `200`.\n \n- If the request fails, appropriate error messages will be returned based on the issue encountered.\n \n\nThis API is useful for developers looking to integrate messaging capabilities within their applications, allowing for seamless communication with Instagram users."
0 commit comments