# Retrieve key context

URL: https://api-docs.vestta.io/me

Return the workspace and scopes of the API key used for the request.

Use this endpoint to check a key: at deploy time, in a health check, or when a user pastes a key into your product. It works with any active key, needs no scope and does not read or change workspace data.

Compare `user.scopes` with the scopes your integration needs, and fail early with a clear message if one is missing — instead of waiting for the first `401 Lack of permissions`.

### GET /v1/me

Returns the authenticated business and granted scopes. Any active key can call this operation.

Required scope: none (any active key)

Response 200: Successful response.
- `status` (string, required, values: `ok`)
- `user` (ApiKeyContext, required)
  - `company_name` (string, optional, nullable): Name of the business that owns the API key.
  - `scopes` (array of strings, required): Granted scopes: properties:read, properties:write, properties:publish, leads:read, leads:write, leads:ingest.
  - `auth_method` (string, required, values: `api_key`)

```json
{
  "status": "ok",
  "user": {
    "company_name": "Inmobiliaria Ejemplo",
    "scopes": [
      "properties:read",
      "leads:read"
    ],
    "auth_method": "api_key"
  }
}
```

Response 401: The API key is missing, malformed, unknown, revoked or expired.

Response 403: The API key lacks the required scope, or the business plan does not include API access.

Response 404: The resource does not exist in this business.

Response 409: Duplicate contact or idempotency key reused with a different payload.

Response 422: A path parameter, query parameter or body field is invalid.

Response 429: The API key reached its request limit. Wait for the number of seconds in `Retry-After` before retrying.

Response 500: Unexpected server error while processing the request.

### Example requests

#### cURL

```bash
curl "https://api.vestta.io/v1/me" \
  -H "X-Api-Key: $VESTTA_API_KEY"
```

#### JavaScript

```javascript
const response = await fetch('https://api.vestta.io/v1/me', {
  headers: { 'X-Api-Key': process.env.VESTTA_API_KEY },
})

const data = await response.json()
```

#### Python

```python
import os

import requests

response = requests.get(
    "https://api.vestta.io/v1/me",
    headers={"X-Api-Key": os.environ["VESTTA_API_KEY"]},
)
response.raise_for_status()
data = response.json()
```
