# 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="181"></th><th></th><th></th></tr></thead><tbody><tr><td>Parameters</td><td>Description</td><td>Required or Optional</td></tr><tr><td>username</td><td>Username of the user to be logged in</td><td>Required</td></tr><tr><td>company_name</td><td>Name of the company for which the user is logging in</td><td>Required</td></tr></tbody></table>

### Shell

* Request Body

```sh
curl --location POST "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

# API URL
url = "URL/access/klearstack/getuserid"

# Request payload
data= {
    "username": "Replace_User_Name_Here",
    "company_name": "Replace_Company_Name_Here"
}

# Headers
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer your_token_here"
}

# Make the POST request
response = requests.post(url, data=data, headers=headers)

# Print the response
if response.status_code == 200:
    print(response.json())
else:
    print("Error:", response.text)
```

### Java

* Request Body

```java
import okhttp3.*;

import java.io.IOException;

public class GetUserIDAPI {
    public static void main(String[] args) {
        OkHttpClient client = new OkHttpClient();

        // JSON payload
        String jsonPayload = "{ \"username\": \"Replace_User_Name_Here\", \"company_name\": \"Replace_Company_Name_Here\" }";

        RequestBody body = RequestBody.create(
            jsonPayload, MediaType.parse("application/json"));

        Request request = new Request.Builder()
            .url("URL/access/klearstack/getuserid")
            .post(body)
            .addHeader("Content-Type", "application/json")
            .addHeader("Authorization", "Bearer your_token_here")
            .build();

        try (Response response = client.newCall(request).execute()) {
            if (response.isSuccessful()) {
                System.out.println("Response: " + response.body().string());
            } else {
                System.out.println("Error: " + response.body().string());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
```

### Node.js

* Request Body

```javascript
const axios = require('axios');

const url = "URL/access/klearstack/getuserid";

const payload = {
    username: "Replace_User_Name_Here",
    company_name: "Replace_Company_Name_Here"
};

axios.post(url, payload, {
    headers: {
        "Content-Type": "application/json",
        "Authorization": "Bearer your_token_here"
    }
})
.then(response => console.log(response.data))
.catch(error => console.error("Error:", error.response ? error.response.data : error.message));
```

### JavaScript (XMLHttpRequest)

* Request Body

```javascript
var payload = JSON.stringify({
    username: "Replace_User_Name_Here",
    company_name: "Replace_Company_Name_Here"
});

var xhr = new XMLHttpRequest();
xhr.open("POST", "URL/access/klearstack/getuserid", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer your_token_here");

// Handle response
xhr.onreadystatechange = function () {
    if (xhr.readyState === XMLHttpRequest.DONE) {
        if (xhr.status === 200) {
            console.log("Response:", xhr.responseText);
        } else {
            console.error("Error:", xhr.responseText);
        }
    }
};

// Send request
xhr.send(payload);
```

### 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>
