/api/upload
This documentation details how to use the media upload endpoint, which supports both raw binary and Base64-encoded file uploads.
Upload Media File
POST
/api/upload
This endpoint uploads a media file (image, video, audio, sticker, or document) to the server. The file is validated, stored temporarily, and made accessible via a unique URL that is active for 24-hours.
There are two methods for uploading a file:
- Raw Binary Upload: Send the file directly as the request body. This is the most efficient method for file uploads from servers or modern web clients.
- JSON (Base64) Upload: Send a JSON object containing the Base64-encoded file. This is useful for clients where file data is handled as a string.
Request Method 1: Raw Binary Upload
When uploading a binary file, the Content-Type
header is mandatory and must accurately reflect the file's MIME type (e.g., image/jpeg
, application/pdf
). The server uses this header for validation.
Request Method 2: JSON (Base64) Upload
To upload via Base64, send a request with Content-Type: application/json
and a body containing a base64
string. The MIME type can be provided in two ways:
- Recommended: Provide the full Data URL scheme within the
base64
string. The API will automatically parse the MIME type.
{ "base64": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA..." }
mimetype
field. This will override any MIME type found in the Data URL.{ "mimetype": "image/png", "base64": "iVBORw0KGgoAAAANSUhEUgA..." }
Validation Rules
The API enforces the following size limits per file category:
- Documents: 50 MB
- Images: 16 MB
- Videos: 16 MB
- Audio: 16 MB
- Stickers (webp): 5 MB
Files are also validated by their "magic numbers" to ensure the file content matches its declared type, enhancing security.
Parameters
Name | Type | Required | Description |
---|---|---|---|
base64 | string | No | The Base64-encoded file data. Can optionally include the Data URL prefix (e.g., data:image/png;base64,...). Required if using JSON upload method. |
mimetype | string | No | The MIME type of the file (e.g., image/png). This is only needed for JSON uploads if the base64 string does not include the Data URL prefix. |
Request Body | binary | No | The request body can either be the raw binary data of the file or a JSON object for Base64 uploads. |
Code Examples
# Raw Binary Upload (Recommended)
curl -X POST "https://wasenderapi.com/api/upload" \
-H "Content-Type: image/jpeg" \
--data-binary "@path/to/your/image.jpg"
# JSON (Base64) Upload
curl -X POST "https://wasenderapi.com/api/upload" \
-H "Content-Type: application/json" \
-d '{
"base64": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQE..."
}'
Response Examples
{
"success": true,
"publicUrl": "https://wasenderapi.com/media/a1b2c3d4-e5f6-7890-abcd-ef1234567890.jpg"
}