S3 API
for WhatsApp Business API.
Base URL: https://s-3.tech/api/v1.1
Send WABA templates and messages from your own systems and receive incoming messages through webhooks. Create keys in your S3 account: Settings, Developers, Secret keys. Limits: 600 requests and 60 sends per minute.
Introduction
The S3 API connects your business to WhatsApp Business for efficient, automated communication with customers. You get:
- Automated customer communication
- Support for text, media and template messages
- Incoming messages received and processed through a webhook
- Secure integration with your systems
To get started, get access to S3 (access is by invitation), then create a key in your S3 account.
Quick start
- 1Create a keyIn your S3 account: Settings → Developers → Secret keys. It is shown only once, so save it. Authentication
- 2Get your numbers and templatesAccount numbers give you the
phone_idfor thefromfield, and templates give you the name, language and number of variables. - 3Send a templateOne POST /public/messages/template request: the message goes to the customer and shows up in the S3 conversation.
# 1. Key: Settings → Developers → Secret keys
export S3_API_KEY="sk-…"
# 2. Numbers and approved templates
curl https://s-3.tech/api/v1.1/public/numbers \
-H "Authorization: Bearer $S3_API_KEY"
curl "https://s-3.tech/api/v1.1/public/templates?status=APPROVED" \
-H "Authorization: Bearer $S3_API_KEY"
# 3. Send a template
curl -X POST https://s-3.tech/api/v1.1/public/messages/template \
-H "Authorization: Bearer $S3_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "540238085832615",
"to": "77001234567",
"template": { "name": "order_ready", "language": "ru" },
"variables": ["Anna", "15:00"]
}'import requests
API = "https://s-3.tech/api/v1.1/public"
H = {"Authorization": "Bearer sk-…"} # 1. key from your S3 account
# 2. Numbers and approved templates
numbers = requests.get(f"{API}/numbers", headers=H).json()["numbers"]
templates = requests.get(f"{API}/templates", headers=H).json()["templates"]
# 3. Send a template
r = requests.post(f"{API}/messages/template", headers=H, json={
"from": numbers[0]["phone_id"],
"to": "77001234567",
"template": {"name": "order_ready", "language": "ru"},
"variables": ["Anna", "15:00"],
})
print(r.status_code, r.json())const API = "https://s-3.tech/api/v1.1/public";
const headers = { Authorization: "Bearer sk-…" }; // 1. key from your S3 account
// 2. Numbers and approved templates
const { numbers } = await (await fetch(`${API}/numbers`, { headers })).json();
const { templates } = await (await fetch(`${API}/templates`, { headers })).json();
// 3. Send a template
const r = await fetch(`${API}/messages/template`, {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify({
from: numbers[0].phone_id,
to: "77001234567",
template: { name: "order_ready", language: "ru" },
variables: ["Anna", "15:00"],
}),
});
console.log(r.status, await r.json());Authentication
Every request to the S3 API needs an API key in the request header. You create it in your S3 account: Settings → Developers → Secret keys. It is shown in full only once, right after you create it, so save it.
Recommended header: Authorization: Bearer sk-…. We also accept X-API-Key: sk-… and Authorization: sk-… (without Bearer, for integrations connected earlier).
Headers
AuthorizationstringBearer sk-…, the API key that authorizes requestsX-API-Keystringthe same, if a separate header suits you betterContent-Typestringrequest content type (application/json)Good to know
- The API key is issued to the business account, not to a specific user
- You get it in your S3 account: Settings → Developers → Secret keys
- The same page shows when it was last used, and you can revoke it there: requests with that key stop working immediately
- Keep your API key in a safe place and don’t share it with third parties
Common errors
curl https://s-3.tech/api/v1.1/public/numbers \
-H "Authorization: Bearer YOUR_API_KEY"import requests
url = "https://s-3.tech/api/v1.1/"
headers = {
"Authorization": "YOUR_API_KEY",
"Content-Type": "application/json"
}
response = requests.post(url, headers=headers)
print(response.text)const r = await fetch("https://s-3.tech/api/v1.1/public/numbers", {
headers: { Authorization: "Bearer YOUR_API_KEY" },
});
console.log(r.status, await r.json());package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
url := "https://s-3.tech/api/v1.1/"
method := "POST"
payload := strings.NewReader("")
client := &http.Client{}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Authorization", "YOUR_API_KEY")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}Rate limits
Limits are counted separately for each API key:
When you go over a limit, the API returns 429 with the rate_limited code and a Retry-After header: the number of seconds before you can retry.
Response headers
X-RateLimit-Limitintegerthe limit that applies to the request; included in every responseX-RateLimit-Remainingintegerhow many requests are left in the current minute; included in every responseRetry-Afterintegeronly in a 429 response: how many seconds to wait before retrying429, retry the request after the pause given in Retry-After. Send broadcasts at an even pace rather than in one burst, so you stay within the limit.HTTP/1.1 429 Too Many Requests
Retry-After: 12
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 0
{ "error": { "code": "rate_limited", "message": "…" } }Errors
The /public/… endpoints return every error in the same shape: an error object with a machine-readable code and a human-readable message.
The examples on this page show the message text translated into English; the API may return it in Russian. In your code, rely on code and the HTTP status, not on message.
invalid_request invalid_recipient from_required template_ambiguousbilling_suspendednumber_not_ownednumber_not_owned means the number isn’t yoursnumber_not_found template_not_foundtemplate_not_approved variables_mismatch and Meta errorssend_failed{ "error": { "code": "template_not_found", "message": "Template not found (list: GET /public/templates)" } }Account numbers
/api/v1.1/public/numbersThe WhatsApp Business (WABA) numbers connected to your account. When sending, pass the phone_id or the number from this response in from.
Response fields
numbers[].phone_idstringnumber ID, for the from field when sendingnumbers[].display_phone_numberstringthe number as customers see itnumbers[].namestringthe number’s display namenumbers[].waba_idstringWhatsApp Business Account (WABA) IDnumbers[].messaging_limitstringthe number’s Meta messaging limit for broadcasts, for example TIER_2Kcurl https://s-3.tech/api/v1.1/public/numbers \
-H "Authorization: Bearer YOUR_API_KEY"import requests
r = requests.get("https://s-3.tech/api/v1.1/public/numbers",
headers={"Authorization": "Bearer YOUR_API_KEY"})
print(r.json()["numbers"])const r = await fetch("https://s-3.tech/api/v1.1/public/numbers", {
headers: { Authorization: "Bearer YOUR_API_KEY" },
});
const { numbers } = await r.json();Templates
/api/v1.1/public/templatesYour account’s WhatsApp templates. By default, the list includes only templates approved by Meta, which are the ones you can send.
Query parameters
statusstringoptionalAPPROVED (default), PENDING, REJECTED or allnamestringoptionalexact template namelanguagestringoptionallanguage, for example ru or en_USThe parameters field
body_variablesintegerhow many values to pass in variables ({{1}}, {{2}}…)body_namesstring[]variable names, if the template uses named variables ({{name}})headerstringheader type: text, image, video, document; for media, pass componentsurl_buttons_with_variableinteger[]indexes of URL buttons that have a variable; their values go in componentscurl "https://s-3.tech/api/v1.1/public/templates?status=APPROVED" \
-H "Authorization: Bearer YOUR_API_KEY"import requests
r = requests.get("https://s-3.tech/api/v1.1/public/templates",
params={"status": "APPROVED"},
headers={"Authorization": "Bearer YOUR_API_KEY"})
for t in r.json()["templates"]:
print(t["name"], t["language"], t["parameters"])const r = await fetch("https://s-3.tech/api/v1.1/public/templates?status=APPROVED", {
headers: { Authorization: "Bearer YOUR_API_KEY" },
});
const { templates } = await r.json();Sending a template
/api/v1.1/public/messages/templateSend an approved template to a customer. A template lets you message first, and also after the customer has been silent for more than 24 hours. The message appears in the S3 conversation and is passed to amoCRM if it’s connected.
Request fields
fromstringsender number: the phone_id or the number itself from the list of numbers. If you have only one number, you can leave it outtostringrequiredcustomer number with country code, for example 77001234567templateobjectrequired{ "id": "…" } or { "name": "…", "language": "ru" }; the language is required if the template has more than onevariablesstring[]optionalvalues for the text variables, in order; their count must match body_variablescomponentsarrayoptionalparameters in Meta format for a header with a file, buttons with a variable or a carousel; in that case variables are not neededcodestringoptionalcode for an authentication template: it is inserted into the text and the buttonmessage_id is the WhatsApp message ID. Delivery and read statuses for the message arrive in the webhook with this ID.curl -X POST https://s-3.tech/api/v1.1/public/messages/template \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "540238085832615",
"to": "77001234567",
"template": { "name": "order_ready", "language": "ru" },
"variables": ["Anna", "15:00"]
}'import requests
r = requests.post(
"https://s-3.tech/api/v1.1/public/messages/template",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"from": "540238085832615",
"to": "77001234567",
"template": {"name": "order_ready", "language": "ru"},
"variables": ["Anna", "15:00"],
},
)
print(r.status_code, r.json())const r = await fetch("https://s-3.tech/api/v1.1/public/messages/template", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
from: "540238085832615",
to: "77001234567",
template: { name: "order_ready", language: "ru" },
variables: ["Anna", "15:00"],
}),
});
console.log(r.status, await r.json());Webhook messages
You set up the webhook in your S3 account. Your URL receives three kinds of events for your WABA numbers:
- an incoming customer message: there is no
eventfield, anddirection: incoming; event: message: an outgoing message sent by an operator in S3 chat, the API, a broadcast, a funnel, amoCRM or Bitrix24 (the sender is insender_type);event: status: the status of an outgoing message:sent,delivered,read,failed(witherror_codeanderror).
Match statuses by message_id: it’s the same ID that /public/messages/template and send-message return.
S3 sends POST requests to your webhook URL, with the data in the request body as JSON.
body object, for example: $json.body.phone_number, $json.body.text, $json.body.phone_number_id.Parameters
eventstringoptionalmessage (outgoing) or status (status of an outgoing message); incoming messages don’t have this fieldwa_idstringUnique WhatsApp business account IDnamestringContact name (if available)phone_number_idstringID of your WhatsApp Business numberphone_numberstringCustomer phone numbermessage_idstringWhatsApp message ID (wamid): it links a sent message to its statusesstatusstringnew for incoming; sent, delivered, read, failed for outgoingfile_pathstringoptionalLink to the file of an incoming photo, video, document or voice message; served with the correct Content-Typemime_typestringoptionalFile type, for example image/jpeg or audio/ogg; codecs=opussender_typestringoptionalWho sent the outgoing message: manager (operator in chat), api, mailing, funnel, amo_manager and otherserror_codenumberoptionalMeta error code when status=failederrorstringoptionalThe reason for non-delivery in plain languagecontentobjectFull message contenttextstringMessage text (for text messages)typestringMessage type (text, image, video, etc.)directionstringMessage direction (incoming/outgoing)timestampstringTime the message was createdUse cases
Webhook messages are used to:
- Receive incoming messages from customers
- Track delivery and read status of sent messages
- Sync operator replies from S3 chat with your system
- Process media files and documents
Good to know
- The webhook must be set up in your S3 account
- The webhook URL must be reachable from the internet
- We recommend HTTPS for security
- Your server must respond with 200 OK to every request
Common errors
// Incoming customer message (no event field)
{
"wa_id": "1234567890",
"name": "Customer name",
"phone_number_id": "12345",
"phone_number": "79998887766",
"message_id": "wamid.HBgL...",
"status": "new",
"file_path": "https://s-3.tech/media/incoming/1234567890123456.jpg",
"mime_type": "image/jpeg",
"content": { "media_id": "1234567890123456", "mime_type": "image/jpeg", "caption": "Photo" },
"type": "image",
"direction": "incoming",
"timestamp": "1760000000"
}
// Outgoing: operator in chat, API, broadcast, funnel, amoCRM
{
"event": "message",
"phone_number_id": "12345",
"phone_number": "79998887766",
"message_id": "wamid.HBgL...",
"status": "sent",
"content": { "text": "Hello" },
"text": "Hello",
"type": "text",
"direction": "outgoing",
"sender_type": "manager",
"timestamp": "1760000005"
}
// Status of an outgoing message: sent, delivered, read, failed
{
"event": "status",
"phone_number_id": "12345",
"phone_number": "79998887766",
"message_id": "wamid.HBgL...",
"status": "failed",
"content": null,
"type": "",
"direction": "outgoing",
"timestamp": "1760000010",
"error_code": 131047,
"error": "More than 24 hours have passed since the customer's last message, a template is required."
}Sending messages
Text message
To send a message, make a POST request to this endpoint:
/api/v1.1/messages/send-messagelegacy endpointEndpoint details
URLhttps://s-3.tech/api/v1.1/messages/send-messageMethodPOSTAuthorizationheaderAPI key for authorizationContent-Typeheaderapplication/jsonRequest bodyJSON object with the message parametersParameters
recipient_phonestringrequiredrecipient phone number in international formatphone_idstringrequiredID of your WhatsApp Business number. You can find it in your S3 account profile by clicking “Show all numbers”. The ID is listed as PhoneId next to the number.message_typestringrequiredmessage type: text (plain text), button (reply buttons), cta_url (link button), image, video, document (files)textstringmessage textcomponentsarrayoptionalarray of message components (used only for messages with buttons)The S3 API supports two main types of outgoing messages:
- Regular messages (text and media): can be sent only during an active session (24 hours after the customer’s last message)
- Template messages: can be sent at any time, as long as you have an approved template
Use cases
Text messages are used for:
- Notifications to customers within the open 24-hour window
- Replying to customer inquiries
- Confirmations and reminders
Good to know
- Messages can be sent only within the 24-hour window after the customer’s last message
- Maximum text length: 4096 characters
- Emoji and special characters are supported
- We recommend template messages for broadcasts
Common errors
curl -X POST https://s-3.tech/api/v1.1/messages/send-message \
-H "Authorization: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"recipient_phone": "79XXXXXXXXX",
"phone_id": "PHONE_ID",
"text": "Hi, this is a text message.",
"message_type": "text"
}'import requests
# Text message parameters
message_data = {
"recipient_phone": "79XXXXXXXXX",
"phone_id": "PHONE_ID",
"text": "Hi, this is a text message.",
"message_type": "text",
}
# Request headers
headers = {
"Authorization": "YOUR_API_KEY",
"Content-Type": "application/json",
}
# Send the request
url = "https://s-3.tech/api/v1.1/messages/send-message"
response = requests.post(url, headers=headers, json=message_data)
# Check the response
if response.status_code == 200:
print("Message sent successfully")
print("Server response:", response.json())
else:
print(f"Error sending message: {response.status_code}")
print("Server response:", response.text)const axios = require('axios');
// Text message parameters
const messageData = {
recipient_phone: "79XXXXXXXXX",
phone_id: "PHONE_ID",
text: "Hi, this is a text message.",
message_type: "text",
};
// Request configuration
const config = {
method: 'post',
url: 'https://s-3.tech/api/v1.1/messages/send-message',
headers: {
'Authorization': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
data: messageData
};
// Send the request
axios(config)
.then(response => {
console.log('Message sent successfully');
console.log('Server response:', response.data);
})
.catch(error => {
console.error('Error sending message:', error);
if (error.response) {
console.error('Server response:', error.response.data);
console.error('Response status:', error.response.status);
}
});package main
import (
"fmt"
"io/ioutil"
"net/http"
"bytes"
"encoding/json"
)
type MessageRequest struct {
RecipientPhone string `json:"recipient_phone"`
PhoneID string `json:"phone_id"`
Text string `json:"text"`
MessageType string `json:"message_type"`
}
func main() {
// Create an object with the text message parameters
messageData := MessageRequest{
RecipientPhone: "79XXXXXXXXX",
PhoneID: "PHONE_ID",
Text: "Hi, this is a text message.",
MessageType: "text",
}
// Convert the object to JSON
jsonData, err := json.Marshal(messageData)
if err != nil {
fmt.Println("Error creating JSON:", err)
return
}
// Send the request
url := "https://s-3.tech/api/v1.1/messages/send-message"
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
// Add headers
req.Header.Set("Authorization", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
// Execute the request
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
// Read the response
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
fmt.Println("Server response:", string(body))
}<?php
// Text message parameters
$message_data = [
"recipient_phone" => "79XXXXXXXXX",
"phone_id" => "PHONE_ID",
"text" => "Hi, this is a text message.",
"message_type" => "text",
];
// Endpoint URL
$url = 'https://s-3.tech/api/v1.1/messages/send-message';
// Initialize cURL
$ch = curl_init($url);
// Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($message_data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: YOUR_API_KEY',
'Content-Type: application/json'
]);
// Execute the request and get the response
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Check for errors
if (curl_errno($ch)) {
echo 'cURL error: ' . curl_error($ch);
} else {
// Print the result
echo "HTTP Code: $http_code\n";
echo "Server response: $response\n";
}
// Close the connection
curl_close($ch);
?>{
"recipient_phone": "79XXXXXXXXX",
"phone_id": "PHONE_ID",
"text": "Hi, this is a text message.",
"message_type": "text"
}Sending a template message
To send a template message, make a POST request to this endpoint:
/api/v1.1/messages/send-template-messagelegacy endpoint/public/messages/template) instead: you pick the template by name and the number by phone_id.Template message parameters
facebook_idstringrequiredtemplate ID in Facebookrecipient_phonestringrequiredrecipient phone number in international formatdisplay_phone_numberstringrequiredthe sender’s display phone number (enter it exactly as it appears in your S3 account)user_compsstring[]array of values to insert into the templateGood to know
- A template message can be sent at any time, even after the 24-hour window has expired
- The template must be approved by Meta beforehand (you can see its status in your S3 account)
- The number of variables in a template is limited (usually up to 4)
- Values in user_comps must follow the order of the variables in the template
curl -X POST https://s-3.tech/api/v1.1/messages/send-template-message \
-H "Authorization: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"facebook_id": "12121233123123",
"recipient_phone": "77001234567",
"display_phone_number": "+7 700 000-00-00",
"user_comps": ["Anna"]
}'Sending a message with a CTA URL button
A CTA URL button opens the specified website when tapped.
Fields
message_typestringcta_url: a message with a link buttoncomponents[].buttons[].urlstringthe URL to open when the button is tapped{
"recipient_phone": "79XXXXXXXXX",
"phone_id": "PHONE_ID",
"text": "Check out our website",
"message_type": "cta_url",
"components": [
{
"type": "button",
"buttons": [
{
"type": "reply",
"text": "Go to website",
"url": "https://example.com"
}
]
}
]
}Sending media
/api/v1.1/messages/send-messagelegacy endpointParameters
recipient_phonestringrequiredrecipient phone number in international formatphone_idstringrequiredID of your WhatsApp Business numbermessage_typestringrequiredmessage type: image, video or documentmedia_filestringrequiredthe filename value from the upload response, for example abc123.jpg. Not a linktextstringoptionalfile captionUse cases
Images are used for:
- Sending product photos
- Showing work samples
- Sending receipts and documents
- Visual confirmation
Good to know
- First upload the file through /media/upload, then pass its filename in media_file
- Meta limits: JPG and PNG images up to 5 MB, MP4 video up to 16 MB, documents up to 100 MB
- As with text, a file can be sent only within 24 hours after the customer’s last message
- The response contains message_id: delivery statuses for it arrive in the webhook
Common errors
import requests
import json
# Media message parameters
media_data = {
"recipient_phone": "1231231231231",
"phone_id": "12345667890",
"message_type": "image",
"media_file": "abc123.jpg"
}
# Request headers
headers = {
"Authorization": "YOUR_API_KEY",
"Content-Type": "application/json"
}
# Send the request
url = "https://s-3.tech/api/v1.1/messages/send-message"
response = requests.post(url, headers=headers, data=json.dumps(media_data))
# Check the response
if response.status_code == 200:
print("Media file sent successfully")
print("Server response:", response.json())
else:
print(f"Error sending media file: {response.status_code}")
print("Server response:", response.text)const axios = require('axios');
// Media message parameters
const mediaData = {
recipient_phone: "1231231231231",
phone_id: "12345667890",
message_type: "image",
media_file: "abc123.jpg"
};
// Request configuration
const config = {
method: 'post',
url: 'https://s-3.tech/api/v1.1/messages/send-message',
headers: {
'Authorization': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
data: mediaData
};
// Send the request
axios(config)
.then(response => {
console.log('Media file sent successfully');
console.log('Server response:', response.data);
})
.catch(error => {
console.error('Error sending media file:', error);
if (error.response) {
console.error('Server response:', error.response.data);
console.error('Response status:', error.response.status);
}
});package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
type MediaRequest struct {
RecipientPhone string `json:"recipient_phone"`
PhoneID string `json:"phone_id"`
MessageType string `json:"message_type"`
MediaFile string `json:"media_file"`
}
func main() {
// Create an object with the message parameters
mediaData := MediaRequest{
RecipientPhone: "1231231231231",
PhoneID: "12345667890",
MessageType: "image",
MediaFile: "abc123.jpg",
}
// Convert the object to JSON
jsonData, err := json.Marshal(mediaData)
if err != nil {
fmt.Println("Error creating JSON:", err)
return
}
// Send the request
url := "https://s-3.tech/api/v1.1/messages/send-message"
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
// Add headers
req.Header.Set("Authorization", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
// Execute the request
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
// Read the response
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
fmt.Println("Server response:", string(body))
}<?php
// Media message parameters
$media_data = [
"recipient_phone" => "1231231231231",
"phone_id" => "12345667890",
"message_type" => "image",
"media_file" => "abc123.jpg"
];
// Endpoint URL
$url = 'https://s-3.tech/api/v1.1/messages/send-message';
// Initialize cURL
$ch = curl_init($url);
// Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($media_data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: YOUR_API_KEY',
'Content-Type: application/json'
]);
// Execute the request and get the response
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Check for errors
if (curl_errno($ch)) {
echo 'cURL error: ' . curl_error($ch);
} else {
// Print the result
echo "HTTP Code: $http_code\n";
echo "Server response: $response\n";
}
// Close the connection
curl_close($ch);
?>{
"recipient_phone": "1231231231231",
"phone_id": "12345667890",
"message_type": "image",
"media_file": "abc123.jpg"
}Media upload
https://s-3.tech/api/v1.1/media/uploadlegacy endpointTo send media files (images, video, documents), first upload them to the S3 server. The upload response contains filename: pass it in the media_file parameter when you send the message. Authorization works the same way as in other requests: Authorization: Bearer sk-…, Authorization: sk-… or X-API-Key.
Parameters
AuthorizationheaderrequiredAPI key for authorizing requestsmediafilerequiredthe file to upload (image, video or document)Response parameters
filenamestringFile name: pass it in media_file when sendingfilepathstringTechnical parameterUse cases
Media upload is used for:
- Sending product images
- Sharing video instructions
- Sending documents and receipts
- Exchanging media files with customers
Good to know
- The file field is called media (multipart/form-data)
- If the name is already taken, the file is saved under a new name, so always take filename from the response
- Size limits and formats are set by Meta at sending time: JPG and PNG images up to 5 MB, MP4 video up to 16 MB, documents (PDF, DOC, XLS, etc.) up to 100 MB
Common errors
curl -X POST https://s-3.tech/api/v1.1/media/upload \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "media=@/path/to/file.jpg"import requests
def upload_file(file_path, api_key):
"""
Upload a file to the S3 server
:param file_path: Path to the file
:param api_key: API key
:return: Server response
"""
url = "https://s-3.tech/api/v1.1/media/upload"
# Open the file for upload
files = {
'media': open(file_path, 'rb')
}
# Request headers
headers = {
'Authorization': api_key
}
try:
# Send the request
response = requests.post(url, headers=headers, files=files)
# Check the response
if response.status_code == 200:
print("File uploaded successfully")
return response.json()
else:
print(f"File upload error: {response.status_code}")
print(f"Server response: {response.text}")
return None
except Exception as e:
print(f"An error occurred: {str(e)}")
return None
finally:
# Close the file
files['media'].close()
# Usage example
if __name__ == "__main__":
file_path = "/path/to/file.jpg"
api_key = "YOUR_API_KEY"
result = upload_file(file_path, api_key)
if result:
print("Uploaded file details:")
print(f"File name: {result.get('filename')}")
print(f"File path: {result.get('filepath')}")package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
"path/filepath"
)
func uploadFile(filePath, apiKey string) error {
// Open the file
file, err := os.Open(filePath)
if err != nil {
return fmt.Errorf("failed to open file: %w", err)
}
defer file.Close()
// Create a buffer for the form
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
// Create a form field for the file
part, err := writer.CreateFormFile("media", filepath.Base(filePath))
if err != nil {
return fmt.Errorf("failed to create file field: %w", err)
}
// Copy the file contents into the form field
_, err = io.Copy(part, file)
if err != nil {
return fmt.Errorf("failed to copy file: %w", err)
}
// Close the form writer
err = writer.Close()
if err != nil {
return fmt.Errorf("failed to close writer: %w", err)
}
// Create the request
url := "https://s-3.tech/api/v1.1/media/upload"
req, err := http.NewRequest("POST", url, body)
if err != nil {
return fmt.Errorf("failed to create request: %w", err)
}
// Add headers
req.Header.Set("Authorization", apiKey)
req.Header.Set("Content-Type", writer.FormDataContentType())
// Send the request
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return fmt.Errorf("failed to execute request: %w", err)
}
defer resp.Body.Close()
// Read the response
respBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("failed to read response: %w", err)
}
// Check the response status
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("request error: %s, status: %d", string(respBody), resp.StatusCode)
}
// Print the successful response
fmt.Println("File uploaded successfully")
fmt.Println("Server response:", string(respBody))
return nil
}
func main() {
// File path and API key
filePath := "/path/to/file.jpg"
apiKey := "YOUR_API_KEY"
// Upload the file
err := uploadFile(filePath, apiKey)
if err != nil {
fmt.Println("Error:", err)
}
}Support
Our team is always ready to help you integrate and use the S3 API:
Useful
pages.
Need help
with your integration?
Tell us where your customers come from and how your team works. We’ll show a suitable scenario and help with the setup.