Skip to main content
POST
/
api
/
send
/
media
Send Media Message
curl --request POST \
  --url https://swiftchats.axis96.xyz/api/send/media \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "phone": "+254720055819",
  "media_type": "image",
  "media_url": "https://images.pexels.com/photos/276267/pexels-photo-276267.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2",
  "caption": "your caption for image or video media types",
  "file_name": "testFile"
}
'
import requests

url = "https://swiftchats.axis96.xyz/api/send/media"

payload = {
"phone": "+254720055819",
"media_type": "image",
"media_url": "https://images.pexels.com/photos/276267/pexels-photo-276267.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2",
"caption": "your caption for image or video media types",
"file_name": "testFile"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
phone: '+254720055819',
media_type: 'image',
media_url: 'https://images.pexels.com/photos/276267/pexels-photo-276267.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2',
caption: 'your caption for image or video media types',
file_name: 'testFile'
})
};

fetch('https://swiftchats.axis96.xyz/api/send/media', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://swiftchats.axis96.xyz/api/send/media",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'phone' => '+254720055819',
'media_type' => 'image',
'media_url' => 'https://images.pexels.com/photos/276267/pexels-photo-276267.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2',
'caption' => 'your caption for image or video media types',
'file_name' => 'testFile'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://swiftchats.axis96.xyz/api/send/media"

payload := strings.NewReader("{\n \"phone\": \"+254720055819\",\n \"media_type\": \"image\",\n \"media_url\": \"https://images.pexels.com/photos/276267/pexels-photo-276267.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2\",\n \"caption\": \"your caption for image or video media types\",\n \"file_name\": \"testFile\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://swiftchats.axis96.xyz/api/send/media")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"phone\": \"+254720055819\",\n \"media_type\": \"image\",\n \"media_url\": \"https://images.pexels.com/photos/276267/pexels-photo-276267.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2\",\n \"caption\": \"your caption for image or video media types\",\n \"file_name\": \"testFile\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://swiftchats.axis96.xyz/api/send/media")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"phone\": \"+254720055819\",\n \"media_type\": \"image\",\n \"media_url\": \"https://images.pexels.com/photos/276267/pexels-photo-276267.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2\",\n \"caption\": \"your caption for image or video media types\",\n \"file_name\": \"testFile\"\n}"

response = http.request(request)
puts response.read_body
{
  "statusCode": 200,
  "data": {
    "success": true,
    "data": {
      "messaging_product": "whatsapp",
      "contacts": [
        {
          "input": "+254720055819",
          "wa_id": "254720055819"
        }
      ],
      "messages": [
        {
          "id": "wamid.HBgMMjU0NzIwMDU1ODE5FQIAERgSMzJEODk0QjY5MDdENDk1RTNCAA=="
        }
      ],
      "chat": {
        "id": 13,
        "uuid": "d3479935-7aac-43de-8dc3-8568d04b0104",
        "organization_id": 3,
        "wam_id": "wamid.HBgMMjU0NzIwMDU1ODE5FQIAERgSMzJEODk0QjY5MDdENDk1RTNCAA==",
        "contact_id": 1,
        "user_id": null,
        "type": "outbound",
        "metadata": "{\"id\":\"wamid.HBgMMjU0NzIwMDU1ODE5FQIAERgSMzJEODk0QjY5MDdENDk1RTNCAA==\",\"type\":\"image\",\"image\":{\"mime_type\":\"image\\/jpeg\"}}",
        "media_id": 2,
        "status": "sent",
        "deleted_by": null,
        "deleted_at": null,
        "created_at": "2024-06-28 16:44:34",
        "contact": {
          "id": 1,
          "uuid": "3d3f9de5-52eb-412c-93aa-1e66a6a86489",
          "organization_id": 3,
          "first_name": "John",
          "last_name": "Doe",
          "phone": "+254720055819",
          "email": null,
          "avatar": "/media/public/9ZiTT2SWyPoIj5TdHQl2VF7Xgy9JoaBNjH19vEWh.jpg",
          "address": "{\"street\":null,\"city\":null,\"state\":null,\"zip\":null,\"country\":null}",
          "metadata": "null",
          "contact_group_id": null,
          "is_favorite": 0,
          "created_by": 6,
          "created_at": "2024-06-07 19:58:35",
          "updated_at": "2024-06-07 19:58:35",
          "deleted_at": null,
          "full_name": "John Doe",
          "formatted_phone_number": "+254 720 055819"
        },
        "media": {
          "id": 2,
          "name": "testFile",
          "path": "https://images.pexels.com/photos/276267/pexels-photo-276267.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2",
          "location": "amazon",
          "type": "image/jpeg",
          "size": "517102",
          "created_at": "2024-06-28 16:44:34"
        }
      }
    }
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

The body is of type object.

Response

200 - application/json

OK

The response is of type object.