Gets the Current User's Profile - Cognigy Documentation
Gets the Current User's Profile
GET/v2.0/users/me
Try it
cURL
curl --request GET \
--url https://api-trial.cognigy.ai/new/v2.0/users/me \
--header 'X-API-Key: <api-key>'
Python
import requests
url = "https://api-trial.cognigy.ai/new/v2.0/users/me"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)
JavaScript
const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api-trial.cognigy.ai/new/v2.0/users/me', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
PHP
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-trial.cognigy.ai/new/v2.0/users/me",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-trial.cognigy.ai/new/v2.0/users/me"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
Response Codes
- 200 OK
Returns the own User object. - 400 Bad Request
Validation failed. Missing payload. - 401 Unauthorized
Missing or invalid API key. - 403 Forbidden
User does not have access. - 404 Not Found
Requested resource not found. - 500 Internal Server Error
An unexpected error occurred.
Example Response
{
"id": "<string>",
"name": "<string>",
"organisation": "<string>",
"roles": [],
"projects": [
"<string>"
],
"acceptedTOS": true,
"disabled": true,
"_id": "<string>",
"createdAt": 1694518620,
"lastChanged": 1694518620,
"createdBy": "<string>",
"lastChangedBy": "<string>"
}
Authorizations
- Required Header
X-API-Key: string
Headers
Accept: enum<string>
The Accept header specifies the media type that the client expects in the response. Available options: application/json, application/hal+json, application/xml, text/xml, text/csv. The default value is application/json.