Media API
The Media API lets you upload remote media files to the Soku media library and render OG template images. Once uploaded, the returned URL can be used in post submissions for video and image content.Upload Remote Media
Download a media file from a remote URL and store it in the Soku media library.Authentication
This endpoint uses API key authentication. Include your API key in thesoku-api-key header.
An active Soku subscription (trialing or active) is required.
Headers
| Header | Required | Description |
|---|---|---|
Content-Type | Yes | Must be application/json |
soku-api-key | Yes | Your Soku API key |
Idempotency-Key | No | A unique string to prevent duplicate uploads. If omitted, Soku auto-derives a key from your user ID and request payload. |
Rate Limit
30 requests per 60 seconds, in addition to the global tier limit. See Rate Limits.Request Body
| Field | Type | Required | Description |
|---|---|---|---|
url | string | Yes | The publicly accessible URL of the media file to upload. Must be a valid HTTP or HTTPS URL. |
Response
Status:201 Created
| Field | Type | Description |
|---|---|---|
url | string | The Soku-hosted URL of the uploaded media file. Use this URL in the mediaUrls, videoUrl, or imageUrls fields when creating posts. |
Render OG Template Image
Render an OG image template. This is an alias forPOST /v1/templates and is functionally identical.
Authentication
This endpoint uses API key authentication. Include your API key in thesoku-api-key header.
An active Soku subscription (trialing or active) is required.
Rate Limit
20 requests per 60 seconds, in addition to the global tier limit. See Rate Limits.For full documentation on template rendering including request body, config options, and examples, see the Templates API.
Examples
Upload a video from a remote URL
Upload an image
Upload and then publish
A common workflow is to upload media first, then use the returned URL in a post:Supported Media Formats
The Media API accepts any media file that the source URL serves over HTTP or HTTPS. For best results with social platform publishing, use the following formats:| Type | Recommended Formats | Notes |
|---|---|---|
| Video | MP4 (H.264) | Most universally supported across all platforms |
| Image | JPEG, PNG, WebP | JPEG recommended for photos, PNG for graphics |
For detailed information on media format requirements and file size limits per platform, see Media Formats & Limits.
Idempotency
TheIdempotency-Key header prevents duplicate uploads when retrying requests.
- Include an
Idempotency-Keyheader with a unique string value onPOST /v1/mediarequests. - If the header is omitted, Soku auto-derives a key from your user ID and a hash of the request payload.
- If you send the same idempotency key with the same request body, the API returns the original cached response without uploading again.
- If you send the same idempotency key with a different request body, the API returns a
409error with codeidempotency_conflict.
Error Responses
| HTTP Status | Error Code | Description |
|---|---|---|
| 400 | validation_error | The url field is missing or not a valid URL |
| 401 | unauthorized | Missing or invalid API key |
| 403 | forbidden | Subscription is not active |
| 409 | idempotency_conflict | Same idempotency key used with a different request body |
| 429 | rate_limit_exceeded | Too many requests. See Rate Limits. |
| 500 | internal_error | Failed to download or store the media file |
Next Steps
| Topic | Description |
|---|---|
| Posts API | Use uploaded media in post submissions |
| Templates API | Generate OG images programmatically |
| Media Formats & Limits | Platform-specific media requirements |