Messenger Code API Reference

To use the Messenger Code API, the Graph API version must be set to version 2.6 or greater in the request.

The Messenger Codes API allows you to programmatically generate Messenger Codes that pass custom ref parameters to your bot when a person scans the code. You might use this to track which codes are getting scanned the most, or activate different functionality based on which code was scanned.

All Facebook Pages have a default Messenger Code that opens their bot in Messenger without any special refs. Your default code is available in the Page admin tool or in the Pages Manager app.

For complete usage details, see Messenger Codes.

Contents

Request URI

https://graph.facebook.com/v2.6/me/messenger_codes?access_token=<ACCESS_TOKEN>

Example Request

curl -X POST -H "Content-Type: application/json" -d '{
  "type": "standard",
  "data": {
    "ref":"billboard-ad"
  },
  "image_size": 1000
}' "https://graph.facebook.com/v2.6/me/messenger_codes?access_token=<ACCESS_TOKEN>"

Example Response

The download URL is not permanent. You should download and cache the image as soon as possible.

{ 
  "uri": "<YOUR_CODE_URL_HERE>"
}

Properties

Property Type Description

type

String

Must be set to standard.

image_size

Integer

Optional. The size, in pixels, for the image you are requesting. Supported range: 100-2000 px. Defaults to 1000px.

data

Object

Optional. Contains the ref to pass to your bot when it is opened via the code.

data.ref

String

Optional. The ref string to pass to your bot is opened via the code. Max 250 characters. Valid characters: a-z A-Z 0-9 +/=-.:_