# End a session

`DELETE https://api.mailmasker.org/api/v1/auth/sessions/:jti`

Sign one of your sessions out at once, wherever it is.

- Who can use it: Any signed-in account
- Area: Sessions
- Answers 200 OK when it works
- Page: https://developer.mailmasker.org/end-session

Its token stops working straight away, and so does its refresh token, so it can't quietly sign itself back in. Ending the session you are using signs you out here too.

## Parameters

| Name | In | Required | What it is | Example |
|---|---|---|---|---|
| `jti` | path | yes | The session's id, in full, as your session list shows it. | `c41ac41ac41ac41ac41ac41ac41ac41ac41ac41ac41ac41ac41ac41ac41ac41a` |
| `user` | query | no | Another account's address, to end one of its sessions. Site admins only; anyone else gets 403. |  |

## Good to know

- A session that isn't yours, or was already ended, answers 404.
- homelab-cli also takes just the start of the id, as long as only one session matches it.

## Examples

cURL:

```bash
curl -s -X DELETE 'https://api.mailmasker.org/api/v1/auth/sessions/c41ac41ac41ac41ac41ac41ac41ac41ac41ac41ac41ac41ac41ac41ac41ac41a' \
  -H "Authorization: Bearer $TOKEN"
```

Perl:

```perl
use Mojo::Base -strict;
use Mojo::UserAgent;

my $ua  = Mojo::UserAgent->new;
my $res = $ua->delete('https://api.mailmasker.org/api/v1/auth/sessions/c41ac41ac41ac41ac41ac41ac41ac41ac41ac41ac41ac41ac41ac41ac41ac41a',
    { Authorization => "Bearer $ENV{TOKEN}" })->result;
die $res->code, ' ', ($res->json('/error') // $res->message), "\n" unless $res->is_success;
print $res->body, "\n";
```

homelab-cli:

```bash
homelab-cli sessions revoke c41a9e07b2d8
```

## Response

200 OK:

```json
{ "ok": true }
```
