# Authenticate User

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://api.g.alchemy.com/signer/v1/whoami

Authenticates a user and returns their identity and wallet information, enabling the application to grant the user access to their Smart Wallet functionalities. This endpoint is used to confirm user authentication via email or passkey, thereby authorizing them to perform actions as the owner of a smart account or to conduct transactions as an EOA signer. It ensures that only authenticated users can access and manage their wallets.


Reference: https://www.alchemy.com/docs/wallets/api-reference/signer/signer-api-endpoints/auth-user

## Headers

| Name | Type | Required | Description |
|------|------|----------|-------------|
| Authorization | string | Yes | Bearer token authentication. Use 'Bearer <apiKey>' as the value. |

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://api.g.alchemy.com/signer/v1/whoami \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "stampedRequest": {
    "url": "string",
    "body": "string",
    "stamp": {
      "stampHeaderName": "string",
      "stampHeaderValue": "string"
    }
  }
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    stampedRequest: {
      url: 'string',
      body: JSON.stringify('string'),
      stamp: {stampHeaderName: 'string', stampHeaderValue: 'string'}
    }
  })
};

fetch('https://api.g.alchemy.com/signer/v1/whoami', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.g.alchemy.com/signer/v1/whoami"

payload = { "stampedRequest": {
        "url": "string",
        "body": "string",
        "stamp": {
            "stampHeaderName": "string",
            "stampHeaderValue": "string"
        }
    } }
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

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

func main() {

	url := "https://api.g.alchemy.com/signer/v1/whoami"

	payload := strings.NewReader("{\n  \"stampedRequest\": {\n    \"url\": \"string\",\n    \"body\": \"string\",\n    \"stamp\": {\n      \"stampHeaderName\": \"string\",\n      \"stampHeaderValue\": \"string\"\n    }\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")
	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://api.g.alchemy.com/signer/v1/whoami")
  .header("Content-Type", "application/json")
  .header("Authorization", "Bearer <token>")
  .body("{\n  \"stampedRequest\": {\n    \"url\": \"string\",\n    \"body\": \"string\",\n    \"stamp\": {\n      \"stampHeaderName\": \"string\",\n      \"stampHeaderValue\": \"string\"\n    }\n  }\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://api.g.alchemy.com/signer/v1/whoami");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n  \"stampedRequest\": {\n    \"url\": \"string\",\n    \"body\": \"string\",\n    \"stamp\": {\n      \"stampHeaderName\": \"string\",\n      \"stampHeaderValue\": \"string\"\n    }\n  }\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## Operation Specification

```yaml
path: /whoami
method: POST
operation:
  summary: Authenticate User
  description: |
    Authenticates a user and returns their identity and wallet information, enabling the application to grant the user access to their Smart Wallet functionalities. This endpoint is used to confirm user authentication via email or passkey, thereby authorizing them to perform actions as the owner of a smart account or to conduct transactions as an EOA signer. It ensures that only authenticated users can access and manage their wallets.
  security:
    - apiKey: []
  x-readme:
    samples-languages:
      - javascript
      - curl
      - python
      - go
  requestBody:
    content:
      application/json:
        schema:
          type: object
          properties:
            stampedRequest:
              description: |
                A stamped [Turnkey Whoami Request](https://docs.turnkey.com/api#tag/Sessions/operation/GetWhoami).
              type: object
              properties:
                url:
                  type: string
                  description: Generated by the turnkey client, but will be ignored on our end.
                body:
                  type: string
                  description: JSON stringified request body.
                stamp:
                  type: object
                  description: |
                    A JSON-encoded object containing stamping information.
                  properties:
                    stampHeaderName:
                      type: string
                      description: |
                        For WebAuthN based stamps, this should be `X-Stamp-Webauthn`. For all other stamps, this should be `X-Stamp`.
                    stampHeaderValue:
                      type: string
                      description: |
                        The stamp over the request body. See the [Turnkey Stamps Documentation](https://docs.turnkey.com/api-design/stamps) for information on the format of this value.
                  required:
                    - stampHeaderName
                    - stampHeaderValue
              required:
                - body
                - stamp
          required:
            - stampedRequest
  responses:
    '200':
      description: User authentication successful.
      content:
        application/json:
          schema:
            type: object
            properties:
              email:
                description: The authenticated user's email address.
                type: string
              userId:
                type: string
                description: A unique identifier for the authenticated user.
              orgId:
                description: The organization ID associated with the authenticated user's account.
                type: string
              address:
                type: string
                description: The Ethereum address of the user's signer. Essential for executing transactions and managing the wallet.
              solanaAddress:
                type: string
                description: The Solana address of the user's signer. Required for Solana transactions and wallet management.
            required:
              - userId
              - orgId
              - address
  operationId: authUser
```
