This topic describes how to obtain credentials based on the credential ID by using an API.
Callout
If a password is set, you must pass authentication. For more information, see API hybrid encryption.
Request path
GET /api/v1/security/credential/:id
Request parameters
Parameter |
Type |
Required |
Example value |
Description |
|---|---|---|---|---|
| id | int | Yes | 1 | The ID of the credential. This parameter is specified in the path. |
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 | Credential | The information about the credential. For more information, see the data structure of Credential section below. |
| error | ApiError | The error information. The error information contains the following parameters:
|
Data structure of 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 without the password. For more information, see the data structure of SshSecret section 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. |
Examples
Request example
GET 10.10.10.1:2886/api/v1/security/credential/1
Response example
{
"successful": true,
"timestamp": "2025-10-14T15:14:01.277047628+08:00",
"duration": 12,
"status": 200,
"traceId": "e6f64ba7f54e7a48",
"data": {
"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"
}
}
