# Get User ID

Endpoint Name: `getuserid`

Request type : `POST`

Authorization: Bearer token as header

Endpoint Details: The getuserid endpoint will be used to user id of a particular user.

<table data-header-hidden><thead><tr><th width="115"></th><th></th></tr></thead><tbody><tr><td>Method</td><td>URL</td></tr><tr><td>POST</td><td><code>URL/access/klearstack/getuserid</code></td></tr></tbody></table>

### Request Body

<table data-header-hidden><thead><tr><th width="165.727294921875"></th><th width="102.72723388671875"></th><th width="99.63623046875"></th><th></th></tr></thead><tbody><tr><td>Parameters</td><td>Values</td><td>Required </td><td>Description</td></tr><tr><td>username</td><td>string</td><td>Yes</td><td>Username of the user to be logged in.</td></tr><tr><td>company_name</td><td>string</td><td>Yes</td><td>Name of the company for which the user is logging in.</td></tr></tbody></table>

### Shell

* Request Body

```sh
curl --location "URL/access/klearstack/getuserid" \
  --header "Authorization: Bearer your_token_here" \
  --form "username=Replace_User_Name_Here" \
  --form "company_name=Replace_Company_Name_Here"
```

### Python

* Request Body

```python
import requests

url = "URL/access/klearstack/getuserid"

payload = {'username': 'Replace_User_Name_Here',
'company_name': 'Replace_Company_Name_Here'}
files=[

]
headers = {
  'Authorization': 'Bearer your_token_here'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)
```

### Java(OkHttp)

* Request Body

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();

// Set media type for form data
MediaType mediaType = MediaType.parse("text/plain");

// Build multipart form body with example form fields
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
  .addFormDataPart("username", "Replace_User_Name_Here")  // replace with actual username
  .addFormDataPart("company_name", "Replace_Company_Name_Here")  // replace with actual company name
  .build();

Request request = new Request.Builder()
  .url("URL/access/klearstack/getuserid")  // replace with your API URL
  .method("POST", body)
  .addHeader("Authorization", "Bearer YOUR_ACCESS_TOKEN")  // replace with your Bearer token
  .build();

Response response = client.newCall(request).execute();

```

### Node.js (Axios)

* Request Body

```javascript
const axios = require('axios');
const FormData = require('form-data');

// Create form data object
let data = new FormData();
data.append('username', 'Replace_User_Name_Here');  // replace with actual username
data.append('company_name', 'Replace_Company_Name_Here');  // replace with actual company name

// Configure request
let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'URL/access/klearstack/getuserid',  // replace with your API URL
  headers: { 
    'Authorization': 'Bearer YOUR_ACCESS_TOKEN',  // replace with your Bearer token
    ...data.getHeaders()
  },
  data: data
};

// Make the request
axios.request(config)
  .then((response) => {
    console.log('Success:', JSON.stringify(response.data));
  })
  .catch((error) => {
    console.log('Error:', error.message);
  });

```

### JavaScript (XHR)

* Request Body

```javascript
// WARNING: For POST requests, body is set to null by browsers.
var data = new FormData();
data.append("username", "Replace_User_Name_Here");
data.append("company_name", "Replace_Company_Name_Here");

var xhr = new XMLHttpRequest();

xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }

});

xhr.open("POST", "URL/access/klearstack/getuserid");

xhr.setRequestHeader("Authorization", "Bearer your_token_here");

xhr.send(data);

```

### API Response

<table data-header-hidden><thead><tr><th width="141"></th><th></th></tr></thead><tbody><tr><td>Status code</td><td>Example Response</td></tr><tr><td>200</td><td><p><code>{</code></p><p>    <code>"_id": "5ce90642bf184f25555b1244",</code><br>    <code>"release_version": “7.8.9”</code></p><p><code>}</code></p></td></tr><tr><td>500</td><td>One or Many Required parameters from company name must be missing, E.g error “Company Name”,</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://klearstack.gitbook.io/klearstack-api-documentation/authentication-and-user-details/get-user-id.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
