# Who is signed in

```http
GET /api/me
```

## Authorization

- **session**: `Authorization: Bearer <token>`. The session token from signing in (or the session cookie in a browser on the same origin).

## Response

**200**: It worked

- **user** `User | null` (required)
  - One of: **User**
    - **id** `string` (required): At most 300 characters
    - **email** `string` (required): At most 300 characters
    - **name** `string` (required): At most 300 characters
    - **image** `string | null`
    - **twoStep** `boolean`: Sign-in asks for a code from an authenticator app too
- **billing** `Billing`
  - **plan** `string` (required): At most 300 characters
  - **status** `string` (required): At most 300 characters
  - **renews** `number | null` (required)
  - **ends** `number | null` (required)
  - **manage** `boolean` (required): There is something to manage in the billing portal
  - **plans** `array<Plan>` (required)
    - **id** `string`: At most 300 characters
    - **title** `string`: At most 300 characters
    - **price** `number`: Cents per month. 0 is free.
    - **blurb** `string`: At most 300 characters
    - **features** `array<string>`

Other answers:

- **4XX**: Refused, with a message to show the person

## Example request

````tabs
tab: cURL
```bash
curl -X GET 'https://your-hatch-server/api/me' \
  -H 'Authorization: Bearer <token>'
```

tab: JavaScript
```js
const res = await fetch("https://your-hatch-server/api/me", {
  method: "GET",
  headers: {
    Authorization: "Bearer <token>",
  },
})
const data = await res.json()
```

tab: Python
```python
import requests

res = requests.request("GET", "https://your-hatch-server/api/me", headers={"Authorization": "Bearer <token>"})
data = res.json()
```

tab: Go
```go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, err := http.NewRequest("GET", "https://your-hatch-server/api/me", nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer <token>")
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	data, _ := io.ReadAll(res.Body)
	fmt.Println(string(data))
}
```

tab: Ruby
```ruby
require "net/http"

uri = URI('https://your-hatch-server/api/me')
req = Net::HTTP::Get.new(uri)
req['Authorization'] = 'Bearer <token>'

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
  http.request(req)
end
puts res.body
```

tab: PHP
```php
<?php

$ch = curl_init('https://your-hatch-server/api/me');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer <token>',
    ],
]);

$response = curl_exec($ch);
echo $response;
```

tab: Java
```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://your-hatch-server/api/me"))
    .header("Authorization", "Bearer <token>")
    .method("GET", HttpRequest.BodyPublishers.noBody())
    .build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```
````

## Example response

````tabs
tab: 200
```json
{
  "user": {
    "id": "string",
    "email": "string",
    "name": "string",
    "image": "string",
    "twoStep": true
  },
  "billing": {
    "plan": "string",
    "status": "string",
    "renews": 0,
    "ends": 0,
    "manage": true,
    "plans": [
      {
        "id": "string",
        "title": "string",
        "price": 0,
        "blurb": "string",
        "features": [
          "string"
        ]
      }
    ]
  }
}
```

tab: 4XX
```json
{
  "message": "string",
  "code": "string",
  "retryable": true,
  "requestId": "string"
}
```
````
