Skip to main content

ghl_models/v3/
oauth.rs

1//! `oauth` data models for GoHighLevel API V3 (12 types).
2//!
3//! Generated from HighLevel's official OpenAPI spec for the
4//! **Oauth** module. Every endpoint that uses these types, with its
5//! parameters, required scopes and enum values, is documented in the
6//! [`oauth` API reference](https://github.com/Shahroz/ghl-rs/blob/main/docs/api/oauth.md).
7//!
8//! Enable with `features = ["oauth"]`.
9// @generated by xtask/generate_models.py — do not edit by hand.
10// Source: https://github.com/GoHighLevel/highlevel-api-docs
11// Doc comments are HighLevel's own field descriptions, reflowed verbatim, so
12// they aren't held to rustdoc's markdown conventions.
13#![allow(
14    missing_docs,
15    clippy::doc_lazy_continuation,
16    clippy::doc_overindented_list_items
17)]
18
19use serde::{Deserialize, Serialize};
20
21/// `AipErrorBodyDto` from the GoHighLevel OpenAPI spec.
22#[derive(Debug, Clone, Default, Serialize, Deserialize)]
23pub struct AipErrorBodyDto {
24    /// Machine-readable error code (see AipErrorCode enum in @platform-core/aip-framework)
25    /// Required by the API.
26    /// (Optional here so responses that omit it still parse.)
27    #[serde(default, skip_serializing_if = "Option::is_none")]
28    pub code: Option<String>,
29    /// Human-readable error message
30    /// Required by the API.
31    /// (Optional here so responses that omit it still parse.)
32    #[serde(default, skip_serializing_if = "Option::is_none")]
33    pub message: Option<String>,
34    /// Additional error context (field name, identifier, etc.)
35    #[serde(default, skip_serializing_if = "Option::is_none")]
36    pub details: Option<serde_json::Value>,
37    /// Suggested resolution for the caller
38    #[serde(default, skip_serializing_if = "Option::is_none")]
39    pub resolution: Option<String>,
40}
41
42/// `AipErrorResponseDto` from the GoHighLevel OpenAPI spec.
43#[derive(Debug, Clone, Default, Serialize, Deserialize)]
44pub struct AipErrorResponseDto {
45    /// AIP-compliant error envelope
46    /// Required by the API.
47    /// (Optional here so responses that omit it still parse.)
48    #[serde(default, skip_serializing_if = "Option::is_none")]
49    pub error: Option<AipErrorBodyDto>,
50}
51
52/// `GetAccessTokenBodyDto` from the GoHighLevel OpenAPI spec.
53#[derive(Debug, Clone, Default, Serialize, Deserialize)]
54pub struct GetAccessTokenBodyDto {
55    /// The ID provided by CRM for your integration
56    /// Required by the API.
57    #[serde(rename = "clientId")]
58    pub client_id: String,
59    /// The client secret provided by CRM for your integration
60    /// Required by the API.
61    #[serde(rename = "clientSecret")]
62    pub client_secret: String,
63    /// The OAuth2 grant type — authorization_code, refresh_token, or client_credentials
64    /// Allowed values: `authorization_code`, `refresh_token`, `client_credentials`.
65    /// Required by the API.
66    #[serde(rename = "grantType")]
67    pub grant_type: String,
68    /// The authorization code received from the authorization endpoint (required for
69    /// authorization_code grant)
70    #[serde(default, skip_serializing_if = "Option::is_none")]
71    pub code: Option<String>,
72    /// The refresh token used to obtain a new access token (required for refresh_token grant)
73    #[serde(
74        rename = "refreshToken",
75        default,
76        skip_serializing_if = "Option::is_none"
77    )]
78    pub refresh_token: Option<String>,
79    /// The type of token to be requested
80    /// Allowed values: `Company`, `Location`.
81    #[serde(rename = "userType", default, skip_serializing_if = "Option::is_none")]
82    pub user_type: Option<String>,
83    /// The redirect URI for your application
84    #[serde(
85        rename = "redirectUri",
86        default,
87        skip_serializing_if = "Option::is_none"
88    )]
89    pub redirect_uri: Option<String>,
90}
91
92/// `GetAccessTokenSuccessfulResponseDto` from the GoHighLevel OpenAPI spec.
93#[derive(Debug, Clone, Default, Serialize, Deserialize)]
94pub struct GetAccessTokenSuccessfulResponseDto {
95    /// The OAuth2 access token
96    #[serde(
97        rename = "accessToken",
98        default,
99        skip_serializing_if = "Option::is_none"
100    )]
101    pub access_token: Option<String>,
102    /// The token type (always Bearer)
103    #[serde(rename = "tokenType", default, skip_serializing_if = "Option::is_none")]
104    pub token_type: Option<String>,
105    /// Time in seconds until the access token expires
106    #[serde(rename = "expiresIn", default, skip_serializing_if = "Option::is_none")]
107    pub expires_in: Option<f64>,
108    /// The OAuth2 refresh token used to obtain a new access token
109    #[serde(
110        rename = "refreshToken",
111        default,
112        skip_serializing_if = "Option::is_none"
113    )]
114    pub refresh_token: Option<String>,
115    /// Space-separated list of scopes the access token has access to
116    #[serde(default, skip_serializing_if = "Option::is_none")]
117    pub scope: Option<String>,
118    /// The user type associated with the token (Location or Company)
119    #[serde(rename = "userType", default, skip_serializing_if = "Option::is_none")]
120    pub user_type: Option<String>,
121    /// Location ID - Present only for Sub-Account Access Token
122    #[serde(
123        rename = "locationId",
124        default,
125        skip_serializing_if = "Option::is_none"
126    )]
127    pub location_id: Option<String>,
128    /// Company ID
129    #[serde(rename = "companyId", default, skip_serializing_if = "Option::is_none")]
130    pub company_id: Option<String>,
131    /// Approved locations to generate location access token
132    #[serde(
133        rename = "approvedLocations",
134        default,
135        skip_serializing_if = "Vec::is_empty"
136    )]
137    pub approved_locations: Vec<String>,
138    /// USER ID - Represent user id of person who performed installation
139    /// Required by the API.
140    /// (Optional here so responses that omit it still parse.)
141    #[serde(rename = "userId", default, skip_serializing_if = "Option::is_none")]
142    pub user_id: Option<String>,
143    /// Plan Id of the subscribed plan in paid apps.
144    #[serde(rename = "planId", default, skip_serializing_if = "Option::is_none")]
145    pub plan_id: Option<String>,
146    /// Indicates whether the installation was performed as a bulk installation
147    #[serde(
148        rename = "isBulkInstallation",
149        default,
150        skip_serializing_if = "Option::is_none"
151    )]
152    pub is_bulk_installation: Option<bool>,
153    /// Boolean to control if user wants app to be automatically installed to future locations
154    /// (only for company tokens)
155    #[serde(
156        rename = "installToFutureLocations",
157        default,
158        skip_serializing_if = "Option::is_none"
159    )]
160    pub install_to_future_locations: Option<bool>,
161    /// Boolean indicating if user approved all locations during bulk installation (only for
162    /// company tokens)
163    #[serde(
164        rename = "approveAllLocations",
165        default,
166        skip_serializing_if = "Option::is_none"
167    )]
168    pub approve_all_locations: Option<bool>,
169}
170
171/// `GetInstalledLocationsSuccessfulResponseDto` from the GoHighLevel OpenAPI spec.
172#[derive(Debug, Clone, Default, Serialize, Deserialize)]
173pub struct GetInstalledLocationsSuccessfulResponseDto {
174    /// List of locations with their installation status for the requested app
175    #[serde(default, skip_serializing_if = "Vec::is_empty")]
176    pub locations: Vec<InstalledLocationSchema>,
177    /// Total location count under the company
178    #[serde(default, skip_serializing_if = "Option::is_none")]
179    pub count: Option<f64>,
180    /// Boolean to control if user wants app to be automatically installed to future locations
181    #[serde(
182        rename = "installToFutureLocations",
183        default,
184        skip_serializing_if = "Option::is_none"
185    )]
186    pub install_to_future_locations: Option<bool>,
187}
188
189/// `GetInstalledLocationsV3SuccessfulResponseDto` from the GoHighLevel OpenAPI spec.
190#[derive(Debug, Clone, Default, Serialize, Deserialize)]
191pub struct GetInstalledLocationsV3SuccessfulResponseDto {
192    /// List of locations with their installation status for the requested app
193    /// Required by the API.
194    /// (Optional here so responses that omit it still parse.)
195    #[serde(default, skip_serializing_if = "Vec::is_empty")]
196    pub items: Vec<InstalledLocationSchema>,
197    /// Pagination metadata (AIP-158)
198    /// Required by the API.
199    /// (Optional here so responses that omit it still parse.)
200    #[serde(default, skip_serializing_if = "Option::is_none")]
201    pub pagination: Option<V3PaginationMetaDto>,
202    /// Query metadata (filters and sort applied)
203    #[serde(default, skip_serializing_if = "Option::is_none")]
204    pub metadata: Option<V3InstalledLocationsListMetadataDto>,
205    /// Boolean to control if user wants app to be automatically installed to future locations
206    #[serde(
207        rename = "installToFutureLocations",
208        default,
209        skip_serializing_if = "Option::is_none"
210    )]
211    pub install_to_future_locations: Option<bool>,
212}
213
214/// `GetLocationAccessCodeBodyDto` from the GoHighLevel OpenAPI spec.
215#[derive(Debug, Clone, Default, Serialize, Deserialize)]
216pub struct GetLocationAccessCodeBodyDto {
217    /// Company Id of location you want to request token for
218    /// Required by the API.
219    #[serde(rename = "companyId")]
220    pub company_id: String,
221    /// The location ID for which you want to obtain accessToken
222    /// Required by the API.
223    #[serde(rename = "locationId")]
224    pub location_id: String,
225}
226
227/// `GetLocationAccessTokenSuccessfulResponseDto` from the GoHighLevel OpenAPI spec.
228#[derive(Debug, Clone, Default, Serialize, Deserialize)]
229pub struct GetLocationAccessTokenSuccessfulResponseDto {
230    /// Location access token which can be used to authenticate & authorize API under following
231    /// scope
232    #[serde(default, skip_serializing_if = "Option::is_none")]
233    pub access_token: Option<String>,
234    /// The token type (always Bearer)
235    #[serde(default, skip_serializing_if = "Option::is_none")]
236    pub token_type: Option<String>,
237    /// Time in seconds remaining for token to expire
238    #[serde(default, skip_serializing_if = "Option::is_none")]
239    pub expires_in: Option<f64>,
240    /// Scopes the following accessToken have access to
241    #[serde(default, skip_serializing_if = "Option::is_none")]
242    pub scope: Option<String>,
243    /// Location ID - Present only for Sub-Account Access Token
244    #[serde(
245        rename = "locationId",
246        default,
247        skip_serializing_if = "Option::is_none"
248    )]
249    pub location_id: Option<String>,
250    /// Plan Id of the subscribed plan in paid apps.
251    #[serde(rename = "planId", default, skip_serializing_if = "Option::is_none")]
252    pub plan_id: Option<String>,
253    /// USER ID - Represent user id of person who performed installation
254    /// Required by the API.
255    /// (Optional here so responses that omit it still parse.)
256    #[serde(rename = "userId", default, skip_serializing_if = "Option::is_none")]
257    pub user_id: Option<String>,
258    /// App ID of the installed application
259    #[serde(rename = "appId", default, skip_serializing_if = "Option::is_none")]
260    pub app_id: Option<String>,
261    /// Version ID of the installed app version
262    #[serde(rename = "versionId", default, skip_serializing_if = "Option::is_none")]
263    pub version_id: Option<String>,
264    /// The OAuth2 refresh token used to obtain a new access token for this specific location
265    #[serde(default, skip_serializing_if = "Option::is_none")]
266    pub refresh_token: Option<String>,
267}
268
269/// `GetLocationAccessTokenV3SuccessfulResponseDto` from the GoHighLevel OpenAPI spec.
270#[derive(Debug, Clone, Default, Serialize, Deserialize)]
271pub struct GetLocationAccessTokenV3SuccessfulResponseDto {
272    /// Location access token which can be used to authenticate & authorize API under following
273    /// scope
274    #[serde(
275        rename = "accessToken",
276        default,
277        skip_serializing_if = "Option::is_none"
278    )]
279    pub access_token: Option<String>,
280    /// The token type (always Bearer)
281    #[serde(rename = "tokenType", default, skip_serializing_if = "Option::is_none")]
282    pub token_type: Option<String>,
283    /// Time in seconds remaining for token to expire
284    #[serde(rename = "expiresIn", default, skip_serializing_if = "Option::is_none")]
285    pub expires_in: Option<f64>,
286    /// Scopes the following accessToken have access to
287    #[serde(default, skip_serializing_if = "Option::is_none")]
288    pub scope: Option<String>,
289    /// Location ID - Present only for Sub-Account Access Token
290    #[serde(
291        rename = "locationId",
292        default,
293        skip_serializing_if = "Option::is_none"
294    )]
295    pub location_id: Option<String>,
296    /// Plan Id of the subscribed plan in paid apps.
297    #[serde(rename = "planId", default, skip_serializing_if = "Option::is_none")]
298    pub plan_id: Option<String>,
299    /// USER ID - Represent user id of person who performed installation
300    /// Required by the API.
301    /// (Optional here so responses that omit it still parse.)
302    #[serde(rename = "userId", default, skip_serializing_if = "Option::is_none")]
303    pub user_id: Option<String>,
304    /// App ID of the installed application
305    #[serde(rename = "appId", default, skip_serializing_if = "Option::is_none")]
306    pub app_id: Option<String>,
307    /// Version ID of the installed app version
308    #[serde(rename = "versionId", default, skip_serializing_if = "Option::is_none")]
309    pub version_id: Option<String>,
310    /// The OAuth2 refresh token used to obtain a new access token for this specific location.
311    #[serde(
312        rename = "refreshToken",
313        default,
314        skip_serializing_if = "Option::is_none"
315    )]
316    pub refresh_token: Option<String>,
317}
318
319/// `InstalledLocationSchema` from the GoHighLevel OpenAPI spec.
320#[derive(Debug, Clone, Default, Serialize, Deserialize)]
321pub struct InstalledLocationSchema {
322    /// Location ID
323    /// Required by the API.
324    /// (Optional here so responses that omit it still parse.)
325    #[serde(rename = "_id", default, skip_serializing_if = "Option::is_none")]
326    pub id: Option<String>,
327    /// Name of the location
328    /// Required by the API.
329    /// (Optional here so responses that omit it still parse.)
330    #[serde(default, skip_serializing_if = "Option::is_none")]
331    pub name: Option<String>,
332    /// Address linked to location
333    /// Required by the API.
334    /// (Optional here so responses that omit it still parse.)
335    #[serde(default, skip_serializing_if = "Option::is_none")]
336    pub address: Option<String>,
337    /// Check if the requested app is installed for following location
338    #[serde(
339        rename = "isInstalled",
340        default,
341        skip_serializing_if = "Option::is_none"
342    )]
343    pub is_installed: Option<bool>,
344    /// Version ID of the installed app version for this location
345    #[serde(rename = "versionId", default, skip_serializing_if = "Option::is_none")]
346    pub version_id: Option<String>,
347    /// Timestamp when the app was installed on this location
348    /// Format: date-time (ISO-8601 string).
349    #[serde(
350        rename = "installedAt",
351        default,
352        skip_serializing_if = "Option::is_none"
353    )]
354    pub installed_at: Option<String>,
355}
356
357/// `V3InstalledLocationsListMetadataDto` from the GoHighLevel OpenAPI spec.
358#[derive(Debug, Clone, Default, Serialize, Deserialize)]
359pub struct V3InstalledLocationsListMetadataDto {
360    /// Filters that were applied to the query
361    #[serde(
362        rename = "filterApplied",
363        default,
364        skip_serializing_if = "Option::is_none"
365    )]
366    pub filter_applied: Option<serde_json::Value>,
367    /// Sort order that was applied to the query
368    #[serde(
369        rename = "sortApplied",
370        default,
371        skip_serializing_if = "Option::is_none"
372    )]
373    pub sort_applied: Option<serde_json::Value>,
374}
375
376/// `V3PaginationMetaDto` from the GoHighLevel OpenAPI spec.
377#[derive(Debug, Clone, Default, Serialize, Deserialize)]
378pub struct V3PaginationMetaDto {
379    /// Total number of records matching the query across all pages
380    #[serde(
381        rename = "totalRecords",
382        default,
383        skip_serializing_if = "Option::is_none"
384    )]
385    pub total_records: Option<f64>,
386    /// True when a next page is available
387    /// Required by the API.
388    /// (Optional here so responses that omit it still parse.)
389    #[serde(
390        rename = "hasNextPage",
391        default,
392        skip_serializing_if = "Option::is_none"
393    )]
394    pub has_next_page: Option<bool>,
395    /// True when a previous page is available
396    /// Required by the API.
397    /// (Optional here so responses that omit it still parse.)
398    #[serde(
399        rename = "hasPrevPage",
400        default,
401        skip_serializing_if = "Option::is_none"
402    )]
403    pub has_prev_page: Option<bool>,
404    /// Opaque token to fetch the next page
405    #[serde(
406        rename = "nextPageToken",
407        default,
408        skip_serializing_if = "Option::is_none"
409    )]
410    pub next_page_token: Option<String>,
411    /// Opaque token to fetch the previous page
412    #[serde(
413        rename = "prevPageToken",
414        default,
415        skip_serializing_if = "Option::is_none"
416    )]
417    pub prev_page_token: Option<String>,
418    /// Number of items returned in the current page
419    /// Required by the API.
420    /// (Optional here so responses that omit it still parse.)
421    #[serde(
422        rename = "currentPageSize",
423        default,
424        skip_serializing_if = "Option::is_none"
425    )]
426    pub current_page_size: Option<f64>,
427    /// Estimated total records; present when exact total is unknown
428    #[serde(
429        rename = "estimatedTotalRecords",
430        default,
431        skip_serializing_if = "Option::is_none"
432    )]
433    pub estimated_total_records: Option<f64>,
434}