# Get a phone session

`GET /api/v1/mobile-sessions/{mobileSession}` and `QUERY /api/v1/mobile-sessions/{mobileSession}`

Retrieve one phone signed in through the Monica app.

This endpoint answers GET and QUERY alike, and both return the same answer. GET sends the parameters in the address, QUERY in the request body. [How QUERY works](https://monica.kentandrian.com/docs/api/query-method).

## Path parameters

- `mobileSession` (integer, required): The id of the phone session.

## Returns

A phone session object. A session of somebody else, or one already signed out, answers 404.

- `data` (object): The phone session.
- `data.type` (string): Always mobile_session. It names the kind of record, so a caller holding several kinds can tell them apart without looking at where they came from.
- `data.id` (string): The id of this record, as a string even when it reads as a number. It is what every endpoint naming this record takes.
- `data.attributes` (object): Everything the record holds.
- `data.attributes.device_name` (string): The name the phone gave itself when it signed in, or null when it gave none.
- `data.attributes.is_current` (boolean): Whether this is the phone making the request. Always false when you call with an API key.
- `data.attributes.last_used_at` (timestamp): When the phone signed in or last renewed its access, as a count of seconds. The app renews at least once an hour while it is used.
- `data.attributes.created_at` (timestamp): When the phone signed in, as a count of seconds since 1970.
- `data.attributes.updated_at` (timestamp): When the row last changed, as a count of seconds, or null.
- `data.links` (object): Where to find this record.
- `data.links.self` (string): The absolute address this record is read from.

## Rate limit

Sixty requests per minute, per user, shared by every key and device. Every answer carries the budget left in `X-RateLimit-Remaining`.

## Request

```sh
curl https://monica-789392842564.asia-southeast1.run.app/api/v1/mobile-sessions/12 \
  -H "Authorization: Bearer $MONICA_TOKEN"
```

```javascript
const response = await fetch('https://monica-789392842564.asia-southeast1.run.app/api/v1/mobile-sessions/12', {
  headers: { Authorization: `Bearer ${token}` },
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->get('https://monica-789392842564.asia-southeast1.run.app/api/v1/mobile-sessions/12');
```

## Request with QUERY

```sh
curl https://monica-789392842564.asia-southeast1.run.app/api/v1/mobile-sessions/12 \
  -X QUERY \
  -H "Authorization: Bearer $MONICA_TOKEN"
```

```javascript
const response = await fetch('https://monica-789392842564.asia-southeast1.run.app/api/v1/mobile-sessions/12', {
  method: 'QUERY',
  headers: { Authorization: `Bearer ${token}` },
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->query('https://monica-789392842564.asia-southeast1.run.app/api/v1/mobile-sessions/12');
```

## Response

`200`

```json
{
    "data": {
        "type": "mobile_session",
        "id": "12",
        "attributes": {
            "device_name": "Pixel 9",
            "is_current": true,
            "last_used_at": 1756339200,
            "created_at": 1756252800,
            "updated_at": 1756339200
        },
        "links": {
            "self": "https://monica-789392842564.asia-southeast1.run.app/api/v1/mobile-sessions/12"
        }
    }
}
```
