> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.termina.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.termina.ai/_mcp/server.

### cURL

```bash
curl --location 'https://termina.ai/api/v1/user/me' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <jwt_token_value>'
```

### Refreshing JWT Token (Python Example)

JWT tokens issued by the Termina API expire after one hour for security reasons.
Depending on your use case, implementing an auto-refresh mechanism can ensure uninterrupted access to your data. Here's a suggested implementation:

```python
import time
import jwt
import requests

class RefreshingToken:
    def __init__(self, api_key, refresh_buffer=60):
        self.api_key = api_key
        self._refresh_buffer = refresh_buffer
        self._token = None
        self._base_api = "https://app.termina.ai/api/v1"

    def token(self):
        if self.api_key is not None and (
            self._token is None
            or (
                jwt.decode(self._token, options={"verify_signature": False})["exp"] - self._refresh_buffer < time.time()
            )
        ):
            self._refresh()
        return self._token

    def _refresh(self):
        response = requests.post(f"{self._base_api}/auth/get-token", json={"api_key": self.api_key})
        self._token = response.json()["access_token"]

    def bearer_headers(self) -> dict:
        return {"Authorization": f"Bearer {self.token()}"}

api_key = "..."
refreshing_token = RefreshingToken(api_key=api_key)

response = requests.get(
    "https://app.termina.ai/api/v1/user/me", 
    headers=refreshing_token.bearer_headers(),
)
print(response.json())
```

### Uploading Files with Signed URLs (Python Example)

> **Info**
>
> Our default upload and download endpoints supports files up to 10GB. Anything larger will require the use of the signed-urls.

```python
import requests

base_url: str = "https://app.termina.ai/api/v1"
group_id: int = ...
deal_id: int = ...
token: str = "..."

# Create test file
file_content = "This is a test file"
file_name = "test_file.txt"

with open(file_name, "w") as f:
    f.write(file_content)

headers = {"Authorization": f"Bearer {token}"}

# Create File Entry
file_resp = requests.post(
    f"{base_url}/group/{group_id}/deal/{deal_id}/file",
    headers=headers,
    json={
        "name": file_name,
        "type": "financials",
    },
)
file = file_resp.json()

# Retrieve upload url from response
signed_url = file["signed_url"]["url"]

# Upload File Contents
with open(file_name, "rb") as f:
    requests.put(signed_url, data=f)
```

### Downloading Files with Signed URLs (Python Example)

```python
import requests

download_url_resp = requests.get(
    f"{base_url}/group/{group_id}/deal/{deal_id}/file/{file_id}/signed-url",
    headers=headers,
)

download_url = download_url_resp.json()["url"]

# Download File
with open("downloaded_file.txt", "wb") as f:
    f.write(requests.get(download_url).content)
```