# Method: projects.accounts.query

- [HTTP request](https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/projects.accounts/query#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/projects.accounts/query#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/projects.accounts/query#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/projects.accounts/query#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/projects.accounts/query#body.response_body)
- [Authorization scopes](https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/projects.accounts/query#body.aspect)
- [Try it!](https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/projects.accounts/query#try-it)

Looks up user accounts within a project or a tenant based on conditions in the request.

### HTTP request

`POST https://identitytoolkit.googleapis.com/v1/projects/{targetProjectId}/accounts:query`

The URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Path parameters

| Parameters ||
|---|---|
| `targetProjectId` | `string` The ID of the project to which the result is scoped. Authorization requires the following [IAM](https://cloud.google.com/iam/docs/) permission on the specified resource `targetProjectId`: - `firebaseauth.users.get` |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "returnUserInfo": boolean, "limit": string, "offset": string, "sortBy": enum (`https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/SortByField`), "order": enum (`https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/Order`), "tenantId": string, "expression": [ { object (`https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/SqlExpression`) } ] } ``` |

| Fields ||
|---|---|
| `returnUserInfo` | `boolean` If `true`, this request will return the accounts matching the query. If `false`, only the **count** of accounts matching the query will be returned. Defaults to `true`. |
| `limit` | `string (https://developers.google.com/discovery/v1/type-format format)` The maximum number of accounts to return with an upper limit of **500** . Defaults to *500* . Only valid when `returnUserInfo` is set to `true`. |
| `offset` | `string (https://developers.google.com/discovery/v1/type-format format)` The number of accounts to skip from the beginning of matching records. Only valid when `returnUserInfo` is set to `true`. |
| `sortBy` | ``enum (`https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/SortByField`)`` |
| `order` | ``enum (`https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/Order`)`` |
| `tenantId` | `string` The ID of the tenant to which the result is scoped. |
| `expression[]` | ``object (`https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/SqlExpression`)`` |

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/QueryUserInfoResponse`.

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/identitytoolkit`
- `
  https://www.googleapis.com/auth/firebase`
- `
  https://www.googleapis.com/auth/cloud-platform`

For more information, see the [Authentication Overview](https://docs.cloud.google.com/docs/authentication#authorization-gcp).