Limits and quotas protect the Google infrastructure from an automated process that uses the Directory API in an inappropriate way. Excessive requests from an API might result from a harmless typo, or may result from an inefficiently designed system that makes needless API calls. Regardless of the cause, blocking traffic from a specific source once it reaches a certain level is necessary for the overall health of the Google Workspace system. It ensures that one developer's actions cannot negatively impact the larger community.
In the unlikely event that your API request fails, the API returns an HTTP status code and reason for the error. Additionally, the body of the response contains a detailed description of what caused the error.
The following list shows the possible error codes, reasons, corresponding descriptions, and recommended action for errors caused by hitting quota limits.
Code | Reason | Description | Recommended Action |
---|---|---|---|
403
|
userRateLimitExceeded | Indicates that the user rate limit has been exceeded. The default value set in the Google Cloud console is 2,400 queries per minute per user per Google Cloud project. | Increase the per user limits from the Admin SDK API Quotas page of your Google Cloud project, or slow down the rate at which you are sending the requests using exponential backoff . |
403
|
quotaExceeded | Indicates that the limit of concurrent requests for a certain operation has been reached. | Retry using exponential back-off . You need to slow down the rate at which you are sending the requests. |
429
|
rateLimitExceeded | Indicates that the limit of concurrent requests for a certain operation has been reached. | Retry using exponential back-off . You must slow down the rate at which you are sending the requests. This limit is per Google Workspace account, not per API client or per user. This limit can't be increased. |
Implementing Exponential Backoff
Exponential backoff is the process of a client periodically retrying a failed request over an increasing amount of time. It is a standard error handling strategy for network applications. Using exponential backoff increases the efficiency of bandwidth usage, reduces the number of requests required to get a successful response, and maximizes the throughput of requests in concurrent environments.
The flow for implementing simple exponential backoff is as follows.
- Make a request to the API
- Receive an error response that has a retry-able error code
- Wait 1s +
random_number_milliseconds
seconds - Retry request
- Receive an error response that has a retry-able error code
- Wait 2s +
random_number_milliseconds
seconds - Retry request
- Receive an error response that has a retry-able error code
- Wait 4s +
random_number_milliseconds
seconds - Retry request
- Receive an error response that has a retry-able error code
- Wait 8s +
random_number_milliseconds
seconds - Retry request
- Receive an error response that has a retry-able error code
- Wait 16s +
random_number_milliseconds
seconds - Retry request
- If you still get an error, stop and log the error.
In the above flow, random_number_milliseconds
is a random
number of milliseconds less than or equal to 1000. This is necessary
to avoid certain lock errors in some concurrent implementations. random_number_milliseconds
must be redefined after each wait.
Note: the wait is always
(2 ^ n) + random_number_milliseconds
, where
n is a monotonically increasing integer initially defined
as 0. n is incremented by 1 for each iteration (each request).
The algorithm is set to terminate when n is 5. This ceiling is in place only to stop clients from retrying infinitely, and results in a total delay of around 32 seconds before a request is deemed "an unrecoverable error". Your API client can implement a higher number of attempts if needed.
API Limits and Quotas
Using the Directory API, you can perform up to:
- 20 action requests per second.
- 20 delete requests per second.
- 10 get requests per second.
- 10 list requests per second.
- You cannot create/update more than 1 organizational unit per customer per second using the Directory API.
- The customer's organizational unit hierarchy is limited to 35 levels of depth.
- The total number of organizational units per customer must not exceed 40,000.
annotatedLocation
, max charactersnotes
, max charactersuser
maximum characters- Chrome and mobile devices – A default and a maximum of 100 entries per page.
- Groups and group members – A default and maximum of 200 entries per page.
- Users – A default of 100 entries and a maximum of 500 entries per page.
- Primary domain -- Your account's primary domain is the domain of the administrator who accepted the Google Workspace Terms of Service agreement. This domain is at the account-level in the top-level organizational unit. When signing up for a Google Workspace account, we recommend using your business domain for the primary domain, and reserve your other domains for specialized uses such as pilots and testing.
- All super administrators can manage the full account.
- The API cannot change or move the Google Workspace account's primary domain. However, the API can rename a user's account, changing its email address from one domain to another.
- For Google Workspace accounts, you have 21 days to verify your ownership of the primary domain. For additional domains, you must verify your domain ownership before using the domain for a user's primary email address. In these cases, the 21 day grace period does not apply.
- In this version of the API, the primary domain's settings apply to all domains associated with the account except for the user access to the Google Workspace services .
- Additional account domains -- After establishing your primary domain and setting up your account, your can add your additional domains to the account. For additional domains, verify your ownership when setting up this domain and before using the domain for a user's primary email address.
- User's home domain -- The domain used in a user's primary email address is the user's home domain. This domain can be any domain in the account, including the primary domain.