> ## Documentation Index
> Fetch the complete documentation index at: https://docs.simplifi.work/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication Examples

<Danger>
  The Simplifi API is in **Developer Preview**. While not all features are finalised, we encourage you to explore and share your feedback — including thoughts on endpoint design, response structure, or areas where documentation could be clearer.
</Danger>

## Code Example

You can see an example of a token manager in Python below:

```python theme={null}
import time
import requests

CLIENT_ID = "your_client_id"
CLIENT_SECRET = "your_client_secret"
AUTH_URL = "https://dev.simplifi.work/oauth/token"
BASE_URL = "https://dev.simplifi.work/api"

class SimplifiClient:
    def __init__(self, client_id: str, client_secret: str):
        self.client_id = client_id
        self.client_secret = client_secret
        self._token: str | None = None
        self._token_expiry: float = 0

    def get_access_token(self) -> str:
        response = requests.post(
            AUTH_URL,
            data={"grant_type": "client_credentials"},
            auth=(self.client_id, self.client_secret),
        )
        response.raise_for_status()
        data = response.json()
        self._token = data["access_token"]
        # Subtract 30 seconds as a buffer so we refresh slightly before 			 expiry
        self._token_expiry = time.time() + data["expires_in"] - 30
        return self._token

	# Is the token expired? if so _get_access_token
    def get_valid_token(self) -> str:
        if self._token is None or time.time() >= self._token_expiry:
            self.get_access_token()
        return self._token

    def request(self, method: str, path: str, **kwargs) -> dict:
        token = self.get_valid_token()
        response = requests.request(
            method,
            f"{BASE_URL}{path}",
            headers={"Authorization": f"Bearer {token}"},
            **kwargs,
        )
        if response.status_code == 401:
            # Token rejected by server — force a refresh and retry once
            self._token = None
            token = self._get_valid_token()
            response = requests.request(
                method,
                f"{BASE_URL}{path}",
                headers={"Authorization": f"Bearer {token}"},
                **kwargs,
            )
        response.raise_for_status()
        return response.json()

    def get_employee(self, employee_id: str) -> dict:
        return self.request("GET", f"/v1/employees/{employee_id}")

    def get_employees(self) -> list:
        return self.request("GET", "/v1/employees")


# Usage
client = SimplifiClient(CLIENT_ID, CLIENT_SECRET)
employee = client.get_employee("123")
```

Note that when the `request` method in the `SimplifiClient` class is called, it gets a valid token by calling `get_valid_token` which checks if an hour has passed (minus 30 seconds) and if so, then it fetches a new, valid token by calling `get_access_token` .

## Testing out authentication using Postman

Here's an example of us requesting for a list of employees in [Postman](www.postman.com). Postman is a SAAS that offers a free plan that you could use to test out the Simplifi API.

Start by making a new request under your collection, and navigate to the **Authorisation** tab.

<Frame>
  <img src="https://mintcdn.com/simplifi/JE5aB2opTKCuoSmw/images/2026-05-07_10-45-23.png?fit=max&auto=format&n=JE5aB2opTKCuoSmw&q=85&s=56fb9a1cd5c9604e8337f339f0cdca6f" alt="2026 05 07 10 43 15" width="1438" height="835" data-path="images/2026-05-07_10-45-23.png" />
</Frame>

Change the Auth Type to **OAuth2.0**

<Frame>
  <img src="https://mintcdn.com/simplifi/JE5aB2opTKCuoSmw/images/2026-05-07_10-46-39.png?fit=max&auto=format&n=JE5aB2opTKCuoSmw&q=85&s=0b7e1a46866504f640157adfac60f674" alt="2026 05 07 10 46 39" width="1436" height="830" data-path="images/2026-05-07_10-46-39.png" />
</Frame>

Scroll down and enter in your **Client ID** and **Client Secret**. Make sure that *Add authorisation data to* is set to Request Headers, *Grant type* is set to Cleint Credentials, and *Client Authentication* is set to **Send as Basic Auth Header**. Scroll down and enter in your **Client ID** and **Client Secret**. Make sure that *Add authorisation data to* is set to Request Headers, *Grant type* is set to Client Credentials, and *Client Authentication* is set to **Send as Basic Auth Header**.

<Frame>
  <img src="https://mintcdn.com/simplifi/JE5aB2opTKCuoSmw/images/2026-05-07_10-49-16.png?fit=max&auto=format&n=JE5aB2opTKCuoSmw&q=85&s=8c7d2fa8651e91b38ab2366134528d12" alt="2026 05 07 10 49 16" width="1436" height="837" data-path="images/2026-05-07_10-49-16.png" />
</Frame>

Scroll down again and press **Get New Access Token**

<Frame>
  <img src="https://mintcdn.com/simplifi/JE5aB2opTKCuoSmw/images/2026-05-07_10-53-12.png?fit=max&auto=format&n=JE5aB2opTKCuoSmw&q=85&s=9843c8a6e9c4191de0669b6d51d79d0a" alt="2026 05 07 10 53 12" width="1435" height="470" data-path="images/2026-05-07_10-53-12.png" />
</Frame>

You should now have generated an access token. Press **Use Token** to proceed.

1. Now enter in the address for the request. We are going to be getting all employees in the organisation, so ours is [https://dev.simplifi.work/api/v1/employees/](https://dev.simplifi.work/api/v1/employees/)
2. Press **send** to request the employees.

<Frame>
  <img src="https://mintcdn.com/simplifi/JE5aB2opTKCuoSmw/images/2026-05-07_10-56-09.png?fit=max&auto=format&n=JE5aB2opTKCuoSmw&q=85&s=cbbf0f29b3314fb792f01bb1dd0fef5d" alt="2026 05 07 10 56 09" width="1438" height="833" data-path="images/2026-05-07_10-56-09.png" />
</Frame>

You should now be able to see in the response body at the bottom, which has all the employees.
