Media
Upload media
Protocols: Linked Device API · Meta Cloud API
Required scope: media:manage
POST
/
graph
/
whatsapp
/
{version}
/
{phoneNumberId}
/
media
Upload media
curl --request POST \
--url https://api.polymorfa.com/graph/whatsapp/{version}/{phoneNumberId}/media \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form messaging_product=whatsapp \
--form file='@example-file'const form = new FormData();
form.append('messaging_product', 'whatsapp');
form.append('file', '{
"fileName": "example-file"
}');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.polymorfa.com/graph/whatsapp/{version}/{phoneNumberId}/media', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.polymorfa.com/graph/whatsapp/{version}/{phoneNumberId}/media"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = { "messaging_product": "whatsapp" }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.polymorfa.com/graph/whatsapp/{version}/{phoneNumberId}/media"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"messaging_product\"\r\n\r\nwhatsapp\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}false{
"id": "<string>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": 123,
"fbtrace_id": "<string>",
"error_subcode": 123,
"error_data": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": 123,
"fbtrace_id": "<string>",
"error_subcode": 123,
"error_data": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": 123,
"fbtrace_id": "<string>",
"error_subcode": 123,
"error_data": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": 123,
"fbtrace_id": "<string>",
"error_subcode": 123,
"error_data": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": 123,
"fbtrace_id": "<string>",
"error_subcode": 123,
"error_data": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": 123,
"fbtrace_id": "<string>",
"error_subcode": 123,
"error_data": "<unknown>"
}
}Authorizations
Polymorfa organization key (pmfa_ prefix) or project token (pmfa_pt_ prefix). Client tokens are not accepted by Graph operations.
Path Parameters
Specifies version for this path parameter.
Example:
"v21.0"
Identifier for the phone number.
Example:
"123456789012345"
Body
multipart/form-data
Response
Media uploaded
Identifier for this resource.
⌘I
Upload media
curl --request POST \
--url https://api.polymorfa.com/graph/whatsapp/{version}/{phoneNumberId}/media \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form messaging_product=whatsapp \
--form file='@example-file'const form = new FormData();
form.append('messaging_product', 'whatsapp');
form.append('file', '{
"fileName": "example-file"
}');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.polymorfa.com/graph/whatsapp/{version}/{phoneNumberId}/media', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.polymorfa.com/graph/whatsapp/{version}/{phoneNumberId}/media"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = { "messaging_product": "whatsapp" }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.polymorfa.com/graph/whatsapp/{version}/{phoneNumberId}/media"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"messaging_product\"\r\n\r\nwhatsapp\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}false{
"id": "<string>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": 123,
"fbtrace_id": "<string>",
"error_subcode": 123,
"error_data": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": 123,
"fbtrace_id": "<string>",
"error_subcode": 123,
"error_data": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": 123,
"fbtrace_id": "<string>",
"error_subcode": 123,
"error_data": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": 123,
"fbtrace_id": "<string>",
"error_subcode": 123,
"error_data": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": 123,
"fbtrace_id": "<string>",
"error_subcode": 123,
"error_data": "<unknown>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": 123,
"fbtrace_id": "<string>",
"error_subcode": 123,
"error_data": "<unknown>"
}
}