# Get credential identity

`GET /v4/me`

Returns the connected workspace, user and effective scopes. No scope is required.

Authentication (security requirement alternatives):

```json
[
  {
    "bearer_auth": []
  },
  {
    "oauth2_auth": []
  },
  {
    "apikey_auth": []
  }
]
```

- bearer_auth: http (bearer). API key or OAuth access token in Authorization header
- oauth2_auth: oauth2. OAuth authorization code flow with mandatory S256 PKCE.
- apikey_auth: apiKey, query api_key. API key in query string

Responses:

- 200: Credential identity

Content type: application/json

Type: object

Schema: [Me](https://docs.searchsoftware.nl/api/models/me.md)

- `status` (optional)
  Type: string

- `data` (optional)
  Type: object
  
  - `auth_type` (optional)
    Type: string
  
  - `workspace` (optional)
    Type: string
  
  - `user` (optional)
    Type: unknown; nullable
    
    allOf:
      Reference: [MeUser](https://docs.searchsoftware.nl/api/models/meuser.md); Type: object
  
  - `scopes` (optional)
    Type: array
    
    Items:
      Type: string

- 401: Invalid credential

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "INVALID_API_KEY",
    "status_code": 401,
    "message": "Invalid API key"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "INVALID_API_KEY",
    "status_code": 401,
    "message": "Invalid API key"
  }
}
```

## Examples

### cURL

```bash
curl -X GET 'https://api.searchsoftware.nl/v4/me' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### TypeScript

```typescript
const response = await fetch('https://api.searchsoftware.nl/v4/me', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://api.searchsoftware.nl/v4/me',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```

### Ruby

```ruby
require 'net/http'
require 'json'

uri = URI('https://api.searchsoftware.nl/v4/me')
request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer YOUR_TOKEN'

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') { |http| http.request(request) }
data = JSON.parse(response.body)
```

### Go

```go
package main

import (
  "fmt"
  "io"
  "net/http"
)

func main() {
  req, _ := http.NewRequest("GET", "https://api.searchsoftware.nl/v4/me", nil)
  req.Header.Set("Authorization", "Bearer YOUR_TOKEN")
  resp, _ := http.DefaultClient.Do(req)
  defer resp.Body.Close()
  data, _ := io.ReadAll(resp.Body)
  fmt.Println(string(data))
}
```

### PHP

```php
<?php
$ch = curl_init('https://api.searchsoftware.nl/v4/me');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer YOUR_TOKEN']);

$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
```

### Rust

```rust
use reqwest;

#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
    let client = reqwest::Client::new();
    let response = client.get("https://api.searchsoftware.nl/v4/me")
        .header("Authorization", "Bearer YOUR_TOKEN")
        .send()
        .await?
        .text()
        .await?;
    println!("{}", response);
    Ok(())
}
```
