> For the complete documentation index, see [llms.txt](https://ronaldaug.gitbook.io/sim-rest/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ronaldaug.gitbook.io/sim-rest/routes/protected-routes.md).

# Protected Routes

To protect routes, keep the routes inside if statement as below

```php
if($auth->routes()){

  // Protect routes must be in this if statment
  
  $router->get("/protected-route",function(){
     echo "You've just accessed the protected route";
  })

}
```

## Access Protected Route with Token

`HEAD` `-/protected-route`

#### Headers

| Name          | Type   | Description  |
| ------------- | ------ | ------------ |
| Authorization | string | Bearer Token |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "status":200,
  "message:"Succefully retrieved data",
  "data":[..]
}
```

{% endtab %}
{% endtabs %}

\
You must have **token** to access protected routes.&#x20;

To generate a **token**, see under [Authentication section.](/sim-rest/authentication.md#get-admin-user-token)
