Send a File to Discord
Due to Discord’s limitations, you can only upload up to 10 files per request, with a combined size not exceeding 25 MB.
Send a File
Sends a File to Discord
POST /api/discord/sendfile
https://api.cookie-api.com/api/discord/sendfile
Authentication Learn how to get your API Key and use it in your requests!
{ "bot_token": "Your Bot's Token", "channel_id": "number", "file_urls": ["string"], "file_names": "string", //optional "content": "content" //optional}
- channel_id: Channel where the File(s) should be send to
- file_urls: Provide the URLs to the files in the following format:
["<URL>", "<URL>"]
. You can include up to 10 files with a total maximum size of 25 MB. - file_names: Provide in the same order as the file URLs. Must match the length of file_urls.“
**
Make sure to include the File ending like .html or .txt - content: Content of the Plain Text Message
curl --location 'https://api.cookie-api.com/api/discord/sendfile' \--header 'Content-Type: application/json' \--header 'Authorization: API_Key' \--data '{ "bot_token": "Bot_Token", "channel_id": "Channel_ID", "file_urls": ["https://upload.wikimedia.org/wikipedia/commons/7/78/Image.jpg", "https://upload.wikimedia.org/wikipedia/commons/b/bc/Information_example_page_300px.jpg"], "content": "If you read this you are cool!"}'
import requestsimport json
url = 'https://api.cookie-api.com/api/discord/sendfile'headers = { 'Content-Type': 'application/json', 'Authorization': 'API_Key'}
data = { 'bot_token': 'Bot_Token', 'channel_id': 'Channel_ID', 'file_urls': [ 'https://upload.wikimedia.org/wikipedia/commons/7/78/Image.jpg', 'https://upload.wikimedia.org/wikipedia/commons/b/bc/Information_example_page_300px.jpg' ], 'content': 'If you read this you are cool!'}
response = requests.post(url, headers=headers, data=json.dumps(data))print(response.json())
const fetch = require('node-fetch');
const url = 'https://api.cookie-api.com/api/discord/sendfile';const headers = { 'Content-Type': 'application/json', 'Authorization': 'API_Key'};
const data = { bot_token: 'Bot_Token', channel_id: 'Channel_ID', file_urls: [ 'https://upload.wikimedia.org/wikipedia/commons/7/78/Image.jpg', 'https://upload.wikimedia.org/wikipedia/commons/b/bc/Information_example_page_300px.jpg' ], content: 'If you read this you are cool!'};
fetch(url, { method: 'POST', headers: headers, body: JSON.stringify(data)}).then(res => res.json()).then(data => console.log(data)).catch(err => console.error(err));
package main
import ( "encoding/json" "fmt" "log" "net/http" "bytes")
func main() { url := "https://api.cookie-api.com/api/discord/sendfile"
data := map[string]interface{}{ "bot_token": "Bot_Token", "channel_id": "Channel_ID", "file_urls": []string{ "https://upload.wikimedia.org/wikipedia/commons/7/78/Image.jpg", "https://upload.wikimedia.org/wikipedia/commons/b/bc/Information_example_page_300px.jpg", }, "content": "If you read this you are cool!", }
jsonData, err := json.Marshal(data) if err != nil { log.Fatal(err) }
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) if err != nil { log.Fatal(err) }
req.Header.Set("Content-Type", "application/json") req.Header.Set("Authorization", "API_Key")
client := &http.Client{} resp, err := client.Do(req) if err != nil { log.Fatal(err) } defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)}
const https = require('https');
const data = JSON.stringify({ bot_token: 'Bot_Token', channel_id: 'Channel_ID', file_urls: [ 'https://upload.wikimedia.org/wikipedia/commons/7/78/Image.jpg', 'https://upload.wikimedia.org/wikipedia/commons/b/bc/Information_example_page_300px.jpg' ], content: 'If you read this you are cool!'});
const options = { hostname: 'api.cookie-api.com', path: '/api/discord/sendfile', method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'API_Key', 'Content-Length': Buffer.byteLength(data) }};
const req = https.request(options, res => { let responseData = ''; res.on('data', chunk => { responseData += chunk; }); res.on('end', () => { console.log(JSON.parse(responseData)); });});
req.on('error', error => { console.error(error);});
req.write(data);req.end();
require 'net/http'require 'uri'require 'json'
uri = URI.parse('https://api.cookie-api.com/api/discord/sendfile')
headers = { 'Content-Type' => 'application/json', 'Authorization' => 'API_Key'}
data = { 'bot_token' => 'Bot_Token', 'channel_id' => 'Channel_ID', 'file_urls' => [ 'https://upload.wikimedia.org/wikipedia/commons/7/78/Image.jpg', 'https://upload.wikimedia.org/wikipedia/commons/b/bc/Information_example_page_300px.jpg' ], 'content' => 'If you read this you are cool!'}
request = Net::HTTP::Post.new(uri, headers)request.body = data.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(request)end
puts response.body
use reqwest::blocking::Client;use reqwest::header::HeaderMap;use serde_json::json;
fn main() { let url = "https://api.cookie-api.com/api/discord/sendfile";
let data = json!({ "bot_token": "Bot_Token", "channel_id": "Channel_ID", "file_urls": [ "https://upload.wikimedia.org/wikipedia/commons/7/78/Image.jpg", "https://upload.wikimedia.org/wikipedia/commons/b/bc/Information_example_page_300px.jpg" ], "content": "If you read this you are cool!" });
let client = Client::new(); let mut headers = HeaderMap::new(); headers.insert("Authorization", "API_Key".parse().unwrap());
let res = client .post(url) .json(&data) .headers(headers) .send() .unwrap();
println!("{}", res.text().unwrap());}
Responses
{ "message": "Files sent successfully", "message_id": "123456789", "success": true}