# Authentication

Endpoints for user authentication.

## Authenticates a user for the current websocket session

> Authenticates using either username/password or API key method.

```json
{"openapi":"3.0.3","info":{"title":"Trading API","version":"1.0.0"},"tags":[{"name":"Authentication","description":"Endpoints for user authentication."}],"servers":[{"url":"https://apstage.proxy.kiiex.io/ap","description":"Staging Environment"},{"url":"https://alphaprod.proxy.kiiex.io/ap","description":"Production Environment"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"AuthenticationResult":{"type":"object","properties":{"user":{"type":"object","properties":{"userId":{"type":"integer"},"userName":{"type":"string"},"email":{"type":"string"},"emailVerified":{"type":"boolean"},"accountId":{"type":"integer"},"omsId":{"type":"integer"},"use2FA":{"type":"boolean"}}},"authenticated":{"type":"boolean"},"locked":{"type":"boolean"},"requires2FA":{"type":"boolean"},"twoFAType":{"type":"string"},"twoFAToken":{"type":"string"}}}}},"paths":{"/AuthenticateUser":{"post":{"tags":["Authentication"],"summary":"Authenticates a user for the current websocket session","description":"Authenticates using either username/password or API key method.","operationId":"AuthenticateUser","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","oneOf":[{"properties":{"APIKey":{"type":"string"},"Signature":{"type":"string"},"UserId":{"type":"string"},"UserName":{"type":"string"},"Nonce":{"type":"string"}}}]}}}},"responses":{"200":{"description":"Authentication result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthenticationResult"}}}},"400":{"description":"Invalid authentication request format"},"401":{"description":"Invalid credentials or token"}}}}}}
```
