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

# Admin/Authentication

Admin authentication.

```
STAGING_URL: https://switchapi3.azurewebsites.net
LIVE_URL: https://switchapi.azurewebsites.net
```

## Login

<mark style="color:green;">`POST`</mark> `https://switch-api-staging.herokuapp.com/admin/login`

Authenticates admin and returns a valid token used for session validation.

#### Headers

| Name    | Type   | Description      |
| ------- | ------ | ---------------- |
| SWI-CS  | string | Payload checksum |
| SWI-CID | string | Client ID        |

#### Request Body

| Name     | Type   | Description    |
| -------- | ------ | -------------- |
| email    | string | admin email    |
| password | string | admin password |

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

```
{
    "message": "Admin login successful",
    "data": {
        "auth_token": "eyJhbGciOiJIUzI1NiJ9.eyJhZG1pbl9pZCI6MTEsImV4cCI6MTU2Mjc2NTE3MSwiY29udGV4dCI6ImFkbWluIn0.gfGI47XH148fTfYMZSmcgYboDFpzOmPbWdPj2hkn1kY",
        "admin": {
            "id": 11,
            "email": "cs@switch.ng",
            "role": "customer_success",
            "disabled": false,
            "has_changed_password": true,
            "password_expired": false
        }
    }
}
```

{% endtab %}

{% tab title="401 " %}

```
{
    "message": "Invalid login details",
    "locked": false
}
```

{% endtab %}
{% endtabs %}

## Logout

<mark style="color:green;">`POST`</mark> `https://switch-api-staging.herokuapp.com/admin/logout`

Invalidates the admin's session token.

#### Headers

| Name          | Type   | Description                   |
| ------------- | ------ | ----------------------------- |
| SWI-CID       | string | Client ID                     |
| Authorization | string | Format  is ***Bearer token*** |

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

```
{
    "message": "User session invalidated"
}
```

{% endtab %}
{% endtabs %}
