Meta's Resumable API with Node.JS
PORT=2002
// META GRAPH API AND IT's VERSION
META_API_URI=https://graph.facebook.com/v14.0
// DEVELOPER APP ID
META_APP_ID=xxxxxxx
// WHATSAPP BUSINESS SYSTEM USER's ACCESS TOKEN
META_ACCESS_TOKEN=xxxxxxx
// BUSINESS ACCOUNT ID
META_BUSINESS_ACC_ID=xxxxxxx
npm install
node index.js
Use Postman or any API explorer, Select your media file for upload
curl --location 'http://localhost:2002/uploadMedia' \
--form 'file=@"/path to media"'
{
"message": "Uploaded!",
"body": {
"h": "4:SU1HLTIwMjMwODA4LVdBMDA1Ny5qcGc=:aW1hZ2UvanBlZw==:ARaRZtSxg-sdfsd fsdfsdfs:e:1691919924:1183230345850902:100083655871696:ARb0Rx-OeipQSkQMkMc"
}
}
Put the uploaded media code in header_handle
from the above API's response
curl --location 'http://localhost:2002/createTemplate' \
--header 'Content-Type: application/json' \
--data '{
"name": "welcome_to_the_demo",
"language": "en_US",
"category": "MARKETING",
"components": [
{
"type": "HEADER",
"format": "IMAGE",
"example": {
"header_handle": [
"4:SU1HLTIwMjMwODA4LVdBMDA1Ny5qcGc=:aW1hZ2UvanBlZw==:ARaRZtSxg-sdfsd fsdfsdfs:e:1691919924:1183230345850902:100083655871696:ARb0Rx-OeipQSkQMkMc"
]
}
},
{
"type": "BODY",
"text": "Shop now through the end of August and use code 25OFF to get 25% off of all merchandise."
}
]
}'
{
"message": "Template Created!",
"body": {
"id": "1495664324171758",
"status": "PENDING",
"category": "MARKETING"
}
}
https://developers.facebook.com/docs/graph-api/guides/upload/