This topic describes how to query the credential list by using the API. You can filter, sort, and paginate the results.
API call
If you set a password, you must authenticate. For more information, see API hybrid encryption.
Request path
GET /api/v1/security/credentials
Request parameters
Parameter |
Type |
Required |
Example value |
Description |
|---|---|---|---|---|
| credential_id | int | No | 1 | The ID of the credential. You can specify this parameter by using the query param. |
| target_type | string | No | HOST | The target type. Currently, only "HOST" is supported. You can specify this parameter by using the query param. |
| key_word | string | No | my | The keyword used to search for the name or username of the credential. You can specify this parameter by using the query param. |
| page | int | No | 1 | The page number. Default value: 1. You can specify this parameter by using the query param. |
| page_size | int | No | 10 | The number of entries per page. Default value: 10. You can specify this parameter by using the query param. |
| sort | string | No | create_time | The field to sort by. You can specify this parameter by using the query param. |
| sort_order | string | No | desc | The sort order (asc/desc). You can specify this parameter by using the query param. |
Response
Parameter |
Type |
Description |
|---|---|---|
| successful | bool | Indicates whether the request was successful. |
| timestamp | time.Time | The timestamp when the server completed the request. |
| duration | int | The time taken by the server to process the request, in milliseconds. |
| status | int | The HTTP status code. |
| traceId | string | The trace ID of the request. |
| data | PaginatedCredentialResponse | The paginated credential list, which contains the following information:
|
| error | ApiError | The error returned when the request fails. This parameter contains the following information:
|
Data structure of a credential:
Parameter |
Type |
Description |
|---|---|---|
| credential_id | int64 | The ID of the credential. |
| name | string | The name of the credential. |
| target_type | string | The target type. |
| description | string | The description of the credential. |
| ssh_secret | SshSecret | The SSH key information (excluding the password). For more information, see Data structure of SshSecret below. |
| create_time | time.Time | The time when the credential was created. |
| update_time | time.Time | The time when the credential was last updated. |
Data structure of SshSecret:
Parameter |
Type |
Description |
|---|---|---|
| targets | []Target | The list of target hosts. |
| username | string | The username. |
| type | string | The authentication type. |
Data structure of CustomPage:
Parameter |
Type |
Description |
|---|---|---|
| total_elements | uint64 | The total number of records. |
| total_pages | uint64 | The total number of pages. |
| size | uint64 | The number of entries per page. |
| number | uint64 | The current page number. |
Examples
Request example
GET 10.10.10.1:2886/api/v1/security/credentials?page=1&page_size=10&key_word=my
Response example
{
"successful": true,
"timestamp": "2025-10-14T15:18:01.277047628+08:00",
"duration": 20,
"status": 200,
"traceId": "e6f64ba7f54e7a52",
"data": {
"contents": [
{
"credential_id": 1,
"name": "my-credential",
"target_type": "HOST",
"description": "SSH credential for hosts",
"ssh_secret": {
"targets": [
{
"ip": "10.10.10.1",
"port": 22
}
],
"username": "root",
"type": "PASSWORD"
},
"create_time": "2025-10-14T15:14:01.277047628+08:00",
"update_time": "2025-10-14T15:14:01.277047628+08:00"
}
],
"page": {
"total_elements": 1,
"total_pages": 1,
"size": 10,
"number": 1
}
}
}
