x-twitter-scraper 0.4.1 → 0.5.1

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.
Files changed (171) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +1 -0
  3. package/client.d.mts +1 -1
  4. package/client.d.ts +1 -1
  5. package/client.js +1 -1
  6. package/client.mjs +1 -1
  7. package/package.json +1 -1
  8. package/resources/account.d.mts +2 -2
  9. package/resources/account.d.ts +2 -2
  10. package/resources/compose.d.mts +186 -65
  11. package/resources/compose.d.mts.map +1 -1
  12. package/resources/compose.d.ts +186 -65
  13. package/resources/compose.d.ts.map +1 -1
  14. package/resources/compose.js +5 -2
  15. package/resources/compose.js.map +1 -1
  16. package/resources/compose.mjs +5 -2
  17. package/resources/compose.mjs.map +1 -1
  18. package/resources/credits.d.mts +1 -1
  19. package/resources/credits.d.ts +1 -1
  20. package/resources/extractions.d.mts +4 -4
  21. package/resources/extractions.d.ts +4 -4
  22. package/resources/guest-wallets.d.mts +2 -2
  23. package/resources/guest-wallets.d.ts +2 -2
  24. package/resources/monitors/keywords.d.mts +4 -4
  25. package/resources/monitors/keywords.d.ts +4 -4
  26. package/resources/monitors/keywords.js +4 -4
  27. package/resources/monitors/keywords.mjs +4 -4
  28. package/resources/monitors/monitors.d.mts +5 -4
  29. package/resources/monitors/monitors.d.mts.map +1 -1
  30. package/resources/monitors/monitors.d.ts +5 -4
  31. package/resources/monitors/monitors.d.ts.map +1 -1
  32. package/resources/monitors/monitors.js +5 -4
  33. package/resources/monitors/monitors.js.map +1 -1
  34. package/resources/monitors/monitors.mjs +5 -4
  35. package/resources/monitors/monitors.mjs.map +1 -1
  36. package/resources/shared.d.mts +24 -8
  37. package/resources/shared.d.mts.map +1 -1
  38. package/resources/shared.d.ts +24 -8
  39. package/resources/shared.d.ts.map +1 -1
  40. package/resources/support/tickets.d.mts +67 -4
  41. package/resources/support/tickets.d.mts.map +1 -1
  42. package/resources/support/tickets.d.ts +67 -4
  43. package/resources/support/tickets.d.ts.map +1 -1
  44. package/resources/support/tickets.js +22 -4
  45. package/resources/support/tickets.js.map +1 -1
  46. package/resources/support/tickets.mjs +22 -4
  47. package/resources/support/tickets.mjs.map +1 -1
  48. package/resources/x/account-connection-challenges.d.mts +1 -1
  49. package/resources/x/account-connection-challenges.d.ts +1 -1
  50. package/resources/x/account-connection-challenges.js +1 -1
  51. package/resources/x/account-connection-challenges.mjs +1 -1
  52. package/resources/x/accounts.d.mts +9 -6
  53. package/resources/x/accounts.d.mts.map +1 -1
  54. package/resources/x/accounts.d.ts +9 -6
  55. package/resources/x/accounts.d.ts.map +1 -1
  56. package/resources/x/accounts.js +4 -2
  57. package/resources/x/accounts.js.map +1 -1
  58. package/resources/x/accounts.mjs +4 -2
  59. package/resources/x/accounts.mjs.map +1 -1
  60. package/resources/x/communities/communities.d.mts +360 -10
  61. package/resources/x/communities/communities.d.mts.map +1 -1
  62. package/resources/x/communities/communities.d.ts +360 -10
  63. package/resources/x/communities/communities.d.ts.map +1 -1
  64. package/resources/x/communities/communities.js +17 -4
  65. package/resources/x/communities/communities.js.map +1 -1
  66. package/resources/x/communities/communities.mjs +17 -4
  67. package/resources/x/communities/communities.mjs.map +1 -1
  68. package/resources/x/communities/join.d.mts +361 -7
  69. package/resources/x/communities/join.d.mts.map +1 -1
  70. package/resources/x/communities/join.d.ts +361 -7
  71. package/resources/x/communities/join.d.ts.map +1 -1
  72. package/resources/x/communities/join.js +20 -5
  73. package/resources/x/communities/join.js.map +1 -1
  74. package/resources/x/communities/join.mjs +20 -5
  75. package/resources/x/communities/join.mjs.map +1 -1
  76. package/resources/x/dm.d.mts +183 -5
  77. package/resources/x/dm.d.mts.map +1 -1
  78. package/resources/x/dm.d.ts +183 -5
  79. package/resources/x/dm.d.ts.map +1 -1
  80. package/resources/x/dm.js +9 -2
  81. package/resources/x/dm.js.map +1 -1
  82. package/resources/x/dm.mjs +9 -2
  83. package/resources/x/dm.mjs.map +1 -1
  84. package/resources/x/media.d.mts +178 -10
  85. package/resources/x/media.d.mts.map +1 -1
  86. package/resources/x/media.d.ts +178 -10
  87. package/resources/x/media.d.ts.map +1 -1
  88. package/resources/x/media.js +9 -5
  89. package/resources/x/media.js.map +1 -1
  90. package/resources/x/media.mjs +9 -5
  91. package/resources/x/media.mjs.map +1 -1
  92. package/resources/x/profile.d.mts +545 -14
  93. package/resources/x/profile.d.mts.map +1 -1
  94. package/resources/x/profile.d.ts +545 -14
  95. package/resources/x/profile.d.ts.map +1 -1
  96. package/resources/x/profile.js +25 -6
  97. package/resources/x/profile.js.map +1 -1
  98. package/resources/x/profile.mjs +25 -6
  99. package/resources/x/profile.mjs.map +1 -1
  100. package/resources/x/tweets/like.d.mts +358 -6
  101. package/resources/x/tweets/like.d.mts.map +1 -1
  102. package/resources/x/tweets/like.d.ts +358 -6
  103. package/resources/x/tweets/like.d.ts.map +1 -1
  104. package/resources/x/tweets/like.js +17 -4
  105. package/resources/x/tweets/like.js.map +1 -1
  106. package/resources/x/tweets/like.mjs +17 -4
  107. package/resources/x/tweets/like.mjs.map +1 -1
  108. package/resources/x/tweets/retweet.d.mts +358 -6
  109. package/resources/x/tweets/retweet.d.mts.map +1 -1
  110. package/resources/x/tweets/retweet.d.ts +358 -6
  111. package/resources/x/tweets/retweet.d.ts.map +1 -1
  112. package/resources/x/tweets/retweet.js +17 -4
  113. package/resources/x/tweets/retweet.js.map +1 -1
  114. package/resources/x/tweets/retweet.mjs +17 -4
  115. package/resources/x/tweets/retweet.mjs.map +1 -1
  116. package/resources/x/tweets/tweets.d.mts +376 -18
  117. package/resources/x/tweets/tweets.d.mts.map +1 -1
  118. package/resources/x/tweets/tweets.d.ts +376 -18
  119. package/resources/x/tweets/tweets.d.ts.map +1 -1
  120. package/resources/x/tweets/tweets.js +25 -6
  121. package/resources/x/tweets/tweets.js.map +1 -1
  122. package/resources/x/tweets/tweets.mjs +25 -6
  123. package/resources/x/tweets/tweets.mjs.map +1 -1
  124. package/resources/x/users/follow.d.mts +361 -7
  125. package/resources/x/users/follow.d.mts.map +1 -1
  126. package/resources/x/users/follow.d.ts +361 -7
  127. package/resources/x/users/follow.d.ts.map +1 -1
  128. package/resources/x/users/follow.js +20 -5
  129. package/resources/x/users/follow.js.map +1 -1
  130. package/resources/x/users/follow.mjs +20 -5
  131. package/resources/x/users/follow.mjs.map +1 -1
  132. package/resources/x/users/users.d.mts +181 -5
  133. package/resources/x/users/users.d.mts.map +1 -1
  134. package/resources/x/users/users.d.ts +181 -5
  135. package/resources/x/users/users.d.ts.map +1 -1
  136. package/resources/x/users/users.js +9 -2
  137. package/resources/x/users/users.js.map +1 -1
  138. package/resources/x/users/users.mjs +9 -2
  139. package/resources/x/users/users.mjs.map +1 -1
  140. package/resources/x/write-actions.d.mts +155 -12
  141. package/resources/x/write-actions.d.mts.map +1 -1
  142. package/resources/x/write-actions.d.ts +155 -12
  143. package/resources/x/write-actions.d.ts.map +1 -1
  144. package/src/client.ts +1 -1
  145. package/src/resources/account.ts +2 -2
  146. package/src/resources/compose.ts +232 -65
  147. package/src/resources/credits.ts +1 -1
  148. package/src/resources/extractions.ts +4 -4
  149. package/src/resources/guest-wallets.ts +2 -2
  150. package/src/resources/monitors/keywords.ts +4 -4
  151. package/src/resources/monitors/monitors.ts +5 -4
  152. package/src/resources/shared.ts +93 -9
  153. package/src/resources/support/tickets.ts +122 -6
  154. package/src/resources/x/account-connection-challenges.ts +1 -1
  155. package/src/resources/x/accounts.ts +9 -6
  156. package/src/resources/x/communities/communities.ts +515 -12
  157. package/src/resources/x/communities/join.ts +518 -9
  158. package/src/resources/x/dm.ts +261 -6
  159. package/src/resources/x/media.ts +258 -11
  160. package/src/resources/x/profile.ts +786 -17
  161. package/src/resources/x/tweets/like.ts +515 -8
  162. package/src/resources/x/tweets/retweet.ts +523 -8
  163. package/src/resources/x/tweets/tweets.ts +529 -23
  164. package/src/resources/x/users/follow.ts +518 -9
  165. package/src/resources/x/users/users.ts +260 -6
  166. package/src/resources/x/write-actions.ts +207 -14
  167. package/src/version.ts +1 -1
  168. package/version.d.mts +1 -1
  169. package/version.d.ts +1 -1
  170. package/version.js +1 -1
  171. package/version.mjs +1 -1
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { APIResource } from '../../core/resource';
4
4
  import { APIPromise } from '../../core/api-promise';
5
+ import { buildHeaders } from '../../internal/headers';
5
6
  import { RequestOptions } from '../../internal/request-options';
6
7
  import { path } from '../../internal/utils/path';
7
8
 
@@ -33,12 +34,18 @@ export class Dm extends APIResource {
33
34
  * const response = await client.x.dm.send('userId', {
34
35
  * account: '@elonmusk',
35
36
  * text: 'Example text content',
37
+ * 'Idempotency-Key': 'Idempotency-Key',
36
38
  * media_ids: ['1234567890123456789'],
37
39
  * });
38
40
  * ```
39
41
  */
40
- send(userID: string, body: DmSendParams, options?: RequestOptions): APIPromise<DmSendResponse> {
41
- return this._client.post(path`/x/dm/${userID}`, { body, ...options });
42
+ send(userID: string, params: DmSendParams, options?: RequestOptions): APIPromise<DmSendResponse> {
43
+ const { 'Idempotency-Key': idempotencyKey, ...body } = params;
44
+ return this._client.post(path`/x/dm/${userID}`, {
45
+ body,
46
+ ...options,
47
+ headers: buildHeaders([{ 'Idempotency-Key': idempotencyKey }, options?.headers]),
48
+ });
42
49
  }
43
50
  }
44
51
 
@@ -70,10 +77,247 @@ export namespace DmRetrieveHistoryResponse {
70
77
  }
71
78
  }
72
79
 
80
+ /**
81
+ * Durable write lifecycle record. Poll statusUrl until terminal is true. Reusing
82
+ * the original Idempotency-Key returns this same record. Submit a new write only
83
+ * when safeToRetry is true, using a new key.
84
+ */
73
85
  export interface DmSendResponse {
74
- messageId: string;
86
+ id: string;
75
87
 
76
- success: true;
88
+ /**
89
+ * Connected account selected for the write.
90
+ */
91
+ account: DmSendResponse.Account | null;
92
+
93
+ action:
94
+ | 'create_tweet'
95
+ | 'delete_tweet'
96
+ | 'like'
97
+ | 'unlike'
98
+ | 'retweet'
99
+ | 'unretweet'
100
+ | 'follow'
101
+ | 'unfollow'
102
+ | 'remove_follower'
103
+ | 'send_dm'
104
+ | 'upload_media'
105
+ | 'update_profile'
106
+ | 'update_avatar'
107
+ | 'update_banner'
108
+ | 'create_community'
109
+ | 'delete_community'
110
+ | 'join_community'
111
+ | 'leave_community';
112
+
113
+ /**
114
+ * plannedCredits is the approved maximum. chargedCredits comes from the settled
115
+ * credit ledger. Pending or failed writes are not charged.
116
+ */
117
+ billing: DmSendResponse.Billing;
118
+
119
+ charged: boolean;
120
+
121
+ chargedCredits: string;
122
+
123
+ /**
124
+ * Exact follow-up an API client or agent should perform.
125
+ */
126
+ nextAction: DmSendResponse.NextAction | null;
127
+
128
+ object: 'x_write_action';
129
+
130
+ pollAfterMs: number | null;
131
+
132
+ /**
133
+ * Stable fingerprint and sanitized payload for replay checks.
134
+ */
135
+ request: DmSendResponse.Request;
136
+
137
+ /**
138
+ * Confirmed result produced by the write, when available.
139
+ */
140
+ result: DmSendResponse.Result | null;
141
+
142
+ /**
143
+ * True only when a new attempt can reasonably succeed.
144
+ */
145
+ retryable: boolean;
146
+
147
+ /**
148
+ * True only when no write was dispatched and a new idempotency key may be used.
149
+ */
150
+ safeToRetry: boolean;
151
+
152
+ sendDispatched: boolean;
153
+
154
+ status: 'accepted' | 'dispatching' | 'pending_confirmation' | 'success' | 'failed' | 'expired';
155
+
156
+ statusUrl: string;
157
+
158
+ success: boolean;
159
+
160
+ /**
161
+ * Existing X resource targeted by the write, when applicable.
162
+ */
163
+ target: DmSendResponse.Target | null;
164
+
165
+ targetId: string | null;
166
+
167
+ terminal: boolean;
168
+
169
+ writeActionId: string;
170
+
171
+ /**
172
+ * Compatibility field for a confirmed community ID.
173
+ */
174
+ communityId?: string;
175
+
176
+ /**
177
+ * Confirmed community name when available.
178
+ */
179
+ communityName?: string;
180
+
181
+ completedAt?: string;
182
+
183
+ confirmationAttempts?: number;
184
+
185
+ confirmationCheckedAt?: string;
186
+
187
+ confirmedAt?: string;
188
+
189
+ createdAt?: string;
190
+
191
+ /**
192
+ * Structured recovery context for a failed write.
193
+ */
194
+ details?: { [key: string]: unknown };
195
+
196
+ error?: string;
197
+
198
+ /**
199
+ * Deadline for resolving a non-terminal write. This is not the Idempotency-Key
200
+ * retention deadline.
201
+ */
202
+ expiresAt?: string;
203
+
204
+ idempotent?: boolean;
205
+
206
+ /**
207
+ * Media count, kind, size, and billing details when used.
208
+ */
209
+ media?: { [key: string]: unknown };
210
+
211
+ /**
212
+ * Compatibility field for a confirmed media upload ID.
213
+ */
214
+ mediaId?: string;
215
+
216
+ /**
217
+ * Public media URL when the upload creates one.
218
+ */
219
+ mediaUrl?: string;
220
+
221
+ message?: string;
222
+
223
+ /**
224
+ * Compatibility field for a confirmed direct message ID.
225
+ */
226
+ messageId?: string;
227
+
228
+ requestHash?: string;
229
+
230
+ requestId?: string;
231
+
232
+ /**
233
+ * Compatibility result ID for other write actions.
234
+ */
235
+ resultId?: string;
236
+
237
+ /**
238
+ * Dispatch timestamp when the write reached execution.
239
+ */
240
+ sendDispatchedAt?: string;
241
+
242
+ /**
243
+ * Compatibility field for a confirmed tweet result ID.
244
+ */
245
+ tweetId?: string;
246
+
247
+ updatedAt?: string;
248
+ }
249
+
250
+ export namespace DmSendResponse {
251
+ /**
252
+ * Connected account selected for the write.
253
+ */
254
+ export interface Account {
255
+ id: string;
256
+
257
+ username: string;
258
+ }
259
+
260
+ /**
261
+ * plannedCredits is the approved maximum. chargedCredits comes from the settled
262
+ * credit ledger. Pending or failed writes are not charged.
263
+ */
264
+ export interface Billing {
265
+ charged: boolean;
266
+
267
+ chargedCredits: string;
268
+
269
+ plannedCredits: string;
270
+
271
+ status: 'not_charged' | 'pending' | 'charged' | 'charge_failed' | 'refunded';
272
+ }
273
+
274
+ /**
275
+ * Exact follow-up an API client or agent should perform.
276
+ */
277
+ export interface NextAction {
278
+ type: 'poll' | 'retry' | 'verify_result' | 'fix_request';
279
+
280
+ afterMs?: number;
281
+
282
+ requiresNewIdempotencyKey?: boolean;
283
+
284
+ url?: string;
285
+ }
286
+
287
+ /**
288
+ * Stable fingerprint and sanitized payload for replay checks.
289
+ */
290
+ export interface Request {
291
+ /**
292
+ * Stable hash of account, action, target, and payload.
293
+ */
294
+ hash: string | null;
295
+
296
+ /**
297
+ * Exact sanitized payload dispatched for this action.
298
+ */
299
+ payload: { [key: string]: unknown } | null;
300
+ }
301
+
302
+ /**
303
+ * Confirmed result produced by the write, when available.
304
+ */
305
+ export interface Result {
306
+ id?: string;
307
+
308
+ state?: string;
309
+
310
+ type?: 'tweet' | 'direct_message' | 'media' | 'community' | 'state_change';
311
+ }
312
+
313
+ /**
314
+ * Existing X resource targeted by the write, when applicable.
315
+ */
316
+ export interface Target {
317
+ id: string;
318
+
319
+ type: 'tweet' | 'user' | 'community';
320
+ }
77
321
  }
78
322
 
79
323
  export interface DmRetrieveHistoryParams {
@@ -96,14 +340,25 @@ export interface DmRetrieveHistoryParams {
96
340
 
97
341
  export interface DmSendParams {
98
342
  /**
99
- * X account (@username or ID) sending the DM
343
+ * Body param: X account (@username or ID) sending the DM
100
344
  */
101
345
  account: string;
102
346
 
347
+ /**
348
+ * Body param
349
+ */
103
350
  text: string;
104
351
 
105
352
  /**
106
- * Optional array containing exactly 1 uploaded media ID.
353
+ * Header param: Generate one unique value for each intended write. Reuse it only
354
+ * when retrying the exact same account, action, target, and payload. A reused key
355
+ * returns the original action. Reusing it with different input returns 409. Replay
356
+ * protection remains active for at least 90 days.
357
+ */
358
+ 'Idempotency-Key': string;
359
+
360
+ /**
361
+ * Body param: Optional array containing exactly 1 uploaded media ID.
107
362
  */
108
363
  media_ids?: Array<string>;
109
364
  }
@@ -2,12 +2,10 @@
2
2
 
3
3
  import { APIResource } from '../../core/resource';
4
4
  import { APIPromise } from '../../core/api-promise';
5
+ import { buildHeaders } from '../../internal/headers';
5
6
  import { RequestOptions } from '../../internal/request-options';
6
7
  import { maybeMultipartFormRequestOptions } from '../../internal/uploads';
7
8
 
8
- /**
9
- * Media upload and download
10
- */
11
9
  export class Media extends APIResource {
12
10
  /**
13
11
  * Download images and videos from tweets
@@ -31,13 +29,22 @@ export class Media extends APIResource {
31
29
  * const response = await client.x.media.upload({
32
30
  * account: '@elonmusk',
33
31
  * url: 'https://example.com/image.png',
32
+ * 'Idempotency-Key': 'Idempotency-Key',
34
33
  * });
35
34
  * ```
36
35
  */
37
- upload(body: MediaUploadParams, options?: RequestOptions): APIPromise<MediaUploadResponse> {
36
+ upload(params: MediaUploadParams, options?: RequestOptions): APIPromise<MediaUploadResponse> {
37
+ const { 'Idempotency-Key': idempotencyKey, ...body } = params;
38
38
  return this._client.post(
39
39
  '/x/media',
40
- maybeMultipartFormRequestOptions({ body, ...options }, this._client),
40
+ maybeMultipartFormRequestOptions(
41
+ {
42
+ body,
43
+ ...options,
44
+ headers: buildHeaders([{ 'Idempotency-Key': idempotencyKey }, options?.headers]),
45
+ },
46
+ this._client,
47
+ ),
41
48
  );
42
49
  }
43
50
  }
@@ -54,15 +61,247 @@ export interface MediaDownloadResponse {
54
61
  tweetId?: string;
55
62
  }
56
63
 
64
+ /**
65
+ * Durable write lifecycle record. Poll statusUrl until terminal is true. Reusing
66
+ * the original Idempotency-Key returns this same record. Submit a new write only
67
+ * when safeToRetry is true, using a new key.
68
+ */
57
69
  export interface MediaUploadResponse {
58
- mediaId: string;
70
+ id: string;
71
+
72
+ /**
73
+ * Connected account selected for the write.
74
+ */
75
+ account: MediaUploadResponse.Account | null;
76
+
77
+ action:
78
+ | 'create_tweet'
79
+ | 'delete_tweet'
80
+ | 'like'
81
+ | 'unlike'
82
+ | 'retweet'
83
+ | 'unretweet'
84
+ | 'follow'
85
+ | 'unfollow'
86
+ | 'remove_follower'
87
+ | 'send_dm'
88
+ | 'upload_media'
89
+ | 'update_profile'
90
+ | 'update_avatar'
91
+ | 'update_banner'
92
+ | 'create_community'
93
+ | 'delete_community'
94
+ | 'join_community'
95
+ | 'leave_community';
96
+
97
+ /**
98
+ * plannedCredits is the approved maximum. chargedCredits comes from the settled
99
+ * credit ledger. Pending or failed writes are not charged.
100
+ */
101
+ billing: MediaUploadResponse.Billing;
102
+
103
+ charged: boolean;
104
+
105
+ chargedCredits: string;
106
+
107
+ /**
108
+ * Exact follow-up an API client or agent should perform.
109
+ */
110
+ nextAction: MediaUploadResponse.NextAction | null;
111
+
112
+ object: 'x_write_action';
113
+
114
+ pollAfterMs: number | null;
115
+
116
+ /**
117
+ * Stable fingerprint and sanitized payload for replay checks.
118
+ */
119
+ request: MediaUploadResponse.Request;
120
+
121
+ /**
122
+ * Confirmed result produced by the write, when available.
123
+ */
124
+ result: MediaUploadResponse.Result | null;
125
+
126
+ /**
127
+ * True only when a new attempt can reasonably succeed.
128
+ */
129
+ retryable: boolean;
130
+
131
+ /**
132
+ * True only when no write was dispatched and a new idempotency key may be used.
133
+ */
134
+ safeToRetry: boolean;
135
+
136
+ sendDispatched: boolean;
137
+
138
+ status: 'accepted' | 'dispatching' | 'pending_confirmation' | 'success' | 'failed' | 'expired';
139
+
140
+ statusUrl: string;
141
+
142
+ success: boolean;
143
+
144
+ /**
145
+ * Existing X resource targeted by the write, when applicable.
146
+ */
147
+ target: MediaUploadResponse.Target | null;
148
+
149
+ targetId: string | null;
150
+
151
+ terminal: boolean;
152
+
153
+ writeActionId: string;
154
+
155
+ /**
156
+ * Compatibility field for a confirmed community ID.
157
+ */
158
+ communityId?: string;
159
+
160
+ /**
161
+ * Confirmed community name when available.
162
+ */
163
+ communityName?: string;
164
+
165
+ completedAt?: string;
166
+
167
+ confirmationAttempts?: number;
168
+
169
+ confirmationCheckedAt?: string;
170
+
171
+ confirmedAt?: string;
172
+
173
+ createdAt?: string;
174
+
175
+ /**
176
+ * Structured recovery context for a failed write.
177
+ */
178
+ details?: { [key: string]: unknown };
179
+
180
+ error?: string;
181
+
182
+ /**
183
+ * Deadline for resolving a non-terminal write. This is not the Idempotency-Key
184
+ * retention deadline.
185
+ */
186
+ expiresAt?: string;
187
+
188
+ idempotent?: boolean;
189
+
190
+ /**
191
+ * Media count, kind, size, and billing details when used.
192
+ */
193
+ media?: { [key: string]: unknown };
194
+
195
+ /**
196
+ * Compatibility field for a confirmed media upload ID.
197
+ */
198
+ mediaId?: string;
199
+
200
+ /**
201
+ * Public media URL when the upload creates one.
202
+ */
203
+ mediaUrl?: string;
204
+
205
+ message?: string;
206
+
207
+ /**
208
+ * Compatibility field for a confirmed direct message ID.
209
+ */
210
+ messageId?: string;
211
+
212
+ requestHash?: string;
213
+
214
+ requestId?: string;
215
+
216
+ /**
217
+ * Compatibility result ID for other write actions.
218
+ */
219
+ resultId?: string;
220
+
221
+ /**
222
+ * Dispatch timestamp when the write reached execution.
223
+ */
224
+ sendDispatchedAt?: string;
225
+
226
+ /**
227
+ * Compatibility field for a confirmed tweet result ID.
228
+ */
229
+ tweetId?: string;
230
+
231
+ updatedAt?: string;
232
+ }
233
+
234
+ export namespace MediaUploadResponse {
235
+ /**
236
+ * Connected account selected for the write.
237
+ */
238
+ export interface Account {
239
+ id: string;
240
+
241
+ username: string;
242
+ }
243
+
244
+ /**
245
+ * plannedCredits is the approved maximum. chargedCredits comes from the settled
246
+ * credit ledger. Pending or failed writes are not charged.
247
+ */
248
+ export interface Billing {
249
+ charged: boolean;
250
+
251
+ chargedCredits: string;
252
+
253
+ plannedCredits: string;
254
+
255
+ status: 'not_charged' | 'pending' | 'charged' | 'charge_failed' | 'refunded';
256
+ }
257
+
258
+ /**
259
+ * Exact follow-up an API client or agent should perform.
260
+ */
261
+ export interface NextAction {
262
+ type: 'poll' | 'retry' | 'verify_result' | 'fix_request';
263
+
264
+ afterMs?: number;
265
+
266
+ requiresNewIdempotencyKey?: boolean;
267
+
268
+ url?: string;
269
+ }
59
270
 
60
271
  /**
61
- * Public media URL for tweet `media` arrays.
272
+ * Stable fingerprint and sanitized payload for replay checks.
62
273
  */
63
- mediaUrl: string;
274
+ export interface Request {
275
+ /**
276
+ * Stable hash of account, action, target, and payload.
277
+ */
278
+ hash: string | null;
64
279
 
65
- success: true;
280
+ /**
281
+ * Exact sanitized payload dispatched for this action.
282
+ */
283
+ payload: { [key: string]: unknown } | null;
284
+ }
285
+
286
+ /**
287
+ * Confirmed result produced by the write, when available.
288
+ */
289
+ export interface Result {
290
+ id?: string;
291
+
292
+ state?: string;
293
+
294
+ type?: 'tweet' | 'direct_message' | 'media' | 'community' | 'state_change';
295
+ }
296
+
297
+ /**
298
+ * Existing X resource targeted by the write, when applicable.
299
+ */
300
+ export interface Target {
301
+ id: string;
302
+
303
+ type: 'tweet' | 'user' | 'community';
304
+ }
66
305
  }
67
306
 
68
307
  export interface MediaDownloadParams {
@@ -89,14 +328,22 @@ export interface MediaDownloadParams {
89
328
 
90
329
  export interface MediaUploadParams {
91
330
  /**
92
- * X account (@username or ID) uploading media from URL
331
+ * Body param: X account (@username or ID) uploading media from URL
93
332
  */
94
333
  account: string;
95
334
 
96
335
  /**
97
- * HTTPS URL to download and upload as media
336
+ * Body param: HTTPS URL to download and upload as media
98
337
  */
99
338
  url: string;
339
+
340
+ /**
341
+ * Header param: Generate one unique value for each intended write. Reuse it only
342
+ * when retrying the exact same account, action, target, and payload. A reused key
343
+ * returns the original action. Reusing it with different input returns 409. Replay
344
+ * protection remains active for at least 90 days.
345
+ */
346
+ 'Idempotency-Key': string;
100
347
  }
101
348
 
102
349
  export declare namespace Media {