ampost 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +7 -0
- data/LICENSE +21 -0
- data/README.md +281 -0
- data/lib/ampost/client.rb +215 -0
- data/lib/ampost/errors.rb +162 -0
- data/lib/ampost/generated/resources.rb +922 -0
- data/lib/ampost/media.rb +130 -0
- data/lib/ampost/page.rb +85 -0
- data/lib/ampost/resource.rb +28 -0
- data/lib/ampost/transport.rb +56 -0
- data/lib/ampost/version.rb +5 -0
- data/lib/ampost.rb +19 -0
- metadata +63 -0
|
@@ -0,0 +1,922 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Generated by scripts/generate.rb from openapi.json. Do not edit by hand: run `ruby scripts/generate.rb`.
|
|
4
|
+
|
|
5
|
+
module Ampost
|
|
6
|
+
module Resources
|
|
7
|
+
# `platforms` operations: `client.platforms`.
|
|
8
|
+
class Platforms < Resource
|
|
9
|
+
# List platforms and their capabilities
|
|
10
|
+
#
|
|
11
|
+
# List every supported platform with its rules: text length, link support, scheduling, unpublish (delete a published post), editPublished (edit a published post's text), firstComment (comment posted after publish, and its length), thread (follow-up posts, and how many), media types, counts, sizes and required metadata, placements by media shape, and the JSON Schema of its `options`. `availability` is `coming_soon` for a platform that is listed but not open to every account yet: for those accounts, connecting it, posting to it and reading its posts or analytics return 403 PLATFORM_COMING_SOON. Read this instead of hardcoding platform differences, and check a post against these rules and its accounts with posts_validate before posts_create.
|
|
12
|
+
#
|
|
13
|
+
# MCP tool: `platforms_list`. Key scope: `posts:read`.
|
|
14
|
+
#
|
|
15
|
+
# `GET /api/platforms`
|
|
16
|
+
#
|
|
17
|
+
# Returns one page; `each` walks every item across pages.
|
|
18
|
+
#
|
|
19
|
+
# @param limit [Integer, nil] Page size, 1-100. Default 20.
|
|
20
|
+
# @param offset [Integer, nil] Number of items to skip. Default 0.
|
|
21
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
22
|
+
# @return [Ampost::Page] Items: `Platform` hashes.
|
|
23
|
+
def list(limit: nil, offset: nil, **options)
|
|
24
|
+
@client.paginate("GET", "/api/platforms", query: { "limit" => limit, "offset" => offset }, options: options)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# `posts` operations: `client.posts`.
|
|
29
|
+
class Posts < Resource
|
|
30
|
+
# List posts
|
|
31
|
+
#
|
|
32
|
+
# List your posts, newest first, optionally filtered by status, platform, platform set (posts with an account in it) or text.
|
|
33
|
+
#
|
|
34
|
+
# MCP tool: `posts_list`. Key scope: `posts:read`.
|
|
35
|
+
#
|
|
36
|
+
# `GET /api/posts`
|
|
37
|
+
#
|
|
38
|
+
# Returns one page; `each` walks every item across pages.
|
|
39
|
+
#
|
|
40
|
+
# @param status [String, nil] Only posts with this status: `draft`, `scheduled`, `queued`, `posting`, `published`, `partial`, `failed`, `discarded`, `deleted`
|
|
41
|
+
# @param platform [String, nil] Only posts with an account on this platform. One of: `instagram`, `facebook`, `linkedin`, `tiktok`, `threads`, `twitter`, `discord`, `telegram`, `bluesky`, `youtube`, `pinterest`.
|
|
42
|
+
# @param platform_set_id [String, nil] Only posts with an account in this platform set
|
|
43
|
+
# @param search [String, nil] Case-insensitive match on the post text
|
|
44
|
+
# @param limit [Integer, nil] Page size, 1-100. Default 20.
|
|
45
|
+
# @param offset [Integer, nil] Number of items to skip. Default 0.
|
|
46
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
47
|
+
# @return [Ampost::Page] Items: `Post` hashes.
|
|
48
|
+
def list(status: nil, platform: nil, platform_set_id: nil, search: nil, limit: nil, offset: nil, **options)
|
|
49
|
+
@client.paginate("GET", "/api/posts", query: { "status" => status, "platform" => platform, "platformSetId" => platform_set_id, "search" => search, "limit" => limit, "offset" => offset }, options: options)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Create, schedule or publish a post
|
|
53
|
+
#
|
|
54
|
+
# Create a post for one or more platforms. `targets` lists platform sets, each with its platforms; omit `platformSetId` for your default set. List several sets to reach several accounts of the same platform in one post (each set holds one account per platform); `platformPosts` then has one entry per account. Without `scheduledFor` it is a draft; set `publishNow` to publish it right away, or `scheduledFor` to publish later. `media` items are public URLs with a required `type` (REST also accepts multipart file uploads up to 4 MB per request; for larger files or files on the user's device use media_upload_create). Use `options.<platform>` for per-platform text and settings. `firstComment` is posted as a comment (a reply on X, Threads and Bluesky) on each new post right after it publishes; a failed comment leaves the post published with `platformPosts[].firstComment.status` failed. `thread` adds follow-up posts on X, Bluesky and Threads, each a reply to the one before (results in `platformPosts[].thread`). Call platforms_list (GET /api/platforms) for each platform's limits, placements and options.
|
|
55
|
+
#
|
|
56
|
+
# MCP tool: `posts_create`. Key scope: `posts:write`.
|
|
57
|
+
#
|
|
58
|
+
# `POST /api/posts`
|
|
59
|
+
#
|
|
60
|
+
# Sends an `Idempotency-Key`: yours (`idempotency_key:`), or a generated one kept across retries.
|
|
61
|
+
#
|
|
62
|
+
# @param body [Hash] The request body (`CreatePostRequest`), with the API's field names as keys.
|
|
63
|
+
# @option body [Array<Hash>] :targets Required. Where the post goes: one entry per platform set (max 10). A set holds one account per platform, so to reach several accounts of one platform (two LinkedIn accounts, several clients' Instagram) list their sets. The post gets one platformPosts entry per account.
|
|
64
|
+
# @option body [String] :text Post text. Use `options.<platform>.text` to vary it per platform.
|
|
65
|
+
# @option body [String, nil] :firstComment Comment Ampost posts on each new post right after it publishes (X, Threads and Bluesky: a reply). Every target platform must support it (`firstComment.supported` in GET /api/platforms); use `options.<platform>.firstComment` to set or turn it off (`""`) per platform. A failed comment does not fail the post.
|
|
66
|
+
# @option body [String, nil] :linkUrl Link to attach. Ignored by platforms whose `link.supported` is false.
|
|
67
|
+
# @option body [Array<Hash>] :media Images and videos, in order (at most 35; each platform's `media.maxItems` applies): `{ url, type }` plus optional metadata and `altText`. `url` is a public https URL, such as a completed media upload's `url`. The types and required fields per platform are in GET /api/platforms (`media`).
|
|
68
|
+
# @option body [String] :mediaFit One of: `pad`, `crop`, `none`.
|
|
69
|
+
# @option body [Array<Hash>] :thread Follow-up posts published right after the post, in order, each replying to the one before (X, Bluesky, Threads). Item: `{ text, media: [{ url, type, altText }] }`, checked like a post. Every target platform must take it (`thread` in GET /api/platforms); `options.<platform>.thread` overrides it, `[]` for none. Not with `firstComment` on one platform. A failed item fails the account; posts_retry continues from it.
|
|
70
|
+
# @option body [Hash] :options
|
|
71
|
+
# @option body [String, nil] :scheduledFor Publish time in the future. Null or omitted: the post is a draft (or published now with `publishNow`).
|
|
72
|
+
# @option body [Boolean] :publishNow Publish right after creating. Cannot be combined with `scheduledFor`.
|
|
73
|
+
# @option body [Boolean] :useQueue Schedule the post in the next free slot of its platform set's queue (see queue_get) instead of at `scheduledFor`. Needs exactly one target and a queue with slots. Cannot be combined with `scheduledFor` or `publishNow`.
|
|
74
|
+
# @option body [Hash] :metadata Your own JSON object (max 4096 bytes), such as your ids. Returned on the post and in every webhook post event. Set on create only.
|
|
75
|
+
# @param idempotency_key [String, nil] Sent as `Idempotency-Key`; default: a new UUID.
|
|
76
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
77
|
+
# @return [Hash] The `Post`.
|
|
78
|
+
def create(body, **options)
|
|
79
|
+
@client.request("POST", "/api/posts", body: body, idempotent: true, options: options)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Check a post without creating it
|
|
83
|
+
#
|
|
84
|
+
# Check a posts_create request without creating, counting or publishing anything: same input, same checks and error codes. `valid` is true when posts_create would accept it and, with `publishNow`, every account would publish. `errors` holds the post's own problems (content, schedule, plan features, the 30-day post quota, for publishNow the hourly publish limit); `targets` has one entry per platform of each target with its own `valid`, `errors` (platform set, the platform's rules for text, media, placement and options, a Pinterest `boardId` the account cannot pin to, the account it publishes through, its health, and for publishNow the per-account quota), `warnings` (`ALT_TEXT_NOT_SENT` for alt text the platform leaves out, `BOARD_NOT_CHECKED` when Pinterest did not answer the `options.pinterest.boardId` check, account issues to fix before a scheduled post publishes, a login that expires soon; account health issues carry the `accounts_get` health codes) and `mediaConversion` (what Ampost would convert on that platform, per media item). Each platform reports its first rule error, like posts_create. A request that does not fit the schema answers 400 `VALIDATION_FAILED` like posts_create. Takes no post quota, publish limit or X units.
|
|
85
|
+
#
|
|
86
|
+
# MCP tool: `posts_validate`. Key scope: `posts:read`.
|
|
87
|
+
#
|
|
88
|
+
# `POST /api/posts/validate`
|
|
89
|
+
#
|
|
90
|
+
# @param body [Hash] The request body (`CreatePostRequest`), with the API's field names as keys.
|
|
91
|
+
# @option body [Array<Hash>] :targets Required. Where the post goes: one entry per platform set (max 10). A set holds one account per platform, so to reach several accounts of one platform (two LinkedIn accounts, several clients' Instagram) list their sets. The post gets one platformPosts entry per account.
|
|
92
|
+
# @option body [String] :text Post text. Use `options.<platform>.text` to vary it per platform.
|
|
93
|
+
# @option body [String, nil] :firstComment Comment Ampost posts on each new post right after it publishes (X, Threads and Bluesky: a reply). Every target platform must support it (`firstComment.supported` in GET /api/platforms); use `options.<platform>.firstComment` to set or turn it off (`""`) per platform. A failed comment does not fail the post.
|
|
94
|
+
# @option body [String, nil] :linkUrl Link to attach. Ignored by platforms whose `link.supported` is false.
|
|
95
|
+
# @option body [Array<Hash>] :media Images and videos, in order (at most 35; each platform's `media.maxItems` applies): `{ url, type }` plus optional metadata and `altText`. `url` is a public https URL, such as a completed media upload's `url`. The types and required fields per platform are in GET /api/platforms (`media`).
|
|
96
|
+
# @option body [String] :mediaFit One of: `pad`, `crop`, `none`.
|
|
97
|
+
# @option body [Array<Hash>] :thread Follow-up posts published right after the post, in order, each replying to the one before (X, Bluesky, Threads). Item: `{ text, media: [{ url, type, altText }] }`, checked like a post. Every target platform must take it (`thread` in GET /api/platforms); `options.<platform>.thread` overrides it, `[]` for none. Not with `firstComment` on one platform. A failed item fails the account; posts_retry continues from it.
|
|
98
|
+
# @option body [Hash] :options
|
|
99
|
+
# @option body [String, nil] :scheduledFor Publish time in the future. Null or omitted: the post is a draft (or published now with `publishNow`).
|
|
100
|
+
# @option body [Boolean] :publishNow Publish right after creating. Cannot be combined with `scheduledFor`.
|
|
101
|
+
# @option body [Boolean] :useQueue Schedule the post in the next free slot of its platform set's queue (see queue_get) instead of at `scheduledFor`. Needs exactly one target and a queue with slots. Cannot be combined with `scheduledFor` or `publishNow`.
|
|
102
|
+
# @option body [Hash] :metadata Your own JSON object (max 4096 bytes), such as your ids. Returned on the post and in every webhook post event. Set on create only.
|
|
103
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
104
|
+
# @return [Hash] The `PostValidation`.
|
|
105
|
+
def validate(body, **options)
|
|
106
|
+
@client.request("POST", "/api/posts/validate", body: body, options: options)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Import posts from CSV
|
|
110
|
+
#
|
|
111
|
+
# Create many posts from a CSV file: one post per row, each checked like posts_create. Columns: `text`, `platforms` (space-separated, with an optional `platformSetId`) or `accountIds`, `scheduledFor` or `useQueue` (neither: a draft), `linkUrl`, `media` (space-separated public URLs; `.mp4`, `.m4v`, `.mov` and `.webm` are videos, the rest images) and `text_<platform>` for per-platform text. The dashboard's CSV export has the same columns, so an exported file imports again (its read-only columns are skipped). Send `dryRun: true` first: it checks every row without creating anything. A bad row does not stop the others; `rows[]` gives each row's `status` (`valid`, `created` or `error`) and `errors` with the column. Unknown columns are skipped with a warning. Plans import at most 50 (Free), 1,000 (Pro), 2,500 (Max) or 5,000 (Scale) rows per request. An import and a dry run each take one token per row from the hourly `importPosts` limit (two runs of the plan's largest file an hour, e.g. a dry run and its import); a file with more rows than are left fails with 429 `RATE_LIMITED` and creates nothing. Send an idempotency key with the import: a retry with the same key and file returns the first result and creates nothing new. REST also accepts multipart with the file in a part named `file`.
|
|
112
|
+
#
|
|
113
|
+
# MCP tool: `posts_import_csv`. Key scope: `posts:write`.
|
|
114
|
+
#
|
|
115
|
+
# `POST /api/posts/bulk`
|
|
116
|
+
#
|
|
117
|
+
# Sends an `Idempotency-Key`: yours (`idempotency_key:`), or a generated one kept across retries.
|
|
118
|
+
#
|
|
119
|
+
# @param body [Hash] The request body (`ImportPostsCsvRequest`), with the API's field names as keys.
|
|
120
|
+
# @option body [String] :csv Required. The CSV text: a header row, then one post per row. Columns: `text`, `platforms`, `platformSetId`, `accountIds`, `scheduledFor`, `useQueue`, `linkUrl`, `firstComment`, `media`, `altText` and `text_<platform>` (per-platform text, such as `text_linkedin`) and `tiktok_<option>` (TikTok's `options.tiktok`: `tiktok_privacyLevel`, `tiktok_consent`, `tiktok_disableComment`, `tiktok_disableDuet`, `tiktok_disableStitch`, `tiktok_brandContentToggle`, `tiktok_brandOrganicToggle`, `tiktok_isAigc`, `tiktok_inboxDraft`; a TikTok row needs `tiktok_privacyLevel` and `tiktok_consent` = true unless it is an inbox draft, and its `media` must be files uploaded to Ampost, which Ampost measures; an empty cell leaves the option out, so interactions stay off). Each row needs `platforms` (with an optional `platformSetId`; default: your default set) or `accountIds`. List cells separate items with spaces; `altText` holds one alt text per `media` URL, in order, separated by `|` (leave an item empty for none). Unknown columns are skipped with a warning.
|
|
121
|
+
# @option body [Boolean] :dryRun Check every row like posts_create does without creating anything. `valid` rows would be created.
|
|
122
|
+
# @param idempotency_key [String, nil] Sent as `Idempotency-Key`; default: a new UUID.
|
|
123
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
124
|
+
# @return [Hash] The `ImportPostsCsvResult`.
|
|
125
|
+
def import_csv(body, **options)
|
|
126
|
+
@client.request("POST", "/api/posts/bulk", body: body, idempotent: true, options: options)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Get a post
|
|
130
|
+
#
|
|
131
|
+
# Get one post with its result per account (`platformPosts`).
|
|
132
|
+
#
|
|
133
|
+
# MCP tool: `posts_get`. Key scope: `posts:read`.
|
|
134
|
+
#
|
|
135
|
+
# `GET /api/posts/{postId}`
|
|
136
|
+
#
|
|
137
|
+
# @param post_id [String]
|
|
138
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
139
|
+
# @return [Hash] The `Post`.
|
|
140
|
+
def get(post_id, **options)
|
|
141
|
+
@client.request("GET", "/api/posts/#{path(post_id)}", options: options)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Update a post
|
|
145
|
+
#
|
|
146
|
+
# Change a draft or scheduled post. Send only the fields to change; `media` and `targets` replace the whole list (accounts the post keeps keep their results). `options` is merged per platform: each `options.<platform>` you send replaces that platform's options as a whole, `null` removes them, and other platforms keep theirs. Set `scheduledFor` to null to turn a scheduled post back into a draft. To change the text of a published post, use posts_edit_published.
|
|
147
|
+
#
|
|
148
|
+
# MCP tool: `posts_update`. Key scope: `posts:write`.
|
|
149
|
+
#
|
|
150
|
+
# `PATCH /api/posts/{postId}`
|
|
151
|
+
#
|
|
152
|
+
# @param post_id [String]
|
|
153
|
+
# @param body [Hash, nil] The request body (`UpdatePostRequest`), with the API's field names as keys.
|
|
154
|
+
# @option body [Array<Hash>] :targets Replaces all targets. Accounts the post keeps also keep their results.
|
|
155
|
+
# @option body [String] :text Post text. Use `options.<platform>.text` to vary it per platform.
|
|
156
|
+
# @option body [String, nil] :firstComment New first comment; null removes it
|
|
157
|
+
# @option body [String, nil] :linkUrl Link to attach. Ignored by platforms whose `link.supported` is false.
|
|
158
|
+
# @option body [Array<Hash>] :media Replaces all media
|
|
159
|
+
# @option body [String] :mediaFit One of: `pad`, `crop`, `none`.
|
|
160
|
+
# @option body [Array<Hash>] :thread Replaces the thread; `[]` removes it
|
|
161
|
+
# @option body [Hash] :options
|
|
162
|
+
# @option body [String, nil] :scheduledFor New publish time; null turns the post back into a draft
|
|
163
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
164
|
+
# @return [Hash] The `Post`.
|
|
165
|
+
def update(post_id, body = nil, **options)
|
|
166
|
+
@client.request("PATCH", "/api/posts/#{path(post_id)}", body: body, options: options)
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# Delete a post
|
|
170
|
+
#
|
|
171
|
+
# Discard a post that has not been published, including a scheduled one. The post stays readable with status `discarded`, and its media in Ampost storage is deleted. To take a published post down from the platforms, use posts_unpublish.
|
|
172
|
+
#
|
|
173
|
+
# MCP tool: `posts_delete`. Key scope: `posts:write`.
|
|
174
|
+
#
|
|
175
|
+
# `DELETE /api/posts/{postId}`
|
|
176
|
+
#
|
|
177
|
+
# @param post_id [String]
|
|
178
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
179
|
+
# @return [Hash] The `Post`.
|
|
180
|
+
def delete(post_id, **options)
|
|
181
|
+
@client.request("DELETE", "/api/posts/#{path(post_id)}", options: options)
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# Publish a post now
|
|
185
|
+
#
|
|
186
|
+
# Publish a draft or scheduled post to all its accounts now. Check `platformPosts` for each account's result; an account with a video may stay `processing` (the platform is still processing it) for a few minutes before it is `published`.
|
|
187
|
+
#
|
|
188
|
+
# MCP tool: `posts_publish`. Key scope: `posts:write`.
|
|
189
|
+
#
|
|
190
|
+
# `POST /api/posts/{postId}/publish`
|
|
191
|
+
#
|
|
192
|
+
# Sends an `Idempotency-Key`: yours (`idempotency_key:`), or a generated one kept across retries.
|
|
193
|
+
#
|
|
194
|
+
# @param post_id [String]
|
|
195
|
+
# @param idempotency_key [String, nil] Sent as `Idempotency-Key`; default: a new UUID.
|
|
196
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
197
|
+
# @return [Hash] The `Post`.
|
|
198
|
+
def publish(post_id, **options)
|
|
199
|
+
@client.request("POST", "/api/posts/#{path(post_id)}/publish", idempotent: true, options: options)
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# Unpublish a post
|
|
203
|
+
#
|
|
204
|
+
# Take a published post down from the platforms: every account where it is published, or only the given `accountIds` (from `platformPosts[].accountId`). Each account's result is in `platformPosts`: `deleted`, or still `published` with `notice` saying why (`UNPUBLISH_NOT_SUPPORTED` on Instagram and TikTok, which have no delete API; the platform's own refusal otherwise, such as Telegram's 48-hour limit for bots). The post becomes `deleted` once no account has it; it stays readable in Ampost. YouTube deletes count in the channel's daily budget of edits and deletes (10, 3 on Free; `notice` `RATE_LIMITED` past it). Call platforms_list for `unpublish.supported` per platform. Deleting from X costs X units like a post.
|
|
205
|
+
#
|
|
206
|
+
# MCP tool: `posts_unpublish`. Key scope: `posts:write`.
|
|
207
|
+
#
|
|
208
|
+
# `POST /api/posts/{postId}/unpublish`
|
|
209
|
+
#
|
|
210
|
+
# @param post_id [String]
|
|
211
|
+
# @param body [Hash, nil] The request body (`UnpublishPostRequest`), with the API's field names as keys.
|
|
212
|
+
# @option body [Array<String>] :accountIds Accounts to delete the post from (`platformPosts[].accountId`). Default: every account where it is published.
|
|
213
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
214
|
+
# @return [Hash] The `Post`.
|
|
215
|
+
def unpublish(post_id, body = nil, **options)
|
|
216
|
+
@client.request("POST", "/api/posts/#{path(post_id)}/unpublish", body: body, options: options)
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# Edit a published post's text
|
|
220
|
+
#
|
|
221
|
+
# Replace the text of a published post on the platforms: every account where it is published, or only the given `accountIds` (from `platformPosts[].accountId`). Text only; media and links stay. Each account's result is in `platformPosts`: an edited account's `text` holds the new text, and an account the platform refused keeps its text with `notice` (`EDIT_NOT_SUPPORTED` on Instagram, Threads, TikTok, Bluesky and X, and on Facebook stories; the platform's own refusal otherwise). Facebook edits only posts Ampost published; a Telegram caption under media stays limited to 1024 characters. YouTube and Pinterest replace the video or Pin description. YouTube edits and deletes share a budget of 10 a day per channel (3 on Free); past it the account gets `notice` `RATE_LIMITED`. Call platforms_list for `editPublished.supported` per platform. To change a draft or scheduled post, use posts_update.
|
|
222
|
+
#
|
|
223
|
+
# MCP tool: `posts_edit_published`. Key scope: `posts:write`.
|
|
224
|
+
#
|
|
225
|
+
# `POST /api/posts/{postId}/edit-published`
|
|
226
|
+
#
|
|
227
|
+
# @param post_id [String]
|
|
228
|
+
# @param body [Hash] The request body (`EditPublishedPostRequest`), with the API's field names as keys.
|
|
229
|
+
# @option body [String] :text Required. The new text. It replaces the text only; media and links stay. Each platform's `text.maxLength` applies.
|
|
230
|
+
# @option body [Array<String>] :accountIds Accounts to edit the post on (`platformPosts[].accountId`). Default: every account where it is published.
|
|
231
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
232
|
+
# @return [Hash] The `Post`.
|
|
233
|
+
def edit_published(post_id, body, **options)
|
|
234
|
+
@client.request("POST", "/api/posts/#{path(post_id)}/edit-published", body: body, options: options)
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Retry failed accounts
|
|
238
|
+
#
|
|
239
|
+
# Publish again to the accounts that failed, or only to the given `accountIds` (from `platformPosts[].accountId`). Ampost already retries retryable failures (rate limits, timeouts, platform errors) by itself, up to 5 attempts with backoff; an account waiting for that shows `pending` with `nextAttemptAt`. Call this for an account that is `failed`, after fixing the cause. It starts `attempts` again from 0. A published account whose first comment failed (`platformPosts[].firstComment.status` failed) posts only the comment again, without publishing the post twice or counting it again. An account whose thread stopped at a failed item continues the thread from that item, without publishing the post or the earlier items again.
|
|
240
|
+
#
|
|
241
|
+
# MCP tool: `posts_retry`. Key scope: `posts:write`.
|
|
242
|
+
#
|
|
243
|
+
# `POST /api/posts/{postId}/retry`
|
|
244
|
+
#
|
|
245
|
+
# Sends an `Idempotency-Key`: yours (`idempotency_key:`), or a generated one kept across retries.
|
|
246
|
+
#
|
|
247
|
+
# @param post_id [String]
|
|
248
|
+
# @param body [Hash, nil] The request body (`RetryPostRequest`), with the API's field names as keys.
|
|
249
|
+
# @option body [Array<String>] :accountIds Accounts to retry (`platformPosts[].accountId`). A published account whose `firstComment.status` is failed retries only the comment; an account whose thread stopped at a failed item continues the thread from that item (the post and earlier items are not published again); other accounts publish again. Default: every failed account and every failed first comment.
|
|
250
|
+
# @param idempotency_key [String, nil] Sent as `Idempotency-Key`; default: a new UUID.
|
|
251
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
252
|
+
# @return [Hash] The `Post`.
|
|
253
|
+
def retry(post_id, body = nil, **options)
|
|
254
|
+
@client.request("POST", "/api/posts/#{path(post_id)}/retry", body: body, idempotent: true, options: options)
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
# `media` operations: `client.media`.
|
|
259
|
+
class Media < Resource
|
|
260
|
+
# Start a media upload
|
|
261
|
+
#
|
|
262
|
+
# Get a way to upload a local file for a post. Media in posts_create must be a public URL; use this when the user has the file on their device or you have the file itself. Returns `uploadPageUrl`, an Ampost page where the user uploads files in a browser (in MCP, a client that supports URL elicitation asks the user to open it itself and leaves `uploadPageUrl` out), and `uploadUrl` + `method` + `headers` to PUT one file directly. Both stop accepting files after 60 minutes. Then poll media_upload_status; when it is completed, its `files` are `media[]` items for posts_create. Files that no post uses are deleted 24 hours after the upload was created (by the daily cleanup).
|
|
263
|
+
#
|
|
264
|
+
# MCP tool: `media_upload_create`. Key scope: `media:write`.
|
|
265
|
+
#
|
|
266
|
+
# `POST /api/media/uploads`
|
|
267
|
+
#
|
|
268
|
+
# @param body [Hash, nil] The request body (`CreateMediaUploadRequest`), with the API's field names as keys.
|
|
269
|
+
# @option body [String] :fileName File name for the direct upload, e.g. `launch.mp4`; it becomes the end of the file URL. Default `file`. Files uploaded on the page keep their own names.
|
|
270
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
271
|
+
# @return [Hash] The `MediaUploadCreated`.
|
|
272
|
+
def create_upload(body = nil, **options)
|
|
273
|
+
@client.request("POST", "/api/media/uploads", body: body, options: options)
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
# Get a media upload
|
|
277
|
+
#
|
|
278
|
+
# Read a media upload: `pending` until files arrive, `completed` with `files`, `failed` with `error` (the direct upload's content was not the type it was sent as), or `expired`. Poll every 3-5 seconds after media_upload_create. Each item in `files` is a `media[]` item (`url`, `type`, `mimeType`, `sizeBytes`, `width`, `height`, `durationSeconds`): pass them to posts_create unchanged.
|
|
279
|
+
#
|
|
280
|
+
# MCP tool: `media_upload_status`. Key scope: `media:write`.
|
|
281
|
+
#
|
|
282
|
+
# `GET /api/media/uploads/{uploadId}`
|
|
283
|
+
#
|
|
284
|
+
# @param upload_id [String]
|
|
285
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
286
|
+
# @return [Hash] The `MediaUpload`.
|
|
287
|
+
def get_upload(upload_id, **options)
|
|
288
|
+
@client.request("GET", "/api/media/uploads/#{path(upload_id)}", options: options)
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
# `accounts` operations: `client.accounts`.
|
|
293
|
+
class Accounts < Resource
|
|
294
|
+
# List social accounts
|
|
295
|
+
#
|
|
296
|
+
# List your social accounts, optionally only one platform or one platform set. `status` defaults to `active`, the accounts that can publish; pass `revoked` for disconnected accounts or `all` for both. The `active` total for a set equals that set's `accountCount` in platform_sets_list. `health` says whether each account can publish (`canPost`), whether only a reconnect helps (`needsReconnect`), and why (`issues[]` with codes such as `TOKEN_EXPIRED` or `MISSING_SCOPE:w_member_social`). Fix with accounts_connect and the account's id as `accountId`. `platformMetadata` has public per-platform details, such as the TikTok creator's allowed privacy levels.
|
|
297
|
+
#
|
|
298
|
+
# MCP tool: `accounts_list`. Key scope: `accounts:read`.
|
|
299
|
+
#
|
|
300
|
+
# `GET /api/accounts`
|
|
301
|
+
#
|
|
302
|
+
# Returns one page; `each` walks every item across pages.
|
|
303
|
+
#
|
|
304
|
+
# @param platform [String, nil] Only accounts on this platform. One of: `instagram`, `facebook`, `linkedin`, `tiktok`, `threads`, `twitter`, `discord`, `telegram`, `bluesky`, `youtube`, `pinterest`.
|
|
305
|
+
# @param platform_set_id [String, nil] Only accounts in this platform set
|
|
306
|
+
# @param status [String, nil] `active` (default): accounts that can publish. `revoked`: disconnected accounts. `all`: both.
|
|
307
|
+
# @param limit [Integer, nil] Page size, 1-100. Default 20.
|
|
308
|
+
# @param offset [Integer, nil] Number of items to skip. Default 0.
|
|
309
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
310
|
+
# @return [Ampost::Page] Items: `Account` hashes.
|
|
311
|
+
def list(platform: nil, platform_set_id: nil, status: nil, limit: nil, offset: nil, **options)
|
|
312
|
+
@client.paginate("GET", "/api/accounts", query: { "platform" => platform, "platformSetId" => platform_set_id, "status" => status, "limit" => limit, "offset" => offset }, options: options)
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
# Get a connected account
|
|
316
|
+
#
|
|
317
|
+
# Get one social account by id, including revoked ones (`status: revoked`). `health`: `canPost`, `needsReconnect` and `issues[]` (codes such as `ACCOUNT_REVOKED`, `TOKEN_EXPIRED`, `MISSING_SCOPE:<scope>`, each with a message to relay). When `needsReconnect` is true, call accounts_connect with `accountId` set to this id; the account keeps its id. `platformMetadata` has public per-platform details.
|
|
318
|
+
#
|
|
319
|
+
# MCP tool: `accounts_get`. Key scope: `accounts:read`.
|
|
320
|
+
#
|
|
321
|
+
# `GET /api/accounts/{accountId}`
|
|
322
|
+
#
|
|
323
|
+
# @param account_id [String]
|
|
324
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
325
|
+
# @return [Hash] The `Account`.
|
|
326
|
+
def get(account_id, **options)
|
|
327
|
+
@client.request("GET", "/api/accounts/#{path(account_id)}", options: options)
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
# Disconnect an account
|
|
331
|
+
#
|
|
332
|
+
# Disconnect a social account: Ampost revokes its access at the platform where the platform allows it, deletes the stored tokens and sets `status: revoked`. Scheduled posts for the account will fail. The account keeps its id and can be reconnected later with accounts_connect and `accountId`. `providerRevoked` says whether the platform confirmed the revoke; when false, `providerAccessSettings` says where the user removes Ampost in the platform's settings. Instagram and Threads have no revoke endpoint, so they always return `providerRevoked: false`. Calling it again on a disconnected account returns the account unchanged with `providerRevoked: false`.
|
|
333
|
+
#
|
|
334
|
+
# MCP tool: `accounts_disconnect`. Key scope: `accounts:write`.
|
|
335
|
+
#
|
|
336
|
+
# `DELETE /api/accounts/{accountId}`
|
|
337
|
+
#
|
|
338
|
+
# @param account_id [String]
|
|
339
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
340
|
+
# @return [Hash] The `DisconnectedAccount`.
|
|
341
|
+
def disconnect(account_id, **options)
|
|
342
|
+
@client.request("DELETE", "/api/accounts/#{path(account_id)}", options: options)
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
# Turn X analytics on or off
|
|
346
|
+
#
|
|
347
|
+
# Opt an X account in to analytics, or out again. Every X read is billed, so X analytics are off until the account opts in, and the reads count against the plan's 30-day X units like publishing (Max and Scale). When on, Ampost reads the metrics of the posts it published to the account during their first 29 days (daily for 3 days, then weekly) and the follower count once a day; three post reads or one follower read cost one X unit. The sync pauses when the units run out and resumes when they reset. Other platforms need no opt-in (`analytics.optInRequired` is false) and return 400. A plan without X returns 403 UPGRADE_REQUIRED. Returns the account with its `analytics` state.
|
|
348
|
+
#
|
|
349
|
+
# MCP tool: `accounts_set_analytics`. Key scope: `accounts:write`.
|
|
350
|
+
#
|
|
351
|
+
# `PATCH /api/accounts/{accountId}/analytics`
|
|
352
|
+
#
|
|
353
|
+
# @param account_id [String]
|
|
354
|
+
# @param body [Hash] The request body (`SetAccountAnalyticsRequest`), with the API's field names as keys.
|
|
355
|
+
# @option body [Boolean] :enabled Required. `true` starts the metered X analytics sync for the account; `false` stops it
|
|
356
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
357
|
+
# @return [Hash] The `Account`.
|
|
358
|
+
def set_analytics(account_id, body, **options)
|
|
359
|
+
@client.request("PATCH", "/api/accounts/#{path(account_id)}/analytics", body: body, options: options)
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
# List a Pinterest account's boards
|
|
363
|
+
#
|
|
364
|
+
# List the boards of an active Pinterest account (up to 250), read from Pinterest (the same list is reused for up to a minute; a board made with accounts_set_board shows at once). `defaultBoardId` is the board Pins go to when a post sets no `options.pinterest.boardId`; it is `null` until one is picked, and the account then has the `BOARD_NOT_SELECTED` health warning. Ask the user which board to use and call accounts_set_board. An account with a single board gets it as the default at connect. Other platforms return 400.
|
|
365
|
+
#
|
|
366
|
+
# MCP tool: `accounts_list_boards`. Key scope: `accounts:read`.
|
|
367
|
+
#
|
|
368
|
+
# `GET /api/accounts/{accountId}/boards`
|
|
369
|
+
#
|
|
370
|
+
# @param account_id [String]
|
|
371
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
372
|
+
# @return [Hash] The `PinterestBoardList`.
|
|
373
|
+
def list_boards(account_id, **options)
|
|
374
|
+
@client.request("GET", "/api/accounts/#{path(account_id)}/boards", options: options)
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
# Pick a Pinterest account's default board
|
|
378
|
+
#
|
|
379
|
+
# Set the board Pins go to when a post sets no `options.pinterest.boardId`: pass `boardId` (from accounts_list_boards), or `newBoardName` to create a public board and use it. Ampost checks the board with Pinterest first. The choice survives a reconnect. Returns the account; `platformMetadata.boardId` and `boardName` show the default. Other platforms return 400.
|
|
380
|
+
#
|
|
381
|
+
# MCP tool: `accounts_set_board`. Key scope: `accounts:write`.
|
|
382
|
+
#
|
|
383
|
+
# `PATCH /api/accounts/{accountId}/board`
|
|
384
|
+
#
|
|
385
|
+
# @param account_id [String]
|
|
386
|
+
# @param body [Hash, nil] The request body (`SetPinterestBoardRequest`), with the API's field names as keys.
|
|
387
|
+
# @option body [String] :boardId An existing board of the account, from accounts_list_boards. Pass this or `newBoardName`
|
|
388
|
+
# @option body [String] :newBoardName Creates a public board with this name and makes it the default. Pass this or `boardId`
|
|
389
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
390
|
+
# @return [Hash] The `Account`.
|
|
391
|
+
def set_board(account_id, body = nil, **options)
|
|
392
|
+
@client.request("PATCH", "/api/accounts/#{path(account_id)}/board", body: body, options: options)
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
# Connect a social account
|
|
396
|
+
#
|
|
397
|
+
# Create a short-lived Ampost-hosted link that connects one social account to a platform set. The user opens `connectUrl` in a browser and authorizes there; consent cannot happen in chat. In MCP, a client that supports URL elicitation asks the user to open the page itself, and the result then has no `connectUrl`. Then poll the connection request until it is connected, failed or expired. To reconnect an existing account (a revoked one, or an active one whose `health.needsReconnect` is true), pass its id as `accountId`; `platform` may then be omitted. For a new connection, `expectedUsername` or `expectedPlatformAccountId` makes sure the user signs in to the right account. If the user signs in to another account, the request fails with ACCOUNT_MISMATCH and nothing changes. A new request replaces the pending one for the same platform and set, also one the user opened but did not finish (it fails with SUPERSEDED), so call this again when the user lost or closed the page. A coming-soon platform (`availability: coming_soon` in platforms_list) returns 403 PLATFORM_COMING_SOON for accounts it is not open to yet, reconnects included.
|
|
398
|
+
#
|
|
399
|
+
# MCP tool: `accounts_connect`. Key scope: `accounts:write`.
|
|
400
|
+
#
|
|
401
|
+
# `POST /api/accounts/connect`
|
|
402
|
+
#
|
|
403
|
+
# Sends an `Idempotency-Key`: yours (`idempotency_key:`), or a generated one kept across retries.
|
|
404
|
+
#
|
|
405
|
+
# @param body [Hash] The request body (`ConnectAccountRequest`), with the API's field names as keys.
|
|
406
|
+
# @option body [String] :platform The platform to connect. Required unless `accountId` is given.
|
|
407
|
+
# @option body [String] :platformSetId Target platform set. Default: your default set, or for a reconnect the account's own set. An active account cannot change sets.
|
|
408
|
+
# @option body [String] :accountId Reconnect this existing account (active: refreshes its token and permissions; revoked: reactivates it). The user must sign in to the same platform account, otherwise the request fails with ACCOUNT_MISMATCH and nothing changes.
|
|
409
|
+
# @option body [String] :expectedUsername New connections: the username the user must sign in to, as `username` in accounts_get (Facebook: the Page name). Case and a leading @ are ignored. Otherwise the request fails with ACCOUNT_MISMATCH.
|
|
410
|
+
# @option body [String] :expectedPlatformAccountId New connections: the platform's id of the account the user must sign in to, as `platformAccountId` in accounts_get. Otherwise the request fails with ACCOUNT_MISMATCH.
|
|
411
|
+
# @option body [String] :redirectUrl When done, the result page links the browser here (the user clicks to leave Ampost), with the outcome in the query (https; http only for localhost).
|
|
412
|
+
# @option body [String] :state Returned unchanged as `state` on `redirectUrl`.
|
|
413
|
+
# @param idempotency_key [String, nil] Sent as `Idempotency-Key`; default: a new UUID.
|
|
414
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
415
|
+
# @return [Hash] The `ConnectRequestCreated`.
|
|
416
|
+
def connect(body, **options)
|
|
417
|
+
@client.request("POST", "/api/accounts/connect", body: body, idempotent: true, options: options)
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
# Get a connection request
|
|
421
|
+
#
|
|
422
|
+
# Read the status of an account connection request: pending, awaiting_selection, connected, failed or expired. Poll every 2-5 seconds. When connected, `accountId` is the account's id (a reconnected account keeps its id). When failed or expired, `error.message` says why and what the user should do next; relay it as is. `ACCOUNT_MISMATCH` means the user signed in to another account than `accountId` or the expected one; nothing was changed. `SOCIAL_ACCOUNT_IN_USE` means a Free workspace tried to connect a social account another Ampost workspace has (or had in the last 30 days); a paid plan can connect it. `SUPERSEDED` means a newer request for this platform replaced this one: poll the newer request instead. `USER_CANCELLED` means the user cancelled or declined consent.
|
|
423
|
+
#
|
|
424
|
+
# MCP tool: `accounts_connect_status`. Key scope: `accounts:read`.
|
|
425
|
+
#
|
|
426
|
+
# `GET /api/accounts/connect/{connectRequestId}`
|
|
427
|
+
#
|
|
428
|
+
# @param connect_request_id [String]
|
|
429
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
430
|
+
# @return [Hash] The `ConnectRequest`.
|
|
431
|
+
def get_connect_request(connect_request_id, **options)
|
|
432
|
+
@client.request("GET", "/api/accounts/connect/#{path(connect_request_id)}", options: options)
|
|
433
|
+
end
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
# `platform-sets` operations: `client.platform_sets`.
|
|
437
|
+
class PlatformSets < Resource
|
|
438
|
+
# List platform sets
|
|
439
|
+
#
|
|
440
|
+
# List your platform sets with their active account counts, default set first. `accountCount` counts only active accounts, the same ones accounts_list returns by default; revoked accounts are not counted. A platform set groups at most one account per platform; every post targets one set.
|
|
441
|
+
#
|
|
442
|
+
# MCP tool: `platform_sets_list`. Key scope: `accounts:read`.
|
|
443
|
+
#
|
|
444
|
+
# `GET /api/platform-sets`
|
|
445
|
+
#
|
|
446
|
+
# Returns one page; `each` walks every item across pages.
|
|
447
|
+
#
|
|
448
|
+
# @param limit [Integer, nil] Page size, 1-100. Default 20.
|
|
449
|
+
# @param offset [Integer, nil] Number of items to skip. Default 0.
|
|
450
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
451
|
+
# @return [Ampost::Page] Items: `PlatformSet` hashes.
|
|
452
|
+
def list(limit: nil, offset: nil, **options)
|
|
453
|
+
@client.paginate("GET", "/api/platform-sets", query: { "limit" => limit, "offset" => offset }, options: options)
|
|
454
|
+
end
|
|
455
|
+
|
|
456
|
+
# Create a platform set
|
|
457
|
+
#
|
|
458
|
+
# Create an empty platform set. You can have at most 20 sets.
|
|
459
|
+
#
|
|
460
|
+
# MCP tool: `platform_sets_create`. Key scope: `accounts:write`.
|
|
461
|
+
#
|
|
462
|
+
# `POST /api/platform-sets`
|
|
463
|
+
#
|
|
464
|
+
# Sends an `Idempotency-Key`: yours (`idempotency_key:`), or a generated one kept across retries.
|
|
465
|
+
#
|
|
466
|
+
# @param body [Hash] The request body (`PlatformSetRequest`), with the API's field names as keys.
|
|
467
|
+
# @option body [String] :name Required. Set name, 1-50 characters
|
|
468
|
+
# @param idempotency_key [String, nil] Sent as `Idempotency-Key`; default: a new UUID.
|
|
469
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
470
|
+
# @return [Hash] The `PlatformSet`.
|
|
471
|
+
def create(body, **options)
|
|
472
|
+
@client.request("POST", "/api/platform-sets", body: body, idempotent: true, options: options)
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
# Get a platform set
|
|
476
|
+
#
|
|
477
|
+
# Get one platform set with its active account count (revoked accounts are not counted).
|
|
478
|
+
#
|
|
479
|
+
# MCP tool: `platform_sets_get`. Key scope: `accounts:read`.
|
|
480
|
+
#
|
|
481
|
+
# `GET /api/platform-sets/{platformSetId}`
|
|
482
|
+
#
|
|
483
|
+
# @param platform_set_id [String]
|
|
484
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
485
|
+
# @return [Hash] The `PlatformSet`.
|
|
486
|
+
def get(platform_set_id, **options)
|
|
487
|
+
@client.request("GET", "/api/platform-sets/#{path(platform_set_id)}", options: options)
|
|
488
|
+
end
|
|
489
|
+
|
|
490
|
+
# Rename a platform set
|
|
491
|
+
#
|
|
492
|
+
# Rename a platform set, including the default set.
|
|
493
|
+
#
|
|
494
|
+
# MCP tool: `platform_sets_update`. Key scope: `accounts:write`.
|
|
495
|
+
#
|
|
496
|
+
# `PATCH /api/platform-sets/{platformSetId}`
|
|
497
|
+
#
|
|
498
|
+
# @param platform_set_id [String]
|
|
499
|
+
# @param body [Hash] The request body (`PlatformSetRequest`), with the API's field names as keys.
|
|
500
|
+
# @option body [String] :name Required. Set name, 1-50 characters
|
|
501
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
502
|
+
# @return [Hash] The `PlatformSet`.
|
|
503
|
+
def update(platform_set_id, body, **options)
|
|
504
|
+
@client.request("PATCH", "/api/platform-sets/#{path(platform_set_id)}", body: body, options: options)
|
|
505
|
+
end
|
|
506
|
+
|
|
507
|
+
# Delete a platform set
|
|
508
|
+
#
|
|
509
|
+
# Delete a platform set and revoke its active accounts. Its disconnected accounts and its posts are kept without a set; reconnect an account with accounts_connect and its accountId to put it in another set. Your last remaining set cannot be deleted (409 LAST_PLATFORM_SET). 409 PLATFORM_SET_IN_USE means an account was connected to the set during the delete: retry.
|
|
510
|
+
#
|
|
511
|
+
# MCP tool: `platform_sets_delete`. Key scope: `accounts:write`.
|
|
512
|
+
#
|
|
513
|
+
# `DELETE /api/platform-sets/{platformSetId}`
|
|
514
|
+
#
|
|
515
|
+
# @param platform_set_id [String]
|
|
516
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
517
|
+
# @return [Hash] The `Deleted`.
|
|
518
|
+
def delete(platform_set_id, **options)
|
|
519
|
+
@client.request("DELETE", "/api/platform-sets/#{path(platform_set_id)}", options: options)
|
|
520
|
+
end
|
|
521
|
+
|
|
522
|
+
# Get a posting queue
|
|
523
|
+
#
|
|
524
|
+
# Get the posting queue of a platform set. A set without a saved queue answers with no slots in UTC. Each platform set has one queue: weekly slots (weekday and HH:MM) in an IANA time zone, which follow its daylight saving changes. posts_create with `useQueue: true` schedules the post in the set's next free slot. A slot is taken while a queued post is scheduled at its time; rescheduling, publishing or deleting the post frees it.
|
|
525
|
+
#
|
|
526
|
+
# MCP tool: `queue_get`. Key scope: `posts:read`.
|
|
527
|
+
#
|
|
528
|
+
# `GET /api/platform-sets/{platformSetId}/queue`
|
|
529
|
+
#
|
|
530
|
+
# @param platform_set_id [String]
|
|
531
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
532
|
+
# @return [Hash] The `Queue`.
|
|
533
|
+
def get_queue(platform_set_id, **options)
|
|
534
|
+
@client.request("GET", "/api/platform-sets/#{path(platform_set_id)}/queue", options: options)
|
|
535
|
+
end
|
|
536
|
+
|
|
537
|
+
# Update a posting queue
|
|
538
|
+
#
|
|
539
|
+
# Set the time zone or the weekly slots of a platform set's queue; `slots` replaces the whole list. Queues need the Pro plan or above (403 UPGRADE_REQUIRED). Posts already in the queue keep their time. Each platform set has one queue: weekly slots (weekday and HH:MM) in an IANA time zone, which follow its daylight saving changes. posts_create with `useQueue: true` schedules the post in the set's next free slot. A slot is taken while a queued post is scheduled at its time; rescheduling, publishing or deleting the post frees it.
|
|
540
|
+
#
|
|
541
|
+
# MCP tool: `queue_update`. Key scope: `posts:write`.
|
|
542
|
+
#
|
|
543
|
+
# `PATCH /api/platform-sets/{platformSetId}/queue`
|
|
544
|
+
#
|
|
545
|
+
# @param platform_set_id [String]
|
|
546
|
+
# @param body [Hash, nil] The request body (`UpdateQueueRequest`), with the API's field names as keys.
|
|
547
|
+
# @option body [String] :timezone IANA time zone the slot times are in, for example Europe/Warsaw. Slots follow its daylight saving changes.
|
|
548
|
+
# @option body [Array<Hash>] :slots Replaces every slot (max 100); duplicates are merged. An empty list turns the queue off.
|
|
549
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
550
|
+
# @return [Hash] The `Queue`.
|
|
551
|
+
def update_queue(platform_set_id, body = nil, **options)
|
|
552
|
+
@client.request("PATCH", "/api/platform-sets/#{path(platform_set_id)}/queue", body: body, options: options)
|
|
553
|
+
end
|
|
554
|
+
|
|
555
|
+
# Preview queue slots
|
|
556
|
+
#
|
|
557
|
+
# The queue's next slot times from now on, each with the queued post holding it (`postId`, null when free). With `filter: free` the first slot is where posts_create with `useQueue` puts the next post. Each platform set has one queue: weekly slots (weekday and HH:MM) in an IANA time zone, which follow its daylight saving changes. posts_create with `useQueue: true` schedules the post in the set's next free slot. A slot is taken while a queued post is scheduled at its time; rescheduling, publishing or deleting the post frees it.
|
|
558
|
+
#
|
|
559
|
+
# MCP tool: `queue_slots`. Key scope: `posts:read`.
|
|
560
|
+
#
|
|
561
|
+
# `GET /api/platform-sets/{platformSetId}/queue/slots`
|
|
562
|
+
#
|
|
563
|
+
# @param platform_set_id [String]
|
|
564
|
+
# @param count [Integer, nil] How many slots, 1-50. Default 10.
|
|
565
|
+
# @param filter [String, nil] `free`: only free slots, the ones posts_create with `useQueue` fills next, in order. Default `all`: taken slots too, with their post.
|
|
566
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
567
|
+
# @return [Hash] The `QueuePreview`.
|
|
568
|
+
def get_queue_slots(platform_set_id, count: nil, filter: nil, **options)
|
|
569
|
+
@client.request("GET", "/api/platform-sets/#{path(platform_set_id)}/queue/slots", query: { "count" => count, "filter" => filter }, options: options)
|
|
570
|
+
end
|
|
571
|
+
end
|
|
572
|
+
|
|
573
|
+
# `analytics` operations: `client.analytics`.
|
|
574
|
+
class Analytics < Resource
|
|
575
|
+
# Post analytics
|
|
576
|
+
#
|
|
577
|
+
# Metrics of your published posts, newest first: one `platformPosts` entry per account the post went to, with views, reach, likes, comments, shares and saves (null when the platform does not report one). Pass `postId` for one post. `analyticsStatus` says why an entry has no metrics. Analytics cover Facebook Pages, Instagram, Threads, TikTok, Bluesky, YouTube and Pinterest accounts (on YouTube and Pinterest only posts published through Ampost; LinkedIn once its API access is approved), X accounts that opted in with accounts_set_analytics (Max and Scale; only posts published through Ampost), and Telegram followers (no post metrics). Discord has no analytics: asking for it fails with 422 `ANALYTICS_NOT_AVAILABLE_ON_PLATFORM`. When none of the matching accounts has analytics enabled the call fails with 403 `ANALYTICS_NOT_ENABLED` (its `details.accounts` say why per account). Ampost reads analytics in the background and serves the stored numbers: each account about hourly (daily on the Free plan), a post's metrics hourly in its first 48 hours, every 6 hours up to 14 days and daily up to 90 days. X posts are read daily in their first 3 days and weekly up to 29 days, which costs the plan's X units. Meta itself can lag 24-48 hours. `syncedAt` says when each number was read.
|
|
578
|
+
#
|
|
579
|
+
# MCP tool: `analytics_posts`. Key scope: `analytics:read`.
|
|
580
|
+
#
|
|
581
|
+
# `GET /api/analytics/posts`
|
|
582
|
+
#
|
|
583
|
+
# Returns one page; `each` walks every item across pages.
|
|
584
|
+
#
|
|
585
|
+
# @param post_id [String, nil] Only this post
|
|
586
|
+
# @param platform [String, nil] Only accounts on this platform. One of: `instagram`, `facebook`, `linkedin`, `tiktok`, `threads`, `twitter`, `discord`, `telegram`, `bluesky`, `youtube`, `pinterest`.
|
|
587
|
+
# @param platform_set_id [String, nil] Only accounts in this platform set
|
|
588
|
+
# @param account_id [String, nil] Only this account
|
|
589
|
+
# @param limit [Integer, nil] Page size, 1-100. Default 20.
|
|
590
|
+
# @param offset [Integer, nil] Number of items to skip. Default 0.
|
|
591
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
592
|
+
# @return [Ampost::Page] Items: `AnalyticsPost` hashes.
|
|
593
|
+
def list_posts(post_id: nil, platform: nil, platform_set_id: nil, account_id: nil, limit: nil, offset: nil, **options)
|
|
594
|
+
@client.paginate("GET", "/api/analytics/posts", query: { "postId" => post_id, "platform" => platform, "platformSetId" => platform_set_id, "accountId" => account_id, "limit" => limit, "offset" => offset }, options: options)
|
|
595
|
+
end
|
|
596
|
+
|
|
597
|
+
# Analytics overview
|
|
598
|
+
#
|
|
599
|
+
# Per account and in total, for posts published between `from` and `to` (UTC days, default the last 30): post count, summed views, reach, likes, comments, shares and saves, followers and their change, and sync state. These are the dashboard's numbers. `unavailableAccounts` lists matching accounts without analytics and why. Analytics cover Facebook Pages, Instagram, Threads, TikTok, Bluesky, YouTube and Pinterest accounts (on YouTube and Pinterest only posts published through Ampost; LinkedIn once its API access is approved), X accounts that opted in with accounts_set_analytics (Max and Scale; only posts published through Ampost), and Telegram followers (no post metrics). Discord has no analytics: asking for it fails with 422 `ANALYTICS_NOT_AVAILABLE_ON_PLATFORM`. When none of the matching accounts has analytics enabled the call fails with 403 `ANALYTICS_NOT_ENABLED` (its `details.accounts` say why per account). Ampost reads analytics in the background and serves the stored numbers: each account about hourly (daily on the Free plan), a post's metrics hourly in its first 48 hours, every 6 hours up to 14 days and daily up to 90 days. X posts are read daily in their first 3 days and weekly up to 29 days, which costs the plan's X units. Meta itself can lag 24-48 hours. `syncedAt` says when each number was read.
|
|
600
|
+
#
|
|
601
|
+
# MCP tool: `analytics_overview`. Key scope: `analytics:read`.
|
|
602
|
+
#
|
|
603
|
+
# `GET /api/analytics/overview`
|
|
604
|
+
#
|
|
605
|
+
# @param from [String, nil] First day (UTC), YYYY-MM-DD. Default: 29 days before `to`. At most 90 days with `to`.
|
|
606
|
+
# @param to [String, nil] Last day (UTC), YYYY-MM-DD, included. Default: today.
|
|
607
|
+
# @param platform [String, nil] Only accounts on this platform. One of: `instagram`, `facebook`, `linkedin`, `tiktok`, `threads`, `twitter`, `discord`, `telegram`, `bluesky`, `youtube`, `pinterest`.
|
|
608
|
+
# @param platform_set_id [String, nil] Only accounts in this platform set
|
|
609
|
+
# @param account_id [String, nil] Only this account
|
|
610
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
611
|
+
# @return [Hash] The `AnalyticsOverview`.
|
|
612
|
+
def get_overview(from: nil, to: nil, platform: nil, platform_set_id: nil, account_id: nil, **options)
|
|
613
|
+
@client.request("GET", "/api/analytics/overview", query: { "from" => from, "to" => to, "platform" => platform, "platformSetId" => platform_set_id, "accountId" => account_id }, options: options)
|
|
614
|
+
end
|
|
615
|
+
|
|
616
|
+
# Follower history
|
|
617
|
+
#
|
|
618
|
+
# Follower count per account with one daily snapshot per day between `from` and `to` (UTC days, default the last 30). History starts when Ampost first read the account; a day without a snapshot is missing. Analytics cover Facebook Pages, Instagram, Threads, TikTok, Bluesky, YouTube and Pinterest accounts (on YouTube and Pinterest only posts published through Ampost; LinkedIn once its API access is approved), X accounts that opted in with accounts_set_analytics (Max and Scale; only posts published through Ampost), and Telegram followers (no post metrics). Discord has no analytics: asking for it fails with 422 `ANALYTICS_NOT_AVAILABLE_ON_PLATFORM`. When none of the matching accounts has analytics enabled the call fails with 403 `ANALYTICS_NOT_ENABLED` (its `details.accounts` say why per account). Ampost reads analytics in the background and serves the stored numbers: each account about hourly (daily on the Free plan), a post's metrics hourly in its first 48 hours, every 6 hours up to 14 days and daily up to 90 days. X posts are read daily in their first 3 days and weekly up to 29 days, which costs the plan's X units. Meta itself can lag 24-48 hours. `syncedAt` says when each number was read.
|
|
619
|
+
#
|
|
620
|
+
# MCP tool: `analytics_followers`. Key scope: `analytics:read`.
|
|
621
|
+
#
|
|
622
|
+
# `GET /api/analytics/followers`
|
|
623
|
+
#
|
|
624
|
+
# Returns one page; `each` walks every item across pages.
|
|
625
|
+
#
|
|
626
|
+
# @param from [String, nil] First day (UTC), YYYY-MM-DD. Default: 29 days before `to`. At most 90 days with `to`.
|
|
627
|
+
# @param to [String, nil] Last day (UTC), YYYY-MM-DD, included. Default: today.
|
|
628
|
+
# @param platform [String, nil] Only accounts on this platform. One of: `instagram`, `facebook`, `linkedin`, `tiktok`, `threads`, `twitter`, `discord`, `telegram`, `bluesky`, `youtube`, `pinterest`.
|
|
629
|
+
# @param platform_set_id [String, nil] Only accounts in this platform set
|
|
630
|
+
# @param account_id [String, nil] Only this account
|
|
631
|
+
# @param limit [Integer, nil] Page size, 1-100. Default 20.
|
|
632
|
+
# @param offset [Integer, nil] Number of items to skip. Default 0.
|
|
633
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
634
|
+
# @return [Ampost::Page] Items: `AnalyticsFollowers` hashes.
|
|
635
|
+
def list_followers(from: nil, to: nil, platform: nil, platform_set_id: nil, account_id: nil, limit: nil, offset: nil, **options)
|
|
636
|
+
@client.paginate("GET", "/api/analytics/followers", query: { "from" => from, "to" => to, "platform" => platform, "platformSetId" => platform_set_id, "accountId" => account_id, "limit" => limit, "offset" => offset }, options: options)
|
|
637
|
+
end
|
|
638
|
+
end
|
|
639
|
+
|
|
640
|
+
# `webhooks` operations: `client.webhooks`.
|
|
641
|
+
class Webhooks < Resource
|
|
642
|
+
# List webhooks
|
|
643
|
+
#
|
|
644
|
+
# List your webhooks, oldest first. Secrets show only as `secretPreview`. Webhooks see every platform set, so keys restricted to some sets get 403 PLATFORM_SET_NOT_ALLOWED.
|
|
645
|
+
#
|
|
646
|
+
# MCP tool: `webhooks_list`. Key scope: `webhooks:write`.
|
|
647
|
+
#
|
|
648
|
+
# `GET /api/webhooks/endpoints`
|
|
649
|
+
#
|
|
650
|
+
# Returns one page; `each` walks every item across pages.
|
|
651
|
+
#
|
|
652
|
+
# @param limit [Integer, nil] Page size, 1-100. Default 20.
|
|
653
|
+
# @param offset [Integer, nil] Number of items to skip. Default 0.
|
|
654
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
655
|
+
# @return [Ampost::Page] Items: `Webhook` hashes.
|
|
656
|
+
def list(limit: nil, offset: nil, **options)
|
|
657
|
+
@client.paginate("GET", "/api/webhooks/endpoints", query: { "limit" => limit, "offset" => offset }, options: options)
|
|
658
|
+
end
|
|
659
|
+
|
|
660
|
+
# Create a webhook
|
|
661
|
+
#
|
|
662
|
+
# Send events to an https URL. Ampost POSTs each event as JSON, signed with the webhook's secret (`Ampost-Signature`), and retries a failed delivery 7 times (1 min, 5 min, 30 min, 2 h, 6 h, 12 h and 24 h). After 5 deliveries in a row fail all retries the webhook is turned off. At most 10 webhooks. The response is the only one with the full `secret`: store it now. Revoking the key or app that created the webhook turns it off. Events: post.scheduled, post.unscheduled, post.discarded, post.published, post.partial, post.failed, post.platform.published, post.platform.failed, post.platform.deleted, post.platform.edited, account.connected, account.disconnected, account.needs_reconnect, analytics.synced. Webhooks see every platform set, so keys restricted to some sets get 403 PLATFORM_SET_NOT_ALLOWED.
|
|
663
|
+
#
|
|
664
|
+
# MCP tool: `webhooks_create`. Key scope: `webhooks:write`.
|
|
665
|
+
#
|
|
666
|
+
# `POST /api/webhooks/endpoints`
|
|
667
|
+
#
|
|
668
|
+
# Sends an `Idempotency-Key`: yours (`idempotency_key:`), or a generated one kept across retries.
|
|
669
|
+
#
|
|
670
|
+
# @param body [Hash] The request body (`CreateWebhookRequest`), with the API's field names as keys.
|
|
671
|
+
# @option body [String] :url Required. Public https URL that receives the events. Private, loopback, internal and Ampost's own hosts are rejected.
|
|
672
|
+
# @option body [Array<String>] :events Required. Events to send to this URL
|
|
673
|
+
# @option body [String, nil] :description Your note for this webhook, at most 200 characters
|
|
674
|
+
# @param idempotency_key [String, nil] Sent as `Idempotency-Key`; default: a new UUID.
|
|
675
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
676
|
+
# @return [Hash] The `Webhook`.
|
|
677
|
+
def create(body, **options)
|
|
678
|
+
@client.request("POST", "/api/webhooks/endpoints", body: body, idempotent: true, options: options)
|
|
679
|
+
end
|
|
680
|
+
|
|
681
|
+
# Get a webhook
|
|
682
|
+
#
|
|
683
|
+
# Get one webhook with its status and failure count. The secret shows only as `secretPreview`. Webhooks see every platform set, so keys restricted to some sets get 403 PLATFORM_SET_NOT_ALLOWED.
|
|
684
|
+
#
|
|
685
|
+
# MCP tool: `webhooks_get`. Key scope: `webhooks:write`.
|
|
686
|
+
#
|
|
687
|
+
# `GET /api/webhooks/endpoints/{webhookId}`
|
|
688
|
+
#
|
|
689
|
+
# @param webhook_id [String]
|
|
690
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
691
|
+
# @return [Hash] The `Webhook`.
|
|
692
|
+
def get(webhook_id, **options)
|
|
693
|
+
@client.request("GET", "/api/webhooks/endpoints/#{path(webhook_id)}", options: options)
|
|
694
|
+
end
|
|
695
|
+
|
|
696
|
+
# Update a webhook
|
|
697
|
+
#
|
|
698
|
+
# Change a webhook's URL, events or description, turn it on or off, or rotate its secret (the response then has the new `secret`, the only time it is shown). While a webhook is off no events are queued for it. Turning it back on resets its failure count; events it missed are not sent, so resend the ones you need with webhooks_redeliver. A webhook turned off because its key or app was revoked (`disabledReason: "key_revoked"`) can only be turned on in the dashboard. Changing the URL or rotating the secret ties the webhook to the calling key or app.
|
|
699
|
+
#
|
|
700
|
+
# MCP tool: `webhooks_update`. Key scope: `webhooks:write`.
|
|
701
|
+
#
|
|
702
|
+
# `PATCH /api/webhooks/endpoints/{webhookId}`
|
|
703
|
+
#
|
|
704
|
+
# @param webhook_id [String]
|
|
705
|
+
# @param body [Hash, nil] The request body (`UpdateWebhookRequest`), with the API's field names as keys.
|
|
706
|
+
# @option body [String] :url Public https URL that receives the events. Private, loopback, internal and Ampost's own hosts are rejected.
|
|
707
|
+
# @option body [Array<String>] :events Events to send to this URL
|
|
708
|
+
# @option body [String, nil] :description Your note for this webhook, at most 200 characters
|
|
709
|
+
# @option body [Boolean] :enabled Turn the webhook on or off. Turning it on clears `disabledReason` and the failure count.
|
|
710
|
+
# @option body [Boolean] :rotateSecret True: replace the signing secret. The old one stops working at once.
|
|
711
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
712
|
+
# @return [Hash] The `Webhook`.
|
|
713
|
+
def update(webhook_id, body = nil, **options)
|
|
714
|
+
@client.request("PATCH", "/api/webhooks/endpoints/#{path(webhook_id)}", body: body, options: options)
|
|
715
|
+
end
|
|
716
|
+
|
|
717
|
+
# Delete a webhook
|
|
718
|
+
#
|
|
719
|
+
# Delete a webhook and its delivery log. Pending deliveries are not sent.
|
|
720
|
+
#
|
|
721
|
+
# MCP tool: `webhooks_delete`. Key scope: `webhooks:write`.
|
|
722
|
+
#
|
|
723
|
+
# `DELETE /api/webhooks/endpoints/{webhookId}`
|
|
724
|
+
#
|
|
725
|
+
# @param webhook_id [String]
|
|
726
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
727
|
+
# @return [Hash] The `Deleted`.
|
|
728
|
+
def delete(webhook_id, **options)
|
|
729
|
+
@client.request("DELETE", "/api/webhooks/endpoints/#{path(webhook_id)}", options: options)
|
|
730
|
+
end
|
|
731
|
+
|
|
732
|
+
# Send a test event
|
|
733
|
+
#
|
|
734
|
+
# Send a signed `webhook.test` event to the webhook now, also when it is turned off, and return the delivery with your URL's response. One attempt, no retries.
|
|
735
|
+
#
|
|
736
|
+
# MCP tool: `webhooks_test`. Key scope: `webhooks:write`.
|
|
737
|
+
#
|
|
738
|
+
# `POST /api/webhooks/endpoints/{webhookId}/test`
|
|
739
|
+
#
|
|
740
|
+
# @param webhook_id [String]
|
|
741
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
742
|
+
# @return [Hash] The `WebhookDelivery`.
|
|
743
|
+
def test(webhook_id, **options)
|
|
744
|
+
@client.request("POST", "/api/webhooks/endpoints/#{path(webhook_id)}/test", options: options)
|
|
745
|
+
end
|
|
746
|
+
|
|
747
|
+
# List webhook deliveries
|
|
748
|
+
#
|
|
749
|
+
# The webhook's delivery log, newest first: each event sent, its status, attempts, and the last response code and body. Kept for 30 days.
|
|
750
|
+
#
|
|
751
|
+
# MCP tool: `webhooks_deliveries_list`. Key scope: `webhooks:write`.
|
|
752
|
+
#
|
|
753
|
+
# `GET /api/webhooks/endpoints/{webhookId}/deliveries`
|
|
754
|
+
#
|
|
755
|
+
# Returns one page; `each` walks every item across pages.
|
|
756
|
+
#
|
|
757
|
+
# @param webhook_id [String]
|
|
758
|
+
# @param limit [Integer, nil] Page size, 1-100. Default 20.
|
|
759
|
+
# @param offset [Integer, nil] Number of items to skip. Default 0.
|
|
760
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
761
|
+
# @return [Ampost::Page] Items: `WebhookDelivery` hashes.
|
|
762
|
+
def list_deliveries(webhook_id, limit: nil, offset: nil, **options)
|
|
763
|
+
@client.paginate("GET", "/api/webhooks/endpoints/#{path(webhook_id)}/deliveries", query: { "limit" => limit, "offset" => offset }, options: options)
|
|
764
|
+
end
|
|
765
|
+
|
|
766
|
+
# Redeliver an event
|
|
767
|
+
#
|
|
768
|
+
# Send a past delivery's event again now, with the same event id and body, as a new delivery (one attempt, also when the webhook is turned off). Returns the new delivery with your URL's response.
|
|
769
|
+
#
|
|
770
|
+
# MCP tool: `webhooks_redeliver`. Key scope: `webhooks:write`.
|
|
771
|
+
#
|
|
772
|
+
# `POST /api/webhooks/endpoints/{webhookId}/deliveries/{deliveryId}/redeliver`
|
|
773
|
+
#
|
|
774
|
+
# @param webhook_id [String]
|
|
775
|
+
# @param delivery_id [String]
|
|
776
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
777
|
+
# @return [Hash] The `WebhookDelivery`.
|
|
778
|
+
def redeliver(webhook_id, delivery_id, **options)
|
|
779
|
+
@client.request("POST", "/api/webhooks/endpoints/#{path(webhook_id)}/deliveries/#{path(delivery_id)}/redeliver", options: options)
|
|
780
|
+
end
|
|
781
|
+
end
|
|
782
|
+
|
|
783
|
+
# `docs` operations: `client.docs`.
|
|
784
|
+
class Docs < Resource
|
|
785
|
+
# Search the docs
|
|
786
|
+
#
|
|
787
|
+
# Search the Ampost docs (`/docs`, `/docs/mcp` and `/llms-full.txt`) for a question such as "schedule a post to instagram". Returns the best matching sections, each with its title, a short excerpt and its URL. Any valid key may call it, and it is not counted toward the plan's 30-day API requests.
|
|
788
|
+
#
|
|
789
|
+
# MCP tool: `docs_search`. Key scope: none (any key).
|
|
790
|
+
#
|
|
791
|
+
# `GET /api/docs/search`
|
|
792
|
+
#
|
|
793
|
+
# @param query [String] What you want to know, in plain words, e.g. "schedule a post to instagram".
|
|
794
|
+
# @param limit [Integer, nil] Number of sections, 1-20. Default 5.
|
|
795
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
796
|
+
# @return [Hash] The `DocsSearchResults`.
|
|
797
|
+
def search(query:, limit: nil, **options)
|
|
798
|
+
@client.request("GET", "/api/docs/search", query: { "query" => query, "limit" => limit }, options: options)
|
|
799
|
+
end
|
|
800
|
+
end
|
|
801
|
+
|
|
802
|
+
# `feedback` operations: `client.feedback`.
|
|
803
|
+
class Feedback < Resource
|
|
804
|
+
# Report a bug or suggest a change
|
|
805
|
+
#
|
|
806
|
+
# Send the Ampost team a bug report or a suggestion. When an Ampost call fails in a way you can't explain or fix, report it with the `request` you sent (method, path or tool, body) and the `error` you got (status, code, message, `X-Request-Id`). Ampost adds the user's plan and connected accounts with their health. Fields named like secrets and Ampost keys in strings are removed; don't send credentials. Any valid key may call it, at most 10 reports an hour and 20 a day (5 a day with a screenshot); it is not counted toward the plan's 30-day API requests.
|
|
807
|
+
#
|
|
808
|
+
# MCP tool: `feedback_submit`. Key scope: none (any key).
|
|
809
|
+
#
|
|
810
|
+
# `POST /api/feedback`
|
|
811
|
+
#
|
|
812
|
+
# Sends an `Idempotency-Key`: yours (`idempotency_key:`), or a generated one kept across retries.
|
|
813
|
+
#
|
|
814
|
+
# @param body [Hash] The request body, with the API's field names as keys.
|
|
815
|
+
# @option body [String] :kind Required. `bug` for something that went wrong, `suggestion` for a change you want
|
|
816
|
+
# @option body [String] :message Required. What happened and what you expected, or what you want changed. At most 5000 characters.
|
|
817
|
+
# @option body [String] :route The dashboard page, or the API path or MCP tool the report is about
|
|
818
|
+
# @option body [Hash] :request The request that failed, as you sent it
|
|
819
|
+
# @option body [Hash] :error The error Ampost answered
|
|
820
|
+
# @option body [Array<Hash>] :recentRequests The dashboard's last API calls; the dashboard fills it in
|
|
821
|
+
# @option body [String] :browser The browser's user agent; the dashboard fills it in
|
|
822
|
+
# @option body [String] :screenshot Optional PNG or JPEG, base64 (a `data:` URL is fine). Ampost re-encodes it as JPEG within 1920 px; one still over 1 MB is refused. At most 5 a day.
|
|
823
|
+
# @param idempotency_key [String, nil] Sent as `Idempotency-Key`; default: a new UUID.
|
|
824
|
+
# @param options [Hash] `timeout:`, `max_retries:` and `extra_headers:` for this call.
|
|
825
|
+
# @return [Hash] The `FeedbackReceipt`.
|
|
826
|
+
def submit(body, **options)
|
|
827
|
+
@client.request("POST", "/api/feedback", body: body, idempotent: true, options: options)
|
|
828
|
+
end
|
|
829
|
+
end
|
|
830
|
+
|
|
831
|
+
# Every resource of the API, one reader per tag. Ampost::Client includes it.
|
|
832
|
+
module Readers
|
|
833
|
+
# @return [Ampost::Resources::Platforms]
|
|
834
|
+
attr_reader :platforms
|
|
835
|
+
|
|
836
|
+
# @return [Ampost::Resources::Posts]
|
|
837
|
+
attr_reader :posts
|
|
838
|
+
|
|
839
|
+
# @return [Ampost::Resources::Media, Ampost::MediaResource]
|
|
840
|
+
attr_reader :media
|
|
841
|
+
|
|
842
|
+
# @return [Ampost::Resources::Accounts]
|
|
843
|
+
attr_reader :accounts
|
|
844
|
+
|
|
845
|
+
# @return [Ampost::Resources::PlatformSets]
|
|
846
|
+
attr_reader :platform_sets
|
|
847
|
+
|
|
848
|
+
# @return [Ampost::Resources::Analytics]
|
|
849
|
+
attr_reader :analytics
|
|
850
|
+
|
|
851
|
+
# @return [Ampost::Resources::Webhooks]
|
|
852
|
+
attr_reader :webhooks
|
|
853
|
+
|
|
854
|
+
# @return [Ampost::Resources::Docs]
|
|
855
|
+
attr_reader :docs
|
|
856
|
+
|
|
857
|
+
# @return [Ampost::Resources::Feedback]
|
|
858
|
+
attr_reader :feedback
|
|
859
|
+
|
|
860
|
+
private
|
|
861
|
+
|
|
862
|
+
def init_resources
|
|
863
|
+
@platforms = Platforms.new(self)
|
|
864
|
+
@posts = Posts.new(self)
|
|
865
|
+
@media = Media.new(self)
|
|
866
|
+
@accounts = Accounts.new(self)
|
|
867
|
+
@platform_sets = PlatformSets.new(self)
|
|
868
|
+
@analytics = Analytics.new(self)
|
|
869
|
+
@webhooks = Webhooks.new(self)
|
|
870
|
+
@docs = Docs.new(self)
|
|
871
|
+
@feedback = Feedback.new(self)
|
|
872
|
+
end
|
|
873
|
+
end
|
|
874
|
+
end
|
|
875
|
+
|
|
876
|
+
# Every operation, for tests and tooling.
|
|
877
|
+
OPERATIONS = [
|
|
878
|
+
{ operation_id: "platforms_list", resource: "platforms", method: "list", http_method: "GET", path: "/api/platforms", idempotent: false, paginated: true }.freeze,
|
|
879
|
+
{ operation_id: "posts_list", resource: "posts", method: "list", http_method: "GET", path: "/api/posts", idempotent: false, paginated: true }.freeze,
|
|
880
|
+
{ operation_id: "posts_create", resource: "posts", method: "create", http_method: "POST", path: "/api/posts", idempotent: true, paginated: false }.freeze,
|
|
881
|
+
{ operation_id: "posts_validate", resource: "posts", method: "validate", http_method: "POST", path: "/api/posts/validate", idempotent: false, paginated: false }.freeze,
|
|
882
|
+
{ operation_id: "posts_import_csv", resource: "posts", method: "import_csv", http_method: "POST", path: "/api/posts/bulk", idempotent: true, paginated: false }.freeze,
|
|
883
|
+
{ operation_id: "posts_get", resource: "posts", method: "get", http_method: "GET", path: "/api/posts/{postId}", idempotent: false, paginated: false }.freeze,
|
|
884
|
+
{ operation_id: "posts_update", resource: "posts", method: "update", http_method: "PATCH", path: "/api/posts/{postId}", idempotent: false, paginated: false }.freeze,
|
|
885
|
+
{ operation_id: "posts_delete", resource: "posts", method: "delete", http_method: "DELETE", path: "/api/posts/{postId}", idempotent: false, paginated: false }.freeze,
|
|
886
|
+
{ operation_id: "posts_publish", resource: "posts", method: "publish", http_method: "POST", path: "/api/posts/{postId}/publish", idempotent: true, paginated: false }.freeze,
|
|
887
|
+
{ operation_id: "posts_unpublish", resource: "posts", method: "unpublish", http_method: "POST", path: "/api/posts/{postId}/unpublish", idempotent: false, paginated: false }.freeze,
|
|
888
|
+
{ operation_id: "posts_edit_published", resource: "posts", method: "edit_published", http_method: "POST", path: "/api/posts/{postId}/edit-published", idempotent: false, paginated: false }.freeze,
|
|
889
|
+
{ operation_id: "posts_retry", resource: "posts", method: "retry", http_method: "POST", path: "/api/posts/{postId}/retry", idempotent: true, paginated: false }.freeze,
|
|
890
|
+
{ operation_id: "media_upload_create", resource: "media", method: "create_upload", http_method: "POST", path: "/api/media/uploads", idempotent: false, paginated: false }.freeze,
|
|
891
|
+
{ operation_id: "media_upload_status", resource: "media", method: "get_upload", http_method: "GET", path: "/api/media/uploads/{uploadId}", idempotent: false, paginated: false }.freeze,
|
|
892
|
+
{ operation_id: "accounts_list", resource: "accounts", method: "list", http_method: "GET", path: "/api/accounts", idempotent: false, paginated: true }.freeze,
|
|
893
|
+
{ operation_id: "accounts_get", resource: "accounts", method: "get", http_method: "GET", path: "/api/accounts/{accountId}", idempotent: false, paginated: false }.freeze,
|
|
894
|
+
{ operation_id: "accounts_disconnect", resource: "accounts", method: "disconnect", http_method: "DELETE", path: "/api/accounts/{accountId}", idempotent: false, paginated: false }.freeze,
|
|
895
|
+
{ operation_id: "accounts_set_analytics", resource: "accounts", method: "set_analytics", http_method: "PATCH", path: "/api/accounts/{accountId}/analytics", idempotent: false, paginated: false }.freeze,
|
|
896
|
+
{ operation_id: "accounts_list_boards", resource: "accounts", method: "list_boards", http_method: "GET", path: "/api/accounts/{accountId}/boards", idempotent: false, paginated: false }.freeze,
|
|
897
|
+
{ operation_id: "accounts_set_board", resource: "accounts", method: "set_board", http_method: "PATCH", path: "/api/accounts/{accountId}/board", idempotent: false, paginated: false }.freeze,
|
|
898
|
+
{ operation_id: "accounts_connect", resource: "accounts", method: "connect", http_method: "POST", path: "/api/accounts/connect", idempotent: true, paginated: false }.freeze,
|
|
899
|
+
{ operation_id: "accounts_connect_status", resource: "accounts", method: "get_connect_request", http_method: "GET", path: "/api/accounts/connect/{connectRequestId}", idempotent: false, paginated: false }.freeze,
|
|
900
|
+
{ operation_id: "platform_sets_list", resource: "platform_sets", method: "list", http_method: "GET", path: "/api/platform-sets", idempotent: false, paginated: true }.freeze,
|
|
901
|
+
{ operation_id: "platform_sets_create", resource: "platform_sets", method: "create", http_method: "POST", path: "/api/platform-sets", idempotent: true, paginated: false }.freeze,
|
|
902
|
+
{ operation_id: "platform_sets_get", resource: "platform_sets", method: "get", http_method: "GET", path: "/api/platform-sets/{platformSetId}", idempotent: false, paginated: false }.freeze,
|
|
903
|
+
{ operation_id: "platform_sets_update", resource: "platform_sets", method: "update", http_method: "PATCH", path: "/api/platform-sets/{platformSetId}", idempotent: false, paginated: false }.freeze,
|
|
904
|
+
{ operation_id: "platform_sets_delete", resource: "platform_sets", method: "delete", http_method: "DELETE", path: "/api/platform-sets/{platformSetId}", idempotent: false, paginated: false }.freeze,
|
|
905
|
+
{ operation_id: "queue_get", resource: "platform_sets", method: "get_queue", http_method: "GET", path: "/api/platform-sets/{platformSetId}/queue", idempotent: false, paginated: false }.freeze,
|
|
906
|
+
{ operation_id: "queue_update", resource: "platform_sets", method: "update_queue", http_method: "PATCH", path: "/api/platform-sets/{platformSetId}/queue", idempotent: false, paginated: false }.freeze,
|
|
907
|
+
{ operation_id: "queue_slots", resource: "platform_sets", method: "get_queue_slots", http_method: "GET", path: "/api/platform-sets/{platformSetId}/queue/slots", idempotent: false, paginated: false }.freeze,
|
|
908
|
+
{ operation_id: "analytics_posts", resource: "analytics", method: "list_posts", http_method: "GET", path: "/api/analytics/posts", idempotent: false, paginated: true }.freeze,
|
|
909
|
+
{ operation_id: "analytics_overview", resource: "analytics", method: "get_overview", http_method: "GET", path: "/api/analytics/overview", idempotent: false, paginated: false }.freeze,
|
|
910
|
+
{ operation_id: "analytics_followers", resource: "analytics", method: "list_followers", http_method: "GET", path: "/api/analytics/followers", idempotent: false, paginated: true }.freeze,
|
|
911
|
+
{ operation_id: "webhooks_list", resource: "webhooks", method: "list", http_method: "GET", path: "/api/webhooks/endpoints", idempotent: false, paginated: true }.freeze,
|
|
912
|
+
{ operation_id: "webhooks_create", resource: "webhooks", method: "create", http_method: "POST", path: "/api/webhooks/endpoints", idempotent: true, paginated: false }.freeze,
|
|
913
|
+
{ operation_id: "webhooks_get", resource: "webhooks", method: "get", http_method: "GET", path: "/api/webhooks/endpoints/{webhookId}", idempotent: false, paginated: false }.freeze,
|
|
914
|
+
{ operation_id: "webhooks_update", resource: "webhooks", method: "update", http_method: "PATCH", path: "/api/webhooks/endpoints/{webhookId}", idempotent: false, paginated: false }.freeze,
|
|
915
|
+
{ operation_id: "webhooks_delete", resource: "webhooks", method: "delete", http_method: "DELETE", path: "/api/webhooks/endpoints/{webhookId}", idempotent: false, paginated: false }.freeze,
|
|
916
|
+
{ operation_id: "webhooks_test", resource: "webhooks", method: "test", http_method: "POST", path: "/api/webhooks/endpoints/{webhookId}/test", idempotent: false, paginated: false }.freeze,
|
|
917
|
+
{ operation_id: "webhooks_deliveries_list", resource: "webhooks", method: "list_deliveries", http_method: "GET", path: "/api/webhooks/endpoints/{webhookId}/deliveries", idempotent: false, paginated: true }.freeze,
|
|
918
|
+
{ operation_id: "webhooks_redeliver", resource: "webhooks", method: "redeliver", http_method: "POST", path: "/api/webhooks/endpoints/{webhookId}/deliveries/{deliveryId}/redeliver", idempotent: false, paginated: false }.freeze,
|
|
919
|
+
{ operation_id: "docs_search", resource: "docs", method: "search", http_method: "GET", path: "/api/docs/search", idempotent: false, paginated: false }.freeze,
|
|
920
|
+
{ operation_id: "feedback_submit", resource: "feedback", method: "submit", http_method: "POST", path: "/api/feedback", idempotent: true, paginated: false }.freeze
|
|
921
|
+
].freeze
|
|
922
|
+
end
|