1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
use crate::api::*;
use crate::{ApiError, ClientConfig, HttpClient, QueryBuilder, RequestOptions};
use reqwest::Method;
pub mod preferences;
pub use preferences::PreferencesClient;
pub mod reserves;
pub use reserves::ReservesClient;
pub struct AccountsClient {
pub http_client: HttpClient,
pub preferences: PreferencesClient,
pub reserves: ReservesClient,
}
impl AccountsClient {
pub fn new(config: ClientConfig) -> Result<Self, ApiError> {
Ok(Self {
http_client: HttpClient::new(config.clone())?,
preferences: PreferencesClient::new(config.clone())?,
reserves: ReservesClient::new(config.clone())?,
})
}
/// Lists accounts visible to the credential. User tokens return the user's business accounts; Account API keys return the requesting account and its connected accounts. Pass `parent_account_id` to return only that parent account's connected accounts.
///
/// # Arguments
///
/// * `first` - The number of accounts to return (default 10, max 50).
/// * `after` - A cursor; returns accounts after this position.
/// * `last` - The number of accounts to return from the end of the range.
/// * `before` - A cursor; returns accounts before this position.
/// * `order` - The field to sort accounts by. `volume` requires `stats:read` on the parent account.
/// * `direction` - Sort direction.
/// * `status` - Return only accounts with this status: `active` (includes accounts that have not entered payments review) or `suspended`.
/// * `query` - Free-text filter on account title or ID. `%` and `_` match literally.
/// * `created_after` - Return only accounts created after this ISO 8601 timestamp.
/// * `created_before` - Return only accounts created before this ISO 8601 timestamp.
/// * `volume_min` - Return only accounts whose lifetime USD volume is at least this value. Requires `stats:read` on the parent account.
/// * `volume_max` - Return only accounts whose lifetime USD volume is at most this value. Requires `stats:read` on the parent account.
/// * `parent_account_id` - For platforms: the parent account ID whose direct connected accounts to return. Requires `payout:account:read` on the parent account.
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
///
/// # Examples
///
/// ```no_run
/// use whop_sdk::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
/// let config = ClientConfig {
/// token: Some("<token>".to_string()),
/// ..Default::default()
/// };
/// let client = Whop::new(config).expect("Failed to build client");
/// client
/// .accounts
/// .list(
/// &AccountsListQueryRequest {
/// ..Default::default()
/// },
/// None,
/// )
/// .await;
/// }
/// ```
pub async fn list(
&self,
request: &AccountsListQueryRequest,
options: Option<RequestOptions>,
) -> Result<ListAccountsResponse, ApiError> {
let options = {
let mut o = options.unwrap_or_default();
o.additional_headers
.entry("Api-Version-Date".to_string())
.or_insert_with(|| "2026-08-21-1".to_string());
Some(o)
};
self.http_client
.execute_request(
Method::GET,
"accounts",
None,
QueryBuilder::new()
.int("first", request.first.clone())
.string("after", request.after.clone())
.int("last", request.last.clone())
.string("before", request.before.clone())
.serialize("order", request.order.clone())
.serialize("direction", request.direction.clone())
.serialize("status", request.status.clone())
.structured_query("query", request.query.clone())
.datetime("created_after", request.created_after.clone())
.datetime("created_before", request.created_before.clone())
.float("volume_min", request.volume_min.clone())
.float("volume_max", request.volume_max.clone())
.string("parent_account_id", request.parent_account_id.clone())
.build(),
options,
)
.await
}
/// Creates an account. User tokens create business accounts; Account API keys create connected accounts. Tax fields (`tax_remitted_by`, `tax_type`, `product_tax_code_id`, `business_address`, `tax_identifiers`) are configured with Update Account, not at creation.
///
/// # Arguments
///
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
///
/// # Examples
///
/// ```no_run
/// use whop_sdk::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
/// let config = ClientConfig {
/// token: Some("<token>".to_string()),
/// ..Default::default()
/// };
/// let client = Whop::new(config).expect("Failed to build client");
/// client
/// .accounts
/// .create(
/// &CreateAccountsRequest {
/// ..Default::default()
/// },
/// None,
/// )
/// .await;
/// }
/// ```
pub async fn create(
&self,
request: &CreateAccountsRequest,
options: Option<RequestOptions>,
) -> Result<Account, ApiError> {
let options = {
let mut o = options.unwrap_or_default();
o.additional_headers
.entry("Api-Version-Date".to_string())
.or_insert_with(|| "2026-08-21-1".to_string());
Some(o)
};
self.http_client
.execute_request(
Method::POST,
"accounts",
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
/// Retrieves the account associated with the current Account API key.
///
/// # Arguments
///
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
///
/// # Examples
///
/// ```no_run
/// use whop_sdk::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
/// let config = ClientConfig {
/// token: Some("<token>".to_string()),
/// ..Default::default()
/// };
/// let client = Whop::new(config).expect("Failed to build client");
/// client.accounts.me(None).await;
/// }
/// ```
pub async fn me(&self, options: Option<RequestOptions>) -> Result<Account, ApiError> {
let options = {
let mut o = options.unwrap_or_default();
o.additional_headers
.entry("Api-Version-Date".to_string())
.or_insert_with(|| "2026-08-21-1".to_string());
Some(o)
};
self.http_client
.execute_request(Method::GET, "accounts/me", None, None, options)
.await
}
/// Retrieves a single account by ID or public route when it is visible to the credential, including its crypto wallet. The reserved id `me` retrieves the account associated with the current Account API key; user tokens have no single account, so they must address one by ID or route.
///
/// # Arguments
///
/// * `id` - Account ID, prefixed `biz_`, its public route, or `me` for the account associated with the current API key.
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
///
/// # Examples
///
/// ```no_run
/// use whop_sdk::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
/// let config = ClientConfig {
/// token: Some("<token>".to_string()),
/// ..Default::default()
/// };
/// let client = Whop::new(config).expect("Failed to build client");
/// client.accounts.retrieve(&"id".to_string(), None).await;
/// }
/// ```
pub async fn retrieve(
&self,
id: &str,
options: Option<RequestOptions>,
) -> Result<Account, ApiError> {
let options = {
let mut o = options.unwrap_or_default();
o.additional_headers
.entry("Api-Version-Date".to_string())
.or_insert_with(|| "2026-08-21-1".to_string());
Some(o)
};
self.http_client
.execute_request(
Method::GET,
&format!("accounts/{}", id),
None,
None,
options,
)
.await
}
/// Updates an account. User tokens can update business accounts; Account API keys can update connected accounts. The reserved id `me` — accepted on Retrieve Account — resolves to the requesting account, which an Account API key cannot edit, so updates must name the connected account by its `biz_` id.
///
/// # Arguments
///
/// * `id` - Account ID, prefixed `biz_`.
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
///
/// # Examples
///
/// ```no_run
/// use whop_sdk::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
/// let config = ClientConfig {
/// token: Some("<token>".to_string()),
/// ..Default::default()
/// };
/// let client = Whop::new(config).expect("Failed to build client");
/// client
/// .accounts
/// .update(
/// &"id".to_string(),
/// &UpdateAccountsRequest {
/// ..Default::default()
/// },
/// None,
/// )
/// .await;
/// }
/// ```
pub async fn update(
&self,
id: &str,
request: &UpdateAccountsRequest,
options: Option<RequestOptions>,
) -> Result<Account, ApiError> {
let options = {
let mut o = options.unwrap_or_default();
o.additional_headers
.entry("Api-Version-Date".to_string())
.or_insert_with(|| "2026-08-21-1".to_string());
Some(o)
};
self.http_client
.execute_request(
Method::PATCH,
&format!("accounts/{}", id),
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
/// Starts an LLC or C-Corp formation for a business account. Defaults to an LLC; set `entity_type` to `c_corp` to form a C-Corp, which additionally requires `share_structure` and officer `roles` on every founder. On submission, the application is validated and the response returns a hosted checkout URL. Once paid, the filing is submitted. Track progress through the account's [`company_formation`](/api-reference/beta/accounts/retrieve-account) field on Retrieve Account.
///
/// # Arguments
///
/// * `id` - Account ID, prefixed `biz_`.
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
///
/// # Examples
///
/// ```no_run
/// use whop_sdk::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
/// let config = ClientConfig {
/// token: Some("<token>".to_string()),
/// ..Default::default()
/// };
/// let client = Whop::new(config).expect("Failed to build client");
/// client
/// .accounts
/// .form_company(
/// &"id".to_string(),
/// &FormCompanyAccountsRequest {
/// business_address: Some(FormCompanyAccountsRequestBusinessAddress {
/// city: "Austin".to_string(),
/// country: "US".to_string(),
/// line1: "4180 Burnet Rd".to_string(),
/// line2: Some("Suite 2".to_string()),
/// postal_code: "78756".to_string(),
/// state: "TX".to_string(),
/// ..Default::default()
/// }),
/// business_name: "Shine Time Auto Detailing".to_string(),
/// business_phone: Some("+15125550142".to_string()),
/// business_type: "brick_and_mortar".to_string(),
/// business_website: Some("https://shinetime.example".to_string()),
/// entity_suffix: Some(FormCompanyAccountsRequestEntitySuffix::Llc),
/// entity_type: Some(FormCompanyAccountsRequestEntityType::Llc),
/// expedite_ein: Some(true),
/// formation_state: FormCompanyAccountsRequestFormationState::Tx,
/// founders: vec![FormCompanyAccountsRequestFoundersItem {
/// address: FormCompanyAccountsRequestFoundersItemAddress {
/// city: "Austin".to_string(),
/// country: "US".to_string(),
/// line1: "907 Ridgemont Dr".to_string(),
/// line2: Some("Apt 4".to_string()),
/// postal_code: "78704".to_string(),
/// state: "TX".to_string(),
/// ..Default::default()
/// },
/// date_of_birth: Some("1988-03-14".to_string()),
/// email: "marcus@shinetime.example".to_string(),
/// first_name: "Marcus".to_string(),
/// is_primary: true,
/// last_name: "Webb".to_string(),
/// ownership_percentage: Some(100.0),
/// phone: "+15125550142".to_string(),
/// roles: Some(vec![
/// FormCompanyAccountsRequestFoundersItemRolesItem::President,
/// ]),
/// ssn: Some("123-45-6789".to_string()),
/// ..Default::default()
/// }],
/// industry_group: "automotive".to_string(),
/// industry_type: "car_wash".to_string(),
/// share_structure: Some(FormCompanyAccountsRequestShareStructure {
/// number_of_shares: 123,
/// value: 123.0,
/// ..Default::default()
/// }),
/// use_registered_agent: Some(true),
/// },
/// None,
/// )
/// .await;
/// }
/// ```
pub async fn form_company(
&self,
id: &str,
request: &FormCompanyAccountsRequest,
options: Option<RequestOptions>,
) -> Result<FormCompanyAccountsResponse, ApiError> {
let options = {
let mut o = options.unwrap_or_default();
o.additional_headers
.entry("Api-Version-Date".to_string())
.or_insert_with(|| "2026-08-21-1".to_string());
Some(o)
};
self.http_client
.execute_request(
Method::POST,
&format!("accounts/{}/form_company", id),
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
/// Transfers ownership of the account to another user, identified by user ID or email address. If the recipient already holds the owner role, ownership moves immediately; otherwise they get an invite and ownership moves when they accept.
///
/// # Arguments
///
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
///
/// # Examples
///
/// ```no_run
/// use whop_sdk::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
/// let config = ClientConfig {
/// token: Some("<token>".to_string()),
/// ..Default::default()
/// };
/// let client = Whop::new(config).expect("Failed to build client");
/// client
/// .accounts
/// .transfer_ownership(
/// &"id".to_string(),
/// &TransferOwnershipAccountsRequest {
/// identifier: "marcus@shinetime.example".to_string(),
/// as_partner: None,
/// },
/// None,
/// )
/// .await;
/// }
/// ```
pub async fn transfer_ownership(
&self,
id: &str,
request: &TransferOwnershipAccountsRequest,
options: Option<RequestOptions>,
) -> Result<TransferOwnershipAccountsResponse, ApiError> {
let options = {
let mut o = options.unwrap_or_default();
o.additional_headers
.entry("Api-Version-Date".to_string())
.or_insert_with(|| "2026-08-21-1".to_string());
Some(o)
};
self.http_client
.execute_request(
Method::POST,
&format!("accounts/{}/transfer_ownership", id),
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
}