API
The OneScrip API lets your own systems and scripts add posts (items) to OneScrip, including posts with images or videos.
Create an API key
- In the OneScrip dashboard, open "API Keys" in the sidebar
- Click "Create new Key"
- Enter a label you will recognize, and under permissions check "Add items (posts, images, videos)"
- Click "Create" and copy the secret that is shown
The secret is shown only once, right after the key is created. OneScrip does not store it, so it cannot be shown again. If you lose it, delete the key and create a new one.
- Only project owners and admins can create or delete API keys
- The number of keys you can create depends on your plan
- A key can only access data in the project it was created for
Basics
| Item | Details |
|---|---|
| Base URL | https://api.onescrip.com/v1 |
| Authentication | Authorization: Bearer <API key> or X-API-Key: <API key> header |
| Rate limit | 60 requests per minute per API key |
| Response format | JSON |
Treat your API key like a password and only use it from secure places such as servers or scripts. Calls from JavaScript running in a browser (CORS) are not supported.
List contents
GET /contents
Returns the contents in your project. Use it to find the id of the content you want to add posts to.
curl https://api.onescrip.com/v1/contents \
-H "Authorization: Bearer $ONESCRIP_API_KEY"
{
"contents": [
{
"id": "6f1c2a4e-....",
"name": "Official account posts",
"description": null,
"type": "social",
"folderId": null
}
]
}
Posts can only be added to contents whose type is social.
Add a post
POST /contents/{contentId}/items
Send text-only posts as JSON. To attach image or video files, use multipart/form-data.
| Parameter | Type | Description |
|---|---|---|
value | string (required) | Post text, up to 1000 characters |
key | string | Optional key to identify the post |
images | file | Image file. JPEG / PNG / WebP / GIF, up to 5MB each |
imageUrls | array of strings | Image URLs. OneScrip downloads and stores the images |
video | file | Video file. MP4 / WebM / MOV / AVI, up to 50MB |
videoUploadId | string | ID of a large video you uploaded beforehand (see below) |
videoThumbnail | file | Thumbnail image for the video. If omitted, one is created from the video |
- You can attach up to 4 images in total (
imagesplusimageUrls), or 1 video - A post cannot have both images and a video
- Images are converted to WebP when stored
On success, the API returns 201 with the ID of the new post.
{ "id": "0b8d5c1f-...." }
Text-only post
curl -X POST https://api.onescrip.com/v1/contents/$CONTENT_ID/items \
-H "Authorization: Bearer $ONESCRIP_API_KEY" \
-H "Content-Type: application/json" \
-d '{"value": "Our new product is here"}'
Post with images
curl -X POST https://api.onescrip.com/v1/contents/$CONTENT_ID/items \
-H "Authorization: Bearer $ONESCRIP_API_KEY" \
-F "value=Our new product is here" \
-F "images=@./photo1.jpg" \
-F "images=@./photo2.png"
Image URLs can be sent as JSON.
curl -X POST https://api.onescrip.com/v1/contents/$CONTENT_ID/items \
-H "Authorization: Bearer $ONESCRIP_API_KEY" \
-H "Content-Type: application/json" \
-d '{"value": "Our new product is here", "imageUrls": ["https://example.com/photo.jpg"]}'
Post with a video
Videos up to about 30MB can be attached directly.
curl -X POST https://api.onescrip.com/v1/contents/$CONTENT_ID/items \
-H "Authorization: Bearer $ONESCRIP_API_KEY" \
-F "value=A post with a video" \
-F "video=@./movie.mp4"
Upload a large video
A single request has a size limit of about 32MB. For larger videos (up to 50MB), use these three steps.
1. Request an upload URL
POST /contents/{contentId}/video-uploads
curl -X POST https://api.onescrip.com/v1/contents/$CONTENT_ID/video-uploads \
-H "Authorization: Bearer $ONESCRIP_API_KEY" \
-H "Content-Type: application/json" \
-d '{"contentType": "video/mp4", "size": 41943040}'
Set contentType to one of video/mp4, video/webm, video/quicktime or video/x-msvideo, and size to the file size in bytes.
{
"uploadId": "3e7a9b20-....",
"uploadUrl": "https://storage.googleapis.com/....",
"method": "PUT",
"headers": {
"Content-Type": "video/mp4",
"Cache-Control": "private, max-age=0",
"x-goog-if-generation-match": "0"
}
}
2. Upload the video file
PUT the file to uploadUrl with every header from headers. The upload fails if any of them is missing.
curl -X PUT "$UPLOAD_URL" \
-H "Content-Type: video/mp4" \
-H "Cache-Control: private, max-age=0" \
-H "x-goog-if-generation-match: 0" \
--data-binary @./movie.mp4
3. Add the post
Set videoUploadId to the uploadId from step 1.
curl -X POST https://api.onescrip.com/v1/contents/$CONTENT_ID/items \
-H "Authorization: Bearer $ONESCRIP_API_KEY" \
-H "Content-Type: application/json" \
-d '{"value": "A post with a video", "videoUploadId": "3e7a9b20-...."}'
Upload URLs expire 15 minutes after they are issued.
Errors
Errors return a message in this format.
{ "error": "Invalid API key" }
| Status | Meaning | Common causes |
|---|---|---|
400 | Invalid input | Empty text, unsupported file type or size, both images and a video attached |
401 | Authentication failed | Missing API key, or the key is wrong or deleted |
403 | Not allowed | The key lacks the permission, or your plan's post or storage limit was reached |
404 | Not found | The content ID is wrong or belongs to another project |
429 | Too many requests | Rate limit exceeded. Wait a moment and try again |
FAQ
Are posts added through the API published right away?
Posts added through the API are registered in the content just like posts added in the dashboard. When they are published depends on the content's posting settings and schedule.
What should I do if my API key leaks?
Delete the key from "API Keys" in the dashboard. A deleted key stops working immediately.