---
agentTools:
  projectIndex: https://rampwin-api.readme.io/llms.txt
---

# Facebook/Instagram Send Media Message using API

## Sending a Video

[block:parameters]
{
  "data": {
    "h-0": "",
    "h-1": "",
    "h-2": "",
    "h-3": "",
    "0-0": "Post Data Attribute",
    "0-1": "Post Data Attribute Value Type",
    "0-2": "Description",
    "0-3": "Required",
    "1-0": "channel_id",
    "1-1": "String",
    "1-2": "Channel ID by which the message template would be sent.",
    "1-3": "Yes",
    "2-0": "contact_id",
    "2-1": "String",
    "2-2": "Facebook and Instagram don't have phone number so you need to send the contact id. Contact id can be received from the webhooks or contacts api.",
    "2-3": "NO ",
    "3-0": "facebook_psid",
    "3-1": "String",
    "3-2": "Facebook and Instagram don't have phone number so you need to send the contact id. Contact id can be received from the webhooks or contacts api.",
    "3-3": "NO",
    "4-0": "instagram_psid",
    "4-1": "String",
    "4-2": "Facebook and Instagram don't have phone number so you need to send the contact id. Contact id can be received from the webhooks or contacts api.  \n  \nEither of contact_id/facebook_psid/instagram_psid is mandatory",
    "4-3": "NO",
    "5-0": "facebook_payload",
    "5-1": "JSON",
    "5-2": "A JSON compatible with facebook official API documentation <https://developers.facebook.com/docs/messenger-platform/instagram/features/generic-template>",
    "5-3": "Yes",
    "6-0": "",
    "6-1": "",
    "6-2": "",
    "6-3": ""
  },
  "cols": 4,
  "rows": 7,
  "align": [
    "left",
    "left",
    "left",
    "left"
  ]
}
[/block]

```curl
curl --location --request POST '<baseAPIURl>/api/messages/send' \
--header 'X-API-Key: <API KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "channel_id": "<Channel ID>",
    "contact_id": "<contact id>",
    "facebook_payload": {
        "attachment": {
            "type": "video/image/audio",
            "payload": {
                "url": "<public URL of file>"
            }
        }
    }
}'

```

## Sending a Image with Button cards

```curl CURL
curl --location --request POST '<baseAPIURl>/api/messages/send' \
--header 'X-API-Key: <API KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "channel_id": "<Channel ID>",
    "contact_id": "<contact id>",
    "facebook_payload": {
        "attachment": {
            "type": "template",
            "payload": {
                "elements": [
                    {
                        "title":"Card Title 1 (Required)",
                        "image_url": "<Image URL> (Optional)",
                        "buttons": [
                            {
                                "type": "web_url",
                                "url": "<URL>",
                                "title": "View Website"
                            },
                            {
                                "type": "postback",
                                "title": "Start Chatting",
                                "payload": "DEVELOPER_DEFINED_PAYLOAD"
                            }
                        ]
                    },
                    {
                        "title":"Card Title 2",
                        "image_url": "<Image URL>",
                        "buttons": [
                            {
                                "type": "web_url",
                                "url": "<URL>",
                                "title": "View Website"
                            }
                        ]
                    }

                ],
                "template_type": "generic"
            }
        }
    }
}'

```

## Sending a text with Quick replies

```curl curl
curl --location --request POST '<baseAPIURl>/api/messages/send' \
--header 'X-API-Key: <API KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "channel_id": "<Channel ID>",
    "contact_id": "<contact id>",
    "facebook_payload": {
        "text": "<SOME_TEXT>",
        "quick_replies": [
            {
                "content_type": "text",
                "title": "<TITLE_1>",
                "payload": "<POSTBACK_PAYLOAD_1>"
            },
            {
                "content_type": "text",
                "title": "<TITLE_2>",
                "payload": "<POSTBACK_PAYLOAD_2>"
            }
        ]
    }
}'

```

Note: Either of Contact\_id or facebook\_psid or instagram\_psid is mandatory