Errors
All errors use the same JSON shape, whether they come back from a request or appear in a post result or webhook. Branch on code, show message to people.
Updated
Format
json
{
"error": {
"code": "invalid_request",
"message": "media must be an array of URLs."
}
}code is stable and safe to branch on. message is for humans and may change. In post results and post.failed webhooks, the same { code, message } object appears as error.
Codes
| Code | HTTP | Meaning | What to do |
|---|---|---|---|
unauthorized | 401 | Missing, malformed or revoked API key. | Check the Authorization: Bearer ugc_live_... header. See authentication. |
insufficient_credits | 402 | Not enough credits for the results this request would create. | Buy a pack in the dashboard. See pricing and credits. |
invalid_request | 400 | A field is missing, has the wrong type, or the format isn't supported on a platform. | Read the message and fix the field. |
account_not_found | 404 | An account ID doesn't exist, was disconnected, or isn't yours. | List accounts with GET /v1/accounts, reconnect if needed. |
media_unreachable | 422 | A media URL couldn't be downloaded. | Make the URL public and direct, or upload with POST /v1/media. |
platform_rejected | 422 | The platform refused the content or request. The message carries the platform's reason. | Fix the content or account setting the message names. |
rate_limited | 429 | Too many requests to our API, or a platform limit was hit. | Wait and retry with backoff. |
Request errors vs result errors
- Request errors come back right away with an HTTP status. Nothing was created.
- Result errors happen later, when a platform processes a scheduled post. The request returned 200, and the failed result has
status: 'failed'and anerror. You also get apost.failedwebhook.
Common platform_rejected reasons
| Platform | Typical reason |
|---|---|
| TikTok | Creator's daily posting cap reached; privacy level not allowed for the account; video too long for the creator. |
| Account isn't Business or Creator; daily publishing limit reached; unsupported media. | |
| Reel outside 3 to 90 seconds; Page permission removed. | |
| YouTube | Upload quota reached; channel can't upload. |
Per-platform caps are in limits.
Handling errors in code
javascript
const res = await fetch("https://ugcapi.dev/v1/posts", { method: "POST", headers, body });
if (!res.ok) {
const { error } = await res.json();
switch (error.code) {
case "insufficient_credits": return showTopUp();
case "rate_limited": return retryLater();
case "account_not_found": return askToReconnect();
default: throw new Error(error.code + ": " + error.message);
}
}Retry only rate_limited and network errors automatically. Other codes need a change before a retry can succeed. For webhook-side handling, see webhooks for social publishing.
FAQ
Am I charged for failed posts?
No. Credits are used only for results that publish.
Should I retry platform_rejected errors?
Not unchanged. Read the message, fix the cause, then create a new post.
Will new error codes be added?
Possibly. Treat unknown codes like a generic failure and show the message.