> For the complete documentation index, see [llms.txt](https://tangled.gitbook.io/tangled-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tangled.gitbook.io/tangled-docs/api-reference/auth.md).

# Auth

Authentication and authorization

## POST /auth/token

> Login

```json
{"openapi":"3.1.0","info":{"title":"Tangled API","version":"0.1.0"},"tags":[{"name":"Auth","description":"Authentication and authorization"}],"paths":{"/auth/token":{"post":{"tags":["Auth"],"summary":"Login","operationId":"login_auth_token_post","requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/Body_login_auth_token_post"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Token"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"Body_login_auth_token_post":{"properties":{"grant_type":{"anyOf":[{"type":"string","pattern":"password"},{"type":"null"}],"title":"Grant Type"},"username":{"type":"string","title":"Username"},"password":{"type":"string","title":"Password"},"scope":{"type":"string","title":"Scope","default":""},"client_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Client Id"},"client_secret":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Client Secret"}},"type":"object","required":["username","password"],"title":"Body_login_auth_token_post"},"Token":{"properties":{"access_token":{"type":"string","title":"Access Token"},"token_type":{"type":"string","title":"Token Type","default":"bearer"}},"type":"object","required":["access_token"],"title":"Token"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}}}
```

## POST /auth/change-password

> Change Password

```json
{"openapi":"3.1.0","info":{"title":"Tangled API","version":"0.1.0"},"tags":[{"name":"Auth","description":"Authentication and authorization"}],"security":[{"OAuth2PasswordBearer":[]}],"components":{"securitySchemes":{"OAuth2PasswordBearer":{"type":"oauth2","flows":{"password":{"scopes":{},"tokenUrl":"/auth/token"}}}},"schemas":{"ChangePasswordIn":{"properties":{"current_password":{"type":"string","title":"Current Password"},"new_password":{"type":"string","minLength":8,"title":"New Password"},"new_password_confirm":{"type":"string","minLength":8,"title":"New Password Confirm"}},"type":"object","required":["current_password","new_password","new_password_confirm"],"title":"ChangePasswordIn"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/auth/change-password":{"post":{"tags":["Auth"],"summary":"Change Password","operationId":"change_password_auth_change_password_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChangePasswordIn"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## GET /auth/sessions

> List Sessions

```json
{"openapi":"3.1.0","info":{"title":"Tangled API","version":"0.1.0"},"tags":[{"name":"Auth","description":"Authentication and authorization"}],"security":[{"OAuth2PasswordBearer":[]}],"components":{"securitySchemes":{"OAuth2PasswordBearer":{"type":"oauth2","flows":{"password":{"scopes":{},"tokenUrl":"/auth/token"}}}},"schemas":{"SessionOut":{"properties":{"id":{"type":"integer","title":"Id"},"ip_address":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ip Address"},"user_agent":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"User Agent"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"last_seen":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Seen"},"current":{"type":"boolean","title":"Current","default":false}},"type":"object","required":["id","created_at"],"title":"SessionOut"}}},"paths":{"/auth/sessions":{"get":{"tags":["Auth"],"summary":"List Sessions","operationId":"list_sessions_auth_sessions_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/SessionOut"},"type":"array","title":"Response List Sessions Auth Sessions Get"}}}}}}}}}
```

## POST /auth/sessions/{session\_id}/revoke

> Revoke Session

```json
{"openapi":"3.1.0","info":{"title":"Tangled API","version":"0.1.0"},"tags":[{"name":"Auth","description":"Authentication and authorization"}],"security":[{"OAuth2PasswordBearer":[]}],"components":{"securitySchemes":{"OAuth2PasswordBearer":{"type":"oauth2","flows":{"password":{"scopes":{},"tokenUrl":"/auth/token"}}}},"schemas":{"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/auth/sessions/{session_id}/revoke":{"post":{"tags":["Auth"],"summary":"Revoke Session","operationId":"revoke_session_auth_sessions__session_id__revoke_post","parameters":[{"name":"session_id","in":"path","required":true,"schema":{"type":"integer","title":"Session Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## POST /auth/sessions/revoke-all

> Revoke All Sessions

```json
{"openapi":"3.1.0","info":{"title":"Tangled API","version":"0.1.0"},"tags":[{"name":"Auth","description":"Authentication and authorization"}],"security":[{"OAuth2PasswordBearer":[]}],"components":{"securitySchemes":{"OAuth2PasswordBearer":{"type":"oauth2","flows":{"password":{"scopes":{},"tokenUrl":"/auth/token"}}}}},"paths":{"/auth/sessions/revoke-all":{"post":{"tags":["Auth"],"summary":"Revoke All Sessions","operationId":"revoke_all_sessions_auth_sessions_revoke_all_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}}}}
```

## POST /auth/logout

> Logout

```json
{"openapi":"3.1.0","info":{"title":"Tangled API","version":"0.1.0"},"tags":[{"name":"Auth","description":"Authentication and authorization"}],"paths":{"/auth/logout":{"post":{"tags":["Auth"],"summary":"Logout","operationId":"logout_auth_logout_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}}}}
```

## GET /auth/api-keys

> List Api Keys

```json
{"openapi":"3.1.0","info":{"title":"Tangled API","version":"0.1.0"},"tags":[{"name":"Auth","description":"Authentication and authorization"}],"security":[{"OAuth2PasswordBearer":[]}],"components":{"securitySchemes":{"OAuth2PasswordBearer":{"type":"oauth2","flows":{"password":{"scopes":{},"tokenUrl":"/auth/token"}}}},"schemas":{"APIKeyOut":{"properties":{"id":{"type":"integer","title":"Id"},"name":{"type":"string","title":"Name"},"key_prefix":{"type":"string","title":"Key Prefix"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"last_used_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Used At"}},"type":"object","required":["id","name","key_prefix","created_at"],"title":"APIKeyOut"}}},"paths":{"/auth/api-keys":{"get":{"tags":["Auth"],"summary":"List Api Keys","operationId":"list_api_keys_auth_api_keys_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/APIKeyOut"},"type":"array","title":"Response List Api Keys Auth Api Keys Get"}}}}}}}}}
```

## POST /auth/api-keys

> Create Api Key

```json
{"openapi":"3.1.0","info":{"title":"Tangled API","version":"0.1.0"},"tags":[{"name":"Auth","description":"Authentication and authorization"}],"security":[{"OAuth2PasswordBearer":[]}],"components":{"securitySchemes":{"OAuth2PasswordBearer":{"type":"oauth2","flows":{"password":{"scopes":{},"tokenUrl":"/auth/token"}}}},"schemas":{"APIKeyCreate":{"properties":{"name":{"type":"string","title":"Name"}},"type":"object","required":["name"],"title":"APIKeyCreate"},"APIKeyCreated":{"properties":{"id":{"type":"integer","title":"Id"},"name":{"type":"string","title":"Name"},"key":{"type":"string","title":"Key"},"key_prefix":{"type":"string","title":"Key Prefix"},"created_at":{"type":"string","format":"date-time","title":"Created At"}},"type":"object","required":["id","name","key","key_prefix","created_at"],"title":"APIKeyCreated"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/auth/api-keys":{"post":{"tags":["Auth"],"summary":"Create Api Key","operationId":"create_api_key_auth_api_keys_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIKeyCreate"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIKeyCreated"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## DELETE /auth/api-keys/{key\_id}

> Revoke Api Key

```json
{"openapi":"3.1.0","info":{"title":"Tangled API","version":"0.1.0"},"tags":[{"name":"Auth","description":"Authentication and authorization"}],"security":[{"OAuth2PasswordBearer":[]}],"components":{"securitySchemes":{"OAuth2PasswordBearer":{"type":"oauth2","flows":{"password":{"scopes":{},"tokenUrl":"/auth/token"}}}},"schemas":{"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/auth/api-keys/{key_id}":{"delete":{"tags":["Auth"],"summary":"Revoke Api Key","operationId":"revoke_api_key_auth_api_keys__key_id__delete","parameters":[{"name":"key_id","in":"path","required":true,"schema":{"type":"integer","title":"Key Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```
