Documentation
¶
Overview ¶
Package apiv1 holds the public API's request and response types. They are shared by the Lambda that serves the API, the Go client used by the CLI and the MCP server, and the usage report embedded in the dashboard.
Index ¶
- Constants
- type APIError
- type Account
- type AccountList
- type AnalyticsAccount
- type AnalyticsPlatformRow
- type AnalyticsPost
- type AnalyticsQuery
- type AnalyticsRange
- type AnalyticsReport
- type AnalyticsSummary
- type Client
- func (c *Client) ConnectAccount(ctx context.Context, req ConnectAccountRequest) (*ConnectLink, error)
- func (c *Client) CreatePost(ctx context.Context, req CreatePostRequest) (*Post, error)
- func (c *Client) CreateQueue(ctx context.Context, req CreateQueueRequest) (*Queue, error)
- func (c *Client) CreateUpload(ctx context.Context, req CreateUploadRequest) (*Upload, error)
- func (c *Client) DeletePost(ctx context.Context, id string) (*DeletePostResponse, error)
- func (c *Client) DeletePosts(ctx context.Context, req DeletePostsRequest) (*DeletePostsResponse, error)
- func (c *Client) DeleteQueue(ctx context.Context, id string) (*DeleteQueueResponse, error)
- func (c *Client) GetAnalytics(ctx context.Context, query AnalyticsQuery) (*AnalyticsReport, error)
- func (c *Client) GetPost(ctx context.Context, id string) (*Post, error)
- func (c *Client) GetUpload(ctx context.Context, id string) (*Upload, error)
- func (c *Client) GetUsage(ctx context.Context) (*UsageReport, error)
- func (c *Client) ListAccounts(ctx context.Context) (*AccountList, error)
- func (c *Client) ListPosts(ctx context.Context, query ListPostsQuery) (*PostList, error)
- func (c *Client) ListProfiles(ctx context.Context) (*ProfileList, error)
- func (c *Client) ListQueues(ctx context.Context) (*QueueList, error)
- func (c *Client) UpdatePost(ctx context.Context, id string, req UpdatePostRequest) (*Post, error)
- func (c *Client) UpdateQueue(ctx context.Context, id string, req UpdateQueueRequest) (*Queue, error)
- type ConnectAccountRequest
- type ConnectLink
- type CreatePostRequest
- type CreateQueueRequest
- type CreateUploadRequest
- type DeletePostResponse
- type DeletePostsError
- type DeletePostsRequest
- type DeletePostsResponse
- type DeleteQueueResponse
- type Delivery
- type ErrorBody
- type ErrorDetail
- type InstagramOptions
- type InstagramUserTag
- type ListPostsQuery
- type Operations
- type Post
- type PostAuthor
- type PostList
- type PostQueue
- type Profile
- type ProfileList
- type Queue
- type QueueList
- type QueueSlot
- type TikTokOptions
- type UpdatePostRequest
- type UpdateQueueRequest
- type Upload
- type UsageCounter
- type UsageLinkCounter
- type UsagePeriod
- type UsagePlan
- type UsageRateLimits
- type UsageReport
- type XOptions
- type XPoll
- type XThreadTweet
- type YouTubeOptions
Constants ¶
const ( // StatusDraft is a post saved without a time; it goes nowhere until it is // scheduled or published with PATCH /v1/posts/{id}. StatusDraft = "draft" StatusScheduled = "scheduled" StatusPending = "pending" StatusProcessing = "processing" StatusPublished = "published" StatusFailed = "failed" StatusPartial = "partial" StatusCancelled = "cancelled" )
Post statuses as exposed by the API (lower case, "published" instead of the internal SUCCESS).
const ( CodeInsufficientScope = "insufficient_scope" CodeSubscriptionRequired = "subscription_required" // CodeWorkspaceForbidden means the key or connection was made for a team // workspace its holder can no longer work in: they left or were removed, // or the owner's plan no longer includes teams. CodeWorkspaceForbidden = "workspace_forbidden" CodeRateLimited = "rate_limited" CodeQuotaExceeded = "quota_exceeded" CodeValidation = "validation_error" CodeNotFound = "not_found" CodeInternal = "internal_error" )
Error codes returned in the error envelope.
const ( XRepliesFollowing = "following" XRepliesMentionedUsers = "mentioned_users" XRepliesSubscribers = "subscribers" XRepliesVerified = "verified" )
X reply audiences for XOptions.ReplySettings. Empty means everyone.
const ( TikTokPublic = "public_to_everyone" TikTokFriends = "mutual_follow_friends" TikTokFollowers = "follower_of_creator" TikTokPrivate = "self_only" )
TikTok privacy levels for TikTokOptions.Privacy.
const ( YouTubePublic = "public" YouTubeUnlisted = "unlisted" YouTubePrivate = "private" )
YouTube privacy statuses for YouTubeOptions.Privacy.
const DefaultBaseURL = "https://api.postatron.com"
DefaultBaseURL is the production API host.
const MaxBulkDelete = 100
MaxBulkDelete is the most posts one DeletePosts call takes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
Status int
Code string
Message string
Details map[string]any
RetryAfter time.Duration
}
APIError is returned by Client for non-2xx responses.
type Account ¶
type Account struct {
ID string `json:"id"`
Platform string `json:"platform"`
Username string `json:"username"`
DisplayName string `json:"display_name"`
Status string `json:"status"`
ProfileID string `json:"profile_id"`
ProfileName string `json:"profile_name"`
ConnectedAt time.Time `json:"connected_at"`
}
Account is a connected social account. Every account belongs to exactly one profile, and a profile holds at most one account per platform.
type AccountList ¶
type AccountList struct {
Data []Account `json:"data"`
}
AccountList is the response of GET /v1/accounts.
type AnalyticsAccount ¶ added in v1.1.0
type AnalyticsAccount struct {
ID string `json:"id"`
Platform string `json:"platform"`
Username string `json:"username"`
Followers int64 `json:"followers"`
Supported bool `json:"supported"`
// Status is "ok", "unsupported", "reconnect_required", "unavailable" or "error".
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
}
AnalyticsAccount says whether an account's numbers could be read.
type AnalyticsPlatformRow ¶ added in v1.1.0
type AnalyticsPlatformRow struct {
Platform string `json:"platform"`
Posts int `json:"posts"`
Likes int64 `json:"likes"`
Comments int64 `json:"comments"`
Views int64 `json:"views"`
}
AnalyticsPlatformRow totals one platform.
type AnalyticsPost ¶ added in v1.1.0
type AnalyticsPost struct {
Platform string `json:"platform"`
Username string `json:"username"`
URL string `json:"url"`
Text string `json:"text"`
PublishedAt string `json:"published_at"`
Likes *int64 `json:"likes"`
Comments *int64 `json:"comments"`
Views *int64 `json:"views"`
Reach *int64 `json:"reach"`
Saves *int64 `json:"saves"`
Impressions *int64 `json:"impressions"`
Clicks *int64 `json:"clicks"`
Follows *int64 `json:"follows"`
Engagement int64 `json:"engagement"`
FromPostatron bool `json:"posted_with_postatron"`
}
AnalyticsPost is one of the best performing posts in the window.
type AnalyticsQuery ¶ added in v1.1.0
type AnalyticsQuery struct {
// Range is 7d, 30d or 90d (default 30d).
Range string
// Platform limits the report to one platform, e.g. instagram.
Platform string
// AccountID limits the report to one connected account.
AccountID string
// Profile is a profile id or name.
Profile string
// Source is "all" (default) or "postatron" for posts made with Postatron only.
Source string
}
AnalyticsQuery holds the filters accepted by GET /v1/analytics.
type AnalyticsRange ¶ added in v1.1.0
type AnalyticsRange struct {
Key string `json:"key"`
Start string `json:"start"`
End string `json:"end"`
}
AnalyticsRange is the window the report covers.
type AnalyticsReport ¶ added in v1.1.0
type AnalyticsReport struct {
Range AnalyticsRange `json:"range"`
Summary AnalyticsSummary `json:"summary"`
PerPlatform []AnalyticsPlatformRow `json:"per_platform"`
TopPosts []AnalyticsPost `json:"top_posts"`
Accounts []AnalyticsAccount `json:"accounts"`
GeneratedAt string `json:"generated_at"`
Notes []string `json:"notes,omitempty"`
}
AnalyticsReport is the response of GET /v1/analytics. A metric a platform does not report is null, never a negative number.
type AnalyticsSummary ¶ added in v1.1.0
type AnalyticsSummary struct {
EngagementRate float64 `json:"engagement_rate_percent"`
EngagementRateBasis string `json:"engagement_rate_basis"`
Engagements int64 `json:"engagements"`
Reach int64 `json:"reach"`
Followers int64 `json:"followers"`
PostsThisPeriod int `json:"posts_this_period"`
}
AnalyticsSummary holds the headline numbers.
type Client ¶
Client calls the public API with an API key.
func (*Client) ConnectAccount ¶ added in v1.5.0
func (c *Client) ConnectAccount(ctx context.Context, req ConnectAccountRequest) (*ConnectLink, error)
ConnectAccount calls POST /v1/accounts/connect.
func (*Client) CreatePost ¶
CreatePost calls POST /v1/posts.
func (*Client) CreateQueue ¶ added in v1.8.0
CreateQueue calls POST /v1/queues.
func (*Client) CreateUpload ¶ added in v1.1.0
CreateUpload calls POST /v1/media/uploads.
func (*Client) DeletePost ¶
DeletePost calls DELETE /v1/posts/{id}.
func (*Client) DeletePosts ¶ added in v1.8.0
func (c *Client) DeletePosts(ctx context.Context, req DeletePostsRequest) (*DeletePostsResponse, error)
DeletePosts calls POST /v1/posts/bulk-delete.
func (*Client) DeleteQueue ¶ added in v1.8.0
DeleteQueue calls DELETE /v1/queues/{id}. id may also be the queue's name.
func (*Client) GetAnalytics ¶ added in v1.1.0
func (c *Client) GetAnalytics(ctx context.Context, query AnalyticsQuery) (*AnalyticsReport, error)
GetAnalytics calls GET /v1/analytics.
func (*Client) GetUsage ¶
func (c *Client) GetUsage(ctx context.Context) (*UsageReport, error)
GetUsage calls GET /v1/usage.
func (*Client) ListAccounts ¶
func (c *Client) ListAccounts(ctx context.Context) (*AccountList, error)
ListAccounts calls GET /v1/accounts.
func (*Client) ListProfiles ¶ added in v1.1.0
func (c *Client) ListProfiles(ctx context.Context) (*ProfileList, error)
ListProfiles calls GET /v1/profiles.
func (*Client) ListQueues ¶ added in v1.7.0
ListQueues calls GET /v1/queues.
func (*Client) UpdatePost ¶ added in v1.5.0
UpdatePost calls PATCH /v1/posts/{id}.
func (*Client) UpdateQueue ¶ added in v1.8.0
func (c *Client) UpdateQueue(ctx context.Context, id string, req UpdateQueueRequest) (*Queue, error)
UpdateQueue calls PATCH /v1/queues/{id}. id may also be the queue's name.
type ConnectAccountRequest ¶ added in v1.5.0
type ConnectAccountRequest struct {
// Platform is the network to connect: x, instagram, facebook, linkedin,
// tiktok, youtube, threads or bluesky.
Platform string `json:"platform"`
// Profile is the profile (name or id) the new account goes into.
Profile string `json:"profile,omitempty"`
}
ConnectAccountRequest is the body of POST /v1/accounts/connect.
type ConnectLink ¶ added in v1.5.0
type ConnectLink struct {
Platform string `json:"platform"`
ConnectURL string `json:"connect_url"`
Profile string `json:"profile,omitempty"`
Hint string `json:"hint"`
}
ConnectLink is a link the person opens to connect a social account. It opens Postatron and starts that platform's sign-in; nothing is connected until they finish it there.
type CreatePostRequest ¶
type CreatePostRequest struct {
Content string `json:"content"`
AccountIDs []string `json:"account_ids,omitempty"`
Platforms []string `json:"platforms,omitempty"`
Profile string `json:"profile,omitempty"`
MediaURLs []string `json:"media_urls,omitempty"`
MediaIDs []string `json:"media_ids,omitempty"`
ScheduledAt *time.Time `json:"scheduled_at,omitempty"`
// Queue (a name or id from GET /v1/queues) schedules the post for that
// queue's next free slot instead of ScheduledAt. Its accounts must all be
// in the queue's profile, which is also what Platforms means when Profile
// is left out.
Queue string `json:"queue,omitempty"`
// X, Instagram, TikTok and YouTube hold the options only that platform
// has. Each needs an account on its platform among the post's accounts.
X *XOptions `json:"x,omitempty"`
Instagram *InstagramOptions `json:"instagram,omitempty"`
TikTok *TikTokOptions `json:"tiktok,omitempty"`
YouTube *YouTubeOptions `json:"youtube,omitempty"`
}
CreatePostRequest is the body of POST /v1/posts. Exactly one of AccountIDs or Platforms must be set. ScheduledAt omitted publishes immediately.
Profile (an id or a name from ListProfiles) limits Platforms to the accounts in that profile. It is required when a platform has an account in more than one profile, so a post never fans out to every client by accident.
MediaURLs are public https links the server downloads; MediaIDs are upload ids from CreateUpload. Instagram and TikTok need at least one image or video, YouTube a video.
type CreateQueueRequest ¶ added in v1.8.0
type CreateQueueRequest struct {
Name string `json:"name"`
// Profile is the profile (name or id) the queue posts for; Default when
// left out. A post added to the queue must go to accounts in it.
Profile string `json:"profile,omitempty"`
// Timezone is an IANA name such as Europe/London; slot times are wall
// clock times there, across daylight saving.
Timezone string `json:"timezone"`
Slots []QueueSlot `json:"slots,omitempty"`
// Paused creates the queue paused, taking no posts until resumed.
Paused bool `json:"paused,omitempty"`
}
CreateQueueRequest is the body of POST /v1/queues.
type CreateUploadRequest ¶ added in v1.1.0
type CreateUploadRequest struct {
// Purpose is shown to the person on the upload page, e.g. "the launch video".
Purpose string `json:"purpose,omitempty"`
}
CreateUploadRequest is the body of POST /v1/media/uploads.
type DeletePostResponse ¶
type DeletePostResponse struct {
ID string `json:"id"`
Status string `json:"status"`
Deleted bool `json:"deleted"`
Cancelled bool `json:"cancelled"`
Message string `json:"message,omitempty"`
}
DeletePostResponse is the response of DELETE /v1/posts/{id}.
Deleted is true when the post is gone from Postatron. For a scheduled post that also means Cancelled: it will never go out. A published post is only removed from Postatron and stays on the platforms; Message says so. A post being published right now, or due within two minutes, is refused with Deleted false and Message saying why.
type DeletePostsError ¶ added in v1.8.0
DeletePostsError says why one post was not deleted.
type DeletePostsRequest ¶ added in v1.8.0
type DeletePostsRequest struct {
IDs []string `json:"ids"`
}
DeletePostsRequest is the body of POST /v1/posts/bulk-delete.
type DeletePostsResponse ¶ added in v1.8.0
type DeletePostsResponse struct {
Deleted []string `json:"deleted"`
Failed []DeletePostsError `json:"failed"`
Message string `json:"message,omitempty"`
}
DeletePostsResponse is the response of POST /v1/posts/bulk-delete: every id is in exactly one of Deleted and Failed. As with DeletePost, published posts are only removed from Postatron, never from the platforms.
type DeleteQueueResponse ¶ added in v1.8.0
type DeleteQueueResponse struct {
ID string `json:"id"`
Deleted bool `json:"deleted"`
Message string `json:"message,omitempty"`
}
DeleteQueueResponse is the response of DELETE /v1/queues/{id}. Posts the queue had already placed stay scheduled.
type Delivery ¶
type Delivery struct {
AccountID string `json:"account_id"`
Platform string `json:"platform"`
Username string `json:"username"`
Status string `json:"status"`
URL string `json:"url,omitempty"`
// Error says why a delivery failed. On a published one it says what
// did not go through after the post itself, such as a first comment or
// a YouTube thumbnail.
Error string `json:"error,omitempty"`
}
Delivery is the per-platform state of a post.
type ErrorBody ¶
type ErrorBody struct {
Error ErrorDetail `json:"error"`
}
ErrorBody is the JSON envelope for every non-2xx response.
type ErrorDetail ¶
type ErrorDetail struct {
Code string `json:"code"`
Message string `json:"message"`
Details map[string]any `json:"details,omitempty"`
}
ErrorDetail carries a stable machine-readable code and a human message.
type InstagramOptions ¶ added in v1.8.0
type InstagramOptions struct {
// PostType is auto (the default: chosen from the media), feed, story,
// reel or carousel.
PostType string `json:"post_type,omitempty"`
// Caption replaces the post's text on Instagram only.
Caption string `json:"caption,omitempty"`
// FirstComment is posted as the first comment, often for hashtags. Not
// on stories.
FirstComment string `json:"first_comment,omitempty"`
// Collaborators are up to 3 usernames invited to co-author the post.
Collaborators []string `json:"collaborators,omitempty"`
// UserTags tag people on images.
UserTags []InstagramUserTag `json:"user_tags,omitempty"`
// AIGenerated asks Instagram to show its AI-content label.
AIGenerated bool `json:"ai_generated,omitempty"`
// TrialReel shares a reel with non-followers first: manual (graduate it
// by hand) or performance (Instagram graduates it if it does well).
TrialReel string `json:"trial_reel,omitempty"`
}
InstagramOptions are the settings only Instagram has.
type InstagramUserTag ¶ added in v1.8.0
type InstagramUserTag struct {
Username string `json:"username"`
X float64 `json:"x"`
Y float64 `json:"y"`
MediaIndex int `json:"media_index,omitempty"`
}
InstagramUserTag tags a username on one image, at X and Y from 0 to 1 across and down it. MediaIndex counts the post's media from 0.
type ListPostsQuery ¶
type ListPostsQuery struct {
Status string
Platform string
// Profile is a profile id or name; only posts to its accounts are listed.
Profile string
From *time.Time
To *time.Time
Limit int
Cursor string
}
ListPostsQuery holds the filters accepted by GET /v1/posts.
type Operations ¶
type Operations interface {
CreatePost(ctx context.Context, req CreatePostRequest) (*Post, error)
ListPosts(ctx context.Context, query ListPostsQuery) (*PostList, error)
GetPost(ctx context.Context, id string) (*Post, error)
UpdatePost(ctx context.Context, id string, req UpdatePostRequest) (*Post, error)
DeletePost(ctx context.Context, id string) (*DeletePostResponse, error)
DeletePosts(ctx context.Context, req DeletePostsRequest) (*DeletePostsResponse, error)
ListAccounts(ctx context.Context) (*AccountList, error)
ConnectAccount(ctx context.Context, req ConnectAccountRequest) (*ConnectLink, error)
ListProfiles(ctx context.Context) (*ProfileList, error)
ListQueues(ctx context.Context) (*QueueList, error)
CreateQueue(ctx context.Context, req CreateQueueRequest) (*Queue, error)
UpdateQueue(ctx context.Context, id string, req UpdateQueueRequest) (*Queue, error)
DeleteQueue(ctx context.Context, id string) (*DeleteQueueResponse, error)
GetUsage(ctx context.Context) (*UsageReport, error)
GetAnalytics(ctx context.Context, query AnalyticsQuery) (*AnalyticsReport, error)
CreateUpload(ctx context.Context, req CreateUploadRequest) (*Upload, error)
GetUpload(ctx context.Context, id string) (*Upload, error)
}
Operations is the public API surface. Client implements it over HTTP; the MCP server and CLI consume it.
type Post ¶
type Post struct {
ID string `json:"id"`
Status string `json:"status"`
Content string `json:"content"`
MediaType string `json:"media_type"`
ContainsLink bool `json:"contains_link"`
ScheduledAt *time.Time `json:"scheduled_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
Deliveries []Delivery `json:"deliveries"`
// Source is where the post was made: dashboard, api or mcp. Empty on
// posts from before it was recorded.
Source string `json:"source,omitempty"`
// CreatedBy is the person who made the post, and UpdatedBy whoever last
// changed it, when someone has. They differ in a team workspace.
CreatedBy *PostAuthor `json:"created_by,omitempty"`
UpdatedBy *PostAuthor `json:"updated_by,omitempty"`
// Queue is the queue that chose the post's time, when one did.
Queue *PostQueue `json:"queue,omitempty"`
// The platform options the post was saved with, when it has any.
X *XOptions `json:"x,omitempty"`
Instagram *InstagramOptions `json:"instagram,omitempty"`
TikTok *TikTokOptions `json:"tiktok,omitempty"`
YouTube *YouTubeOptions `json:"youtube,omitempty"`
}
Post is the API representation of a post.
type PostAuthor ¶ added in v1.8.0
PostAuthor names a person on the account. Name is empty when the person has since left the team or deleted their account.
type PostQueue ¶ added in v1.8.0
PostQueue names the queue a post came from. Name is empty when the queue has since been deleted.
type Profile ¶ added in v1.1.0
type Profile struct {
ID string `json:"id"`
Name string `json:"name"`
IsDefault bool `json:"is_default"`
Accounts []Account `json:"accounts"`
}
Profile groups connected accounts, typically one per brand or client. Every account has a Default profile; paid plans can add more.
type ProfileList ¶ added in v1.1.0
type ProfileList struct {
Data []Profile `json:"data"`
}
ProfileList is the response of GET /v1/profiles.
type Queue ¶ added in v1.7.0
type Queue struct {
ID string `json:"id"`
Name string `json:"name"`
ProfileID string `json:"profile_id"`
ProfileName string `json:"profile_name"`
Timezone string `json:"timezone"`
Slots []QueueSlot `json:"slots"`
// Active is false while the queue is paused and takes no new posts.
Active bool `json:"active"`
// NextSlot is when a post added now would go out; nil when none would,
// with NextSlotError saying why.
NextSlot *time.Time `json:"next_slot,omitempty"`
NextSlotError string `json:"next_slot_error,omitempty"`
// Queued is how many of its posts are still to go out.
Queued int `json:"queued"`
}
Queue is a weekly posting schedule for one profile. Posts added to it go out in its next free slot.
type QueueList ¶ added in v1.7.0
type QueueList struct {
Data []Queue `json:"data"`
}
QueueList is the response of GET /v1/queues.
type QueueSlot ¶ added in v1.7.0
QueueSlot is a weekly posting time: Day 0 is Sunday to 6 Saturday, Time "HH:MM" in the queue's timezone.
type TikTokOptions ¶ added in v1.8.0
type TikTokOptions struct {
// Title is a video's caption, up to 2200 characters, replacing the
// post's text there; or a photo post's title, up to 90. TikTok counts
// characters in UTF-16, so an emoji counts as two.
Title string `json:"title,omitempty"`
// Description is a photo post's long description, up to 4000
// characters; it replaces the post's text there.
Description string `json:"description,omitempty"`
// Draft uploads to the creator's TikTok inbox instead of publishing.
Draft bool `json:"draft,omitempty"`
// Privacy is public_to_everyone, mutual_follow_friends,
// follower_of_creator or self_only.
Privacy string `json:"privacy,omitempty"`
DisableComment *bool `json:"disable_comment,omitempty"`
DisableDuet *bool `json:"disable_duet,omitempty"`
DisableStitch *bool `json:"disable_stitch,omitempty"`
CommercialContent *bool `json:"commercial_content,omitempty"`
// YourBrand discloses promotion of the creator's own business.
YourBrand *bool `json:"your_brand,omitempty"`
// BrandedContent discloses a paid partnership; it cannot be private.
BrandedContent *bool `json:"branded_content,omitempty"`
// MusicUsageConfirmed is the person agreeing to TikTok's Music Usage
// Confirmation, which TikTok requires before it publishes.
MusicUsageConfirmed *bool `json:"music_usage_confirmed,omitempty"`
// AutoAddMusic lets TikTok add recommended music to a photo post.
AutoAddMusic bool `json:"auto_add_music,omitempty"`
// AIGenerated asks TikTok to label the post as AI-generated.
AIGenerated bool `json:"ai_generated,omitempty"`
}
TikTokOptions are the settings TikTok asks for. A post is published directly once Privacy is given, and TikTok then needs the creator's choice of each of Privacy, DisableComment, CommercialContent and MusicUsageConfirmed, plus DisableDuet and DisableStitch for a video, and one of YourBrand or BrandedContent when CommercialContent is true.
With Draft, or with the whole block left out, the post goes to the creator's TikTok inbox instead, and they finish it in the app: a draft takes only Title and Description (photos), and a video draft takes neither.
type UpdatePostRequest ¶ added in v1.5.0
type UpdatePostRequest struct {
// Content replaces the post's text.
Content *string `json:"content,omitempty"`
// ScheduledAt moves the post, or schedules a draft, at least 5 minutes ahead.
ScheduledAt *time.Time `json:"scheduled_at,omitempty"`
// PublishNow publishes the post straight away, after any other change in
// the same request. It cannot be combined with ScheduledAt.
PublishNow bool `json:"publish_now,omitempty"`
// AddPlatforms adds the account on each platform (in Profile), the way
// CreatePostRequest.Platforms chooses them.
AddPlatforms []string `json:"add_platforms,omitempty"`
// AddAccountIDs adds specific connected accounts.
AddAccountIDs []string `json:"add_account_ids,omitempty"`
// RemoveAccountIDs takes accounts off the post; at least one must remain.
RemoveAccountIDs []string `json:"remove_account_ids,omitempty"`
// Profile chooses which brand AddPlatforms means.
Profile string `json:"profile,omitempty"`
// X, Instagram, TikTok and YouTube replace that platform's options as a
// whole; an empty object ({}) clears them.
X *XOptions `json:"x,omitempty"`
Instagram *InstagramOptions `json:"instagram,omitempty"`
TikTok *TikTokOptions `json:"tiktok,omitempty"`
YouTube *YouTubeOptions `json:"youtube,omitempty"`
}
UpdatePostRequest is the body of PATCH /v1/posts/{id}. Every field is optional and anything left out keeps its value. A draft or a scheduled post can change; once it has started publishing it is fixed. A draft stays a draft unless ScheduledAt or PublishNow says when it goes out.
type UpdateQueueRequest ¶ added in v1.8.0
type UpdateQueueRequest struct {
Name *string `json:"name,omitempty"`
Profile *string `json:"profile,omitempty"`
Timezone *string `json:"timezone,omitempty"`
Slots *[]QueueSlot `json:"slots,omitempty"`
// Active false pauses the queue; true resumes it.
Active *bool `json:"active,omitempty"`
}
UpdateQueueRequest is the body of PATCH /v1/queues/{id}. Anything left out keeps its value. Changing the slots or pausing the queue leaves posts it has already placed where they are.
type Upload ¶ added in v1.1.0
type Upload struct {
ID string `json:"id"`
Status string `json:"status"`
UploadURL string `json:"upload_url,omitempty"`
Filename string `json:"filename,omitempty"`
ExpiresAt string `json:"expires_at"`
Hint string `json:"hint,omitempty"`
}
Upload is a slot a person drops a file into from the dashboard, for an agent that cannot send the bytes itself. Pass its ID to CreatePost as MediaIDs once Status is "ready".
type UsageCounter ¶
type UsageCounter struct {
Used int `json:"used"`
Limit int `json:"limit"`
Remaining int `json:"remaining"`
}
UsageCounter is a capped counter. Limit is what the plan includes each month and is also the hard stop: there is no overage on any plan.
type UsageLinkCounter ¶
type UsageLinkCounter struct {
Used int `json:"used"`
}
UsageLinkCounter counts link-containing destination-posts across all platforms.
type UsagePeriod ¶
UsagePeriod is the calendar month the counters belong to.
type UsagePlan ¶
type UsagePlan struct {
Code string `json:"code"`
Name string `json:"name"`
Interval string `json:"interval"`
Status string `json:"status"`
ConnectedAccounts int `json:"connected_accounts"`
MaxConnectedAccounts int `json:"max_connected_accounts"`
}
UsagePlan summarises the subscription the quota comes from.
type UsageRateLimits ¶
type UsageRateLimits struct {
WritesPerMinute int `json:"writes_per_minute"`
ReadsPerMinute int `json:"reads_per_minute"`
UploadsPerMinute int `json:"uploads_per_minute"`
// WritesPerHour is WritesPerMinute * 60, kept for clients written before
// the write window became per minute.
//
// Deprecated: use WritesPerMinute.
WritesPerHour int `json:"writes_per_hour"`
}
UsageRateLimits echoes the per-key limits applied to this plan.
type UsageReport ¶
type UsageReport struct {
Period UsagePeriod `json:"period"`
Plan UsagePlan `json:"plan"`
DestinationPosts UsageCounter `json:"destination_posts"`
LinkPosts UsageLinkCounter `json:"link_posts"`
XLinkPosts UsageCounter `json:"x_link_posts"`
ByPlatform map[string]int `json:"by_platform"`
RateLimits UsageRateLimits `json:"rate_limits"`
}
UsageReport is the response of GET /v1/usage. The dashboard renders the same structure.
type XOptions ¶ added in v1.8.0
type XOptions struct {
// Content replaces the post's text on X only.
Content string `json:"content,omitempty"`
// Thread adds replies under the first tweet, in order: Thread[0] is the
// second tweet. A thread cannot go into a Community.
Thread []XThreadTweet `json:"thread,omitempty"`
// Community is the id of the X Community to post into, or its link
// (https://x.com/i/communities/<id>).
Community string `json:"community,omitempty"`
ShareWithFollowers bool `json:"share_with_followers,omitempty"`
// ReplySettings limits who can reply: following, mentioned_users,
// subscribers or verified. Empty lets everyone reply.
ReplySettings string `json:"reply_settings,omitempty"`
// LongPost allows tweets over 280 characters, which X accepts from
// Premium accounts only.
LongPost bool `json:"long_post,omitempty"`
// Poll makes the first tweet a poll. A poll cannot carry media.
Poll *XPoll `json:"poll,omitempty"`
}
XOptions are the settings only X has.
type XPoll ¶ added in v1.8.0
type XPoll struct {
Options []string `json:"options"`
DurationMinutes int `json:"duration_minutes,omitempty"`
}
XPoll is a poll on the first tweet: 2 to 4 options of up to 25 characters, open for 5 minutes to 7 days (default one day).
type XThreadTweet ¶ added in v1.8.0
type XThreadTweet struct {
Content string `json:"content"`
MediaURLs []string `json:"media_urls,omitempty"`
MediaIDs []string `json:"media_ids,omitempty"`
}
XThreadTweet is one reply in a thread. Media works as on the post itself; when a post is read back, MediaURLs holds the media it carries.
type YouTubeOptions ¶ added in v1.9.0
type YouTubeOptions struct {
// Title is up to 100 characters, without < or >. Left out, it is the
// first line of the content.
Title string `json:"title,omitempty"`
// Description replaces the content as the video's description: up to
// 5000 bytes, without < or >.
Description string `json:"description,omitempty"`
// Privacy is public (the default), unlisted or private.
Privacy string `json:"privacy,omitempty"`
// MadeForKids is the uploader's declaration that the video is made for
// children, which YouTube asks of every upload. Ask the person rather
// than choosing; left out, nothing is declared and the channel's default
// audience setting, if it has one, applies.
MadeForKids *bool `json:"made_for_kids,omitempty"`
// Tags are up to 500 characters in all, counting a comma between tags
// and quotes around a tag with a space in it.
Tags []string `json:"tags,omitempty"`
// CategoryID is a YouTube category id: 1 Film & Animation, 2 Autos &
// Vehicles, 10 Music, 15 Pets & Animals, 17 Sports, 19 Travel & Events,
// 20 Gaming, 22 People & Blogs (the default), 23 Comedy, 24
// Entertainment, 25 News & Politics, 26 Howto & Style, 27 Education, 28
// Science & Technology or 29 Nonprofits & Activism.
CategoryID string `json:"category_id,omitempty"`
// FirstComment is posted on the video once it is up, up to 10000
// characters. The channel must have allowed first comments in the
// dashboard composer, and a video made for kids takes no comments.
FirstComment string `json:"first_comment,omitempty"`
// ThumbnailURL (a public https link to a JPEG or PNG) or ThumbnailID
// (an upload id from CreateUpload) sets a custom thumbnail, which
// YouTube allows only on verified channels. When a post is read back,
// ThumbnailURL holds the thumbnail it carries.
ThumbnailURL string `json:"thumbnail_url,omitempty"`
ThumbnailID string `json:"thumbnail_id,omitempty"`
}
YouTubeOptions are the settings only YouTube has. Leave the block out to upload a public video titled with the first line of the content, described by the content, in People & Blogs.