Skip to main content
POST
/
api
/
partner
/
v1
/
files
import fetch from "node-fetch";

// Step 1: Get upload URL
const response = await fetch("https://www.genviral.io/api/partner/v1/files", {
  method: "POST",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    contentType: "video/mp4",
    filename: "my-video.mp4",
  }),
});

const { data } = await response.json();
// data.uploadUrl = presigned S3 URL
// data.url = https://cdn.vireel.io/partner-api/...

// Step 2: Upload file to presigned URL
const fileBuffer = fs.readFileSync("./my-video.mp4");
await fetch(data.uploadUrl, {
  method: "PUT",
  headers: {
    "Content-Type": "video/mp4",
  },
  body: fileBuffer,
});

// Step 3: Use the CDN URL in your post
await fetch("https://www.genviral.io/api/partner/v1/posts", {
  method: "POST",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    caption: "Check this out!",
    media: {
      type: "video",
      url: data.url, // Use the CDN URL
    },
    accounts: [{ id: "account-id" }],
  }),
});
{
  "ok": true,
  "code": 201,
  "message": "Upload URL generated",
  "data": {
    "uploadUrl": "https://storage.example.com/presigned-url...",
    "url": "https://cdn.vireel.io/partner-api/ws_123/abc123.mp4",
    "contentType": "video/mp4",
    "expiresIn": 600
  }
}
Upload media files directly to Genviral’s CDN. The returned url can then be used when creating posts via the /posts endpoint.

How It Works

  1. Call this endpoint with the file’s content type
  2. Receive a presigned uploadUrl and the final url (CDN URL)
  3. Upload your file directly to the uploadUrl using a PUT request
  4. Use the url in your post creation requests

Body Parameters

contentType
string
required
MIME type of the file. Supported types:
  • Images: image/jpeg, image/png, image/gif, image/webp, image/heic, image/heif
  • Videos: video/mp4, video/quicktime, video/x-msvideo, video/webm, video/x-m4v
filename
string
Original filename for reference (optional). Used for display purposes only.

Response

Successful requests return 201 with:
  • uploadUrl - Presigned URL to upload your file (expires in 10 minutes)
  • url - CDN URL where your file will be accessible after upload
  • contentType - The content type you specified
  • expiresIn - Seconds until the upload URL expires (600)

Examples

Upload a video

import fetch from "node-fetch";

// Step 1: Get upload URL
const response = await fetch("https://www.genviral.io/api/partner/v1/files", {
  method: "POST",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    contentType: "video/mp4",
    filename: "my-video.mp4",
  }),
});

const { data } = await response.json();
// data.uploadUrl = presigned S3 URL
// data.url = https://cdn.vireel.io/partner-api/...

// Step 2: Upload file to presigned URL
const fileBuffer = fs.readFileSync("./my-video.mp4");
await fetch(data.uploadUrl, {
  method: "PUT",
  headers: {
    "Content-Type": "video/mp4",
  },
  body: fileBuffer,
});

// Step 3: Use the CDN URL in your post
await fetch("https://www.genviral.io/api/partner/v1/posts", {
  method: "POST",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    caption: "Check this out!",
    media: {
      type: "video",
      url: data.url, // Use the CDN URL
    },
    accounts: [{ id: "account-id" }],
  }),
});
# Step 1: Get upload URL
curl --request POST \
  --url https://www.genviral.io/api/partner/v1/files \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "contentType": "video/mp4",
    "filename": "my-video.mp4"
  }'

# Step 2: Upload to presigned URL (use uploadUrl from response)
curl --request PUT \
  --url "<uploadUrl from step 1>" \
  --header 'Content-Type: video/mp4' \
  --data-binary @my-video.mp4

# Step 3: Use url in your post request
{
  "ok": true,
  "code": 201,
  "message": "Upload URL generated",
  "data": {
    "uploadUrl": "https://storage.example.com/presigned-url...",
    "url": "https://cdn.vireel.io/partner-api/ws_123/abc123.mp4",
    "contentType": "video/mp4",
    "expiresIn": 600
  }
}

Error Responses

  • 400 invalid_json - Request body is not valid JSON
  • 422 invalid_payload - Invalid content type or missing required fields
  • 500 create_failed - Failed to initialize upload (retry)
The presigned upload URL expires after 10 minutes. If it expires before you upload, simply request a new one.
Files uploaded via this endpoint are stored on Genviral’s CDN and are immediately ready for use in posts. No additional confirmation step is needed.