> For the complete documentation index, see [llms.txt](https://fusionauth.io/docs/llms.txt)

# Search for User Comments

API documentation for the FusionAuth Search for User Comments API.

# Search for User Comments

version

This API has been available since 1.45.0

This API is used to search for User Comments and may be called using the `GET` or `POST` HTTP methods. Examples of each are provided below. The `POST` method is provided to allow for a richer request object without worrying about exceeding the maximum length of a URL. Calling this API with either the `GET` or `POST` HTTP method will provide the same search results given the same query parameters.

## Request

[!API Key Authentication](https://fusionauth.io/docs/apis/authentication.md#api-key-authentication)

Search for User Comments

GET/api/user/comment/search?comment={comment}

#### Request Headers

`X-FusionAuth-TenantId`Stringoptional

The unique Id of the tenant used to scope this API request.

The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.

Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.

See [Making an API request using a Tenant Id](https://fusionauth.io/docs/apis/authentication.md#making-an-api-request-using-a-tenant-id) for additional information.

### Request Parameters

`comment`Stringoptional

The case-insensitive string to search for in the User Comment text. This can contain wildcards using the asterisk character (`*`). If no wildcards are present, the search criteria will be interpreted as `*value*`.

`commenterId`UUIDoptional

Restricts the results to User Comments created by the given User.

`numberOfResults`IntegeroptionalDefaults to 25

The number of results to return from the search.

`orderBy`StringoptionalDefaults to name ASC

The field to order the search results as well as an order direction.

The possible values are:

*   `comment` - the User Comment text
*   `commenterId` - the unique Id of the User who created the User Comment
*   `id` - the unique Id of the User Comment
*   `insertInstant` - the [instant](https://fusionauth.io/docs/reference/data-types.md#instants) when the User Comment was created
*   `tenantId` -the unique Id of the Tenant to which the User Comment belongs
*   `userId` - the unique Id of the User to which the User Comment belongs

The order direction is optional. Possible values of the order direction are `ASC` or `DESC`. If omitted, the default sort order is `ASC`.

For example, to order the results by the insert instant in a descending order, use `insertInstant DESC`.

`startRow`IntegeroptionalDefaults to 0

The offset into the total results. In order to paginate the results, increment this value by the **numberOfResults** for subsequent requests.

For example, if the total search results are greater than the page size designated by **numberOfResults**, set this value to `25` to retrieve results `26-50`, assuming the default page size.

`tenantId`UUIDoptional

Restricts the results to User Comments belonging to the given Tenant. This parameter will be overridden if the request contains an `X-FusionAuth-TenantId` header, or if the supplied API key is scoped to a specific Tenant.

`userId`UUIDoptional

Restricts the results to User Comments belonging to the given User.

[!API Key Authentication](https://fusionauth.io/docs/apis/authentication.md#api-key-authentication)

Search for User Comments

POST/api/user/comment/search

OpenAPI Spec

#### Request Headers

`X-FusionAuth-TenantId`Stringoptional

The unique Id of the tenant used to scope this API request.

The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.

Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.

See [Making an API request using a Tenant Id](https://fusionauth.io/docs/apis/authentication.md#making-an-api-request-using-a-tenant-id) for additional information.

When calling the API using a `POST` request you will send the search criteria in a JSON request body.

### Request Body

`search.comment`Stringoptional

The case-insensitive string to search for in the User Comment text. This can contain wildcards using the asterisk character (`*`). If no wildcards are present, the search criteria will be interpreted as `*value*`.

`search.commenterId`UUIDoptional

Restricts the results to User Comments created by the given User.

`search.numberOfResults`IntegeroptionalDefaults to 25

The number of results to return from the search.

`search.orderBy`StringoptionalDefaults to name ASC

The field to order the search results as well as an order direction.

The possible values are:

*   `comment` - the User Comment text
*   `commenterId` - the unique Id of the User who created the User Comment
*   `id` - the unique Id of the User Comment
*   `insertInstant` - the [instant](https://fusionauth.io/docs/reference/data-types.md#instants) when the User Comment was created
*   `tenantId` -the unique Id of the Tenant to which the User Comment belongs
*   `userId` - the unique Id of the User to which the User Comment belongs

The order direction is optional. Possible values of the order direction are `ASC` or `DESC`. If omitted, the default sort order is `ASC`.

For example, to order the results by the insert instant in a descending order, use `insertInstant DESC`.

`search.startRow`IntegeroptionalDefaults to 0

The offset into the total results. In order to paginate the results, increment this value by the **numberOfResults** for subsequent requests.

For example, if the total search results are greater than the page size designated by **numberOfResults**, set this value to `25` to retrieve results `26-50`, assuming the default page size.

`search.tenantId`UUIDoptional

Restricts the results to User Comments belonging to the given Tenant. This parameter will be overridden if the request contains an `X-FusionAuth-TenantId` header, or if the supplied API key is scoped to a specific Tenant.

`search.userId`UUIDoptional

Restricts the results to User Comments belonging to the given User.

*Example Request JSON*

```json
{
  "search": {
    "comment": "violating",
    "commenterId": "00000000-0000-0000-0000-000000000002",
    "numberOfResults": 25,
    "orderBy": "insertInstant",
    "startRow": 0,
    "tenantId": "00000000-0000-0005-0000-000000000001",
    "userId": "00000000-0000-0000-0000-000000000003"
  }
}
```

## Response

The response for this API contains the User Comments matching the search criteria in paginated format and the total number of results matching the search criteria.

*Response Codes*

| Code | Description |
| --- | --- |
| 200 | The request was successful. The response will contain a JSON body. |
| 400 | The request was invalid and/or malformed. The response will contain an [Errors](https://fusionauth.io/docs/apis/errors.md) JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
| 401 | You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See [Authentication](https://fusionauth.io/docs/apis/authentication.md). |
| 500 | There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |

### Response Body

`total`Integer

The total number of User Comments matching the search criteria. Use this value along with the **numberOfResults** and **startRow** in the search request to perform pagination.

`userComments`Array

The list of User Comment objects.

`userComments[x].comment`String

The text of the User Comment.

`userComments[x].commenterId`UUID

The Id of the User that wrote the User Comment.

`userComments[x].id`UUID

The Id of the User Comment.

`userComments[x].insertInstant`Long

The [instant](https://fusionauth.io/docs/reference/data-types.md#instants) when the comment was written.

`userComments[x].userId`UUID

The Id of the User that the User Comment was written for.

*Example Response JSON*

```json
{
  "userComments": [
    {
      "comment": "Not sure if this user is violating any rules or not.",
      "commenterId": "00000000-0000-0000-0000-000000000002",
      "id": "00000000-0000-0000-0000-000000000042",
      "insertInstant": 1471786483322,
      "userId": "00000000-0000-0000-0000-000000000003"
    }
  ],
  "total": 1
}
```