Users
Table of Content:
Create user
This API endpoint creates a new user account and sends a verification code.
Endpoint: https://apis.threatwinds.com/api/auth/v2/user
Parameters
| Parameter | Location | Type | Required | Description | Example |
|---|---|---|---|---|---|
| body | string | Yes | The email address for the new user account. This email will be used for authentication and communication. | “john@doe.net” | |
| fullName | body | string | Yes | The full name of the user. | “John Doe” |
| alias | body | string | Yes | A username or alias for the user. | “johny” |
To create a user, use a POST request, for example:
curl -X 'POST' \
'https://apis.threatwinds.com/api/auth/v2/user' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"email": "john@doe.net",
"fullName": "John Doe",
"alias": "johny"
}'
Returns
A successful response will return a JSON object containing session information and a verification code ID, similar to creating a session:
{
"bearer": "fq6JoEFTsxiXAl1cVdPDnK4emIQCwaUBfq6JoEFTsxiXAl1cVxPDnK4emIQCwaUB",
"sessionID": "5f35d2c4-5633-4b16-bbf0-5ca22ef8ea2e",
"expireAt": 1674492894,
"ip": "1.1.1.1",
"userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
"verificationCodeID": "5f35d2c4-5633-4b16-bbf0-5ca22ef8ea2e"
}
Note: After creating a user, you need to verify the session using the verification code sent to the provided email address. See the Verify session section in the Sessions documentation.
Get user by ID
This API endpoint retrieves information about a user by their ID.
Endpoint: https://apis.threatwinds.com/api/auth/v2/user/{id}
Parameters
| Parameter | Location | Type | Required | Description | Example |
|---|---|---|---|---|---|
| id | path | string | Yes | The unique identifier of the user. | 5f35d2c4-5633-4b16-bbf0-5ca22ef8ea2e |
To get a user by ID, use a GET request, for example:
curl -X 'GET' \
'https://apis.threatwinds.com/api/auth/v2/user/5f35d2c4-5633-4b16-bbf0-5ca22ef8ea2e' \
-H 'accept: application/json'
Returns
A successful response will return a JSON object containing basic information about the user:
{
"alias": "johny"
}
Delete User
This API endpoint deletes the authenticated user’s own account.
Endpoint: https://apis.threatwinds.com/api/auth/v2/user
Parameters
Headers
| Header | Type | Required | Description |
|---|---|---|---|
| Authorization | string | Optional* | Bearer token for session authentication |
| api-key | string | Optional* | API key for key-based authentication |
| api-secret | string | Optional* | API secret for key-based authentication |
Note: You must use either Authorization header OR API key/secret combination.
To delete your own user account, use a DELETE request, for example:
curl -X 'DELETE' \
'https://apis.threatwinds.com/api/auth/v2/user' \
-H 'accept: application/json' \
-H 'Authorization: Bearer <token>'
Or using API key and secret:
curl -X 'DELETE' \
'https://apis.threatwinds.com/api/auth/v2/user' \
-H 'accept: application/json' \
-H 'api-key: your-api-key' \
-H 'api-secret: your-api-secret'
Returns
A successful response will return a 202 Accepted status with a confirmation message:
{
"message": "acknowledged"
}
Error Codes
| Status Code | Description | Possible Cause |
|---|---|---|
| 400 | Bad Request | Invalid request |
| 401 | Unauthorized | Missing or invalid authentication credentials |
| 403 | Forbidden | Insufficient permissions for this operation |
Error Response Headers
For responses with status codes other than 200 and 202, the following headers are included:
| Header | Description |
|---|---|
| x-error | Contains a description of the error that occurred |
| x-error-id | Contains a unique identifier for the error for support |
Error Codes
| Status Code | Description | Possible Cause |
|---|---|---|
| 400 | Bad Request | Invalid request parameters or malformed JSON |
| 401 | Unauthorized | Missing or invalid authentication credentials |
| 403 | Forbidden | Authenticated user lacks permission for this operation |
| 404 | Not Found | The requested resource does not exist |
| 500 | Internal Server Error | Server-side error; please contact support if persistent |