# Authentication

## POST /auth/verification/send-code

> Request email verification code (passwordless login)

```json
{"openapi":"3.0.1","info":{"title":"Unturned.AI.API","version":"1.0.0"},"tags":[{"name":"Authentication"},{"name":"Verification"}],"servers":[{"url":"http://localhost:8000","description":"Develop Env"}],"security":[{"测试用  Bearer Token":[]}],"components":{"securitySchemes":{"测试用  Bearer Token":{"scheme":"bearer","type":"http"}},"schemas":{"SendCodeRequest":{"properties":{"email":{"type":"string","format":"email","title":"Email","description":"User email address"}},"type":"object","required":["email"],"title":"SendCodeRequest"},"SuccessResponse_dict_":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"data":{"additionalProperties":true,"type":"object","title":"Data","properties":{}},"error":{"anyOf":[{"additionalProperties":true,"type":"object","properties":{}},{"type":"null"}],"title":"Error"}},"type":"object","required":["data"],"title":"SuccessResponse[dict]"},"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/verification/send-code":{"post":{"summary":"Request email verification code (passwordless login)","deprecated":false,"description":"","operationId":"send_code_auth_verification_send_code_post","tags":["Authentication","Authentication","Verification"],"parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendCodeRequest"}}}},"responses":{"202":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse_dict_"}}},"headers":{}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}},"headers":{}}}}}}}
```

## POST /auth/verification/verify-code

> Verify code and get JWT token

```json
{"openapi":"3.0.1","info":{"title":"Unturned.AI.API","version":"1.0.0"},"tags":[{"name":"Authentication"},{"name":"Verification"}],"servers":[{"url":"http://localhost:8000","description":"Develop Env"}],"security":[{"测试用  Bearer Token":[]}],"components":{"securitySchemes":{"测试用  Bearer Token":{"scheme":"bearer","type":"http"}},"schemas":{"SuccessResponse_TokenResponse_":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"data":{"$ref":"#/components/schemas/TokenResponse"},"error":{"anyOf":[{"additionalProperties":true,"type":"object","properties":{}},{"type":"null"}],"title":"Error"}},"type":"object","required":["data"],"title":"SuccessResponse[TokenResponse]"},"TokenResponse":{"properties":{"access_token":{"type":"string","title":"Access Token"},"refresh_token":{"type":"string","title":"Refresh Token"},"token_type":{"type":"string","title":"Token Type","default":"bearer"}},"type":"object","required":["access_token","refresh_token"],"title":"TokenResponse"}}},"paths":{"/auth/verification/verify-code":{"post":{"summary":"Verify code and get JWT token","deprecated":false,"description":"","operationId":"verify_code_auth_verification_verify_code_post","tags":["Authentication","Authentication","Verification"],"parameters":[],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{}}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse_TokenResponse_"}}},"headers":{}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"type":"object","properties":{}}}},"headers":{}}}}}}}
```

## POST /auth/verification/refresh-token

> Refresh JWT token

```json
{"openapi":"3.0.1","info":{"title":"Unturned.AI.API","version":"1.0.0"},"tags":[{"name":"Authentication"},{"name":"Verification"}],"servers":[{"url":"http://localhost:8000","description":"Develop Env"}],"security":[{"测试用  Bearer Token":[]}],"components":{"securitySchemes":{"测试用  Bearer Token":{"scheme":"bearer","type":"http"}},"schemas":{"RefreshTokenRequest":{"properties":{"refresh_token":{"type":"string","title":"Refresh Token","description":"Refresh token to exchange for a new access token"},"user_uuid":{"type":"string","title":"User Uuid","description":"User UUID"}},"type":"object","required":["refresh_token","user_uuid"],"title":"RefreshTokenRequest"},"SuccessResponse_TokenResponse_":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"data":{"$ref":"#/components/schemas/TokenResponse"},"error":{"anyOf":[{"additionalProperties":true,"type":"object","properties":{}},{"type":"null"}],"title":"Error"}},"type":"object","required":["data"],"title":"SuccessResponse[TokenResponse]"},"TokenResponse":{"properties":{"access_token":{"type":"string","title":"Access Token"},"refresh_token":{"type":"string","title":"Refresh Token"},"token_type":{"type":"string","title":"Token Type","default":"bearer"}},"type":"object","required":["access_token","refresh_token"],"title":"TokenResponse"}}},"paths":{"/auth/verification/refresh-token":{"post":{"summary":"Refresh JWT token","deprecated":false,"description":"","operationId":"refresh_token_auth_verification_refresh_token_post","tags":["Authentication","Authentication","Verification"],"parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RefreshTokenRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse_TokenResponse_"}}},"headers":{}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"type":"object","properties":{}}}},"headers":{}}}}}}}
```

## POST /auth/verification/revoke-token

> Revoke JWT token

```json
{"openapi":"3.0.1","info":{"title":"Unturned.AI.API","version":"1.0.0"},"tags":[{"name":"Authentication"},{"name":"Verification"}],"servers":[{"url":"http://localhost:8000","description":"Develop Env"}],"security":[{"测试用  Bearer Token":[]}],"components":{"securitySchemes":{"测试用  Bearer Token":{"scheme":"bearer","type":"http"}},"schemas":{"RevokeTokenRequest":{"properties":{"refresh_token":{"type":"string","title":"Refresh Token","description":"Refresh token to revoke"}},"type":"object","required":["refresh_token"],"title":"RevokeTokenRequest"}}},"paths":{"/auth/verification/revoke-token":{"post":{"summary":"Revoke JWT token","deprecated":false,"description":"","operationId":"revoke_token_auth_verification_revoke_token_post","tags":["Authentication","Authentication","Verification"],"parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RevokeTokenRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","properties":{}}}},"headers":{}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"type":"object","properties":{}}}},"headers":{}}}}}}}
```

## GET /auth/users/me

> Get current user info and billing

```json
{"openapi":"3.0.1","info":{"title":"Unturned.AI.API","version":"1.0.0"},"tags":[{"name":"Authentication"},{"name":"Users"}],"servers":[{"url":"http://localhost:8000","description":"Develop Env"}],"security":[{"测试用  Bearer Token":[]}],"components":{"securitySchemes":{"测试用  Bearer Token":{"scheme":"bearer","type":"http"}},"schemas":{"SuccessResponse_UserResponse_":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"data":{"$ref":"#/components/schemas/UserResponse"},"error":{"anyOf":[{"additionalProperties":true,"type":"object","properties":{}},{"type":"null"}],"title":"Error"}},"type":"object","required":["data"],"title":"SuccessResponse[UserResponse]"},"UserResponse":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"email":{"type":"string","format":"email","title":"Email"},"full_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Full Name"},"is_active":{"type":"boolean","title":"Is Active"},"is_superuser":{"type":"boolean","title":"Is Superuser"},"is_verified":{"type":"boolean","title":"Is Verified"},"projects":{"items":{"$ref":"#/components/schemas/ProjectInfo"},"type":"array","title":"Projects"},"created_at":{"type":"string","title":"Created At"},"updated_at":{"type":"string","title":"Updated At"},"billing":{"$ref":"#/components/schemas/BillingInfo"}},"type":"object","required":["id","email","is_active","is_superuser","is_verified","projects","created_at","updated_at","billing"],"title":"UserResponse"},"ProjectInfo":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"name":{"type":"string","title":"Name"}},"type":"object","required":["id","name"],"title":"ProjectInfo"},"BillingInfo":{"properties":{"token_balance":{"type":"integer","title":"Token Balance"},"tokens_used":{"type":"integer","title":"Tokens Used"},"subscription_tier":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Subscription Tier"}},"type":"object","required":["token_balance","tokens_used"],"title":"BillingInfo"}}},"paths":{"/auth/users/me":{"get":{"summary":"Get current user info and billing","deprecated":false,"description":"","operationId":"get_me_auth_users_me_get","tags":["Authentication","Authentication","Users"],"parameters":[],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse_UserResponse_"}}},"headers":{}}}}}}}
```

## GET /auth/api-keys/

> List all API keys for the authenticated user

```json
{"openapi":"3.0.1","info":{"title":"Unturned.AI.API","version":"1.0.0"},"tags":[{"name":"Authentication"},{"name":"API Keys"}],"servers":[{"url":"http://localhost:8000","description":"Develop Env"}],"security":[{"测试用  Bearer Token":[]}],"components":{"securitySchemes":{"测试用  Bearer Token":{"scheme":"bearer","type":"http"}},"schemas":{"ListApiKeysResponse":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"data":{"$ref":"#/components/schemas/PaginatedData_ApiKeyResponse_"},"error":{"anyOf":[{"additionalProperties":true,"type":"object","properties":{}},{"type":"null"}],"title":"Error"}},"type":"object","required":["data"],"title":"ListApiKeysResponse"},"PaginatedData_ApiKeyResponse_":{"properties":{"items":{"items":{"$ref":"#/components/schemas/ApiKeyResponse"},"type":"array","title":"Items"},"pagination":{"$ref":"#/components/schemas/PaginationInfo"}},"type":"object","required":["items","pagination"],"title":"PaginatedData[ApiKeyResponse]"},"ApiKeyResponse":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"prefix":{"type":"string","title":"Prefix"},"name":{"type":"string","title":"Name"},"full_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Full Key"},"scopes":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Scopes"},"last_used_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Used At"},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Expires At"},"is_active":{"type":"boolean","title":"Is Active"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"updated_at":{"type":"string","format":"date-time","title":"Updated At"}},"type":"object","required":["id","prefix","name","is_active","created_at","updated_at"],"title":"ApiKeyResponse"},"PaginationInfo":{"properties":{"page":{"type":"integer","title":"Page"},"limit":{"type":"integer","title":"Limit"},"total":{"type":"integer","title":"Total"},"pages":{"type":"integer","title":"Pages"}},"type":"object","required":["page","limit","total","pages"],"title":"PaginationInfo","description":"Pagination metadata."},"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/":{"get":{"summary":"List all API keys for the authenticated user","deprecated":false,"description":"","operationId":"list_api_keys_auth_api_keys__get","tags":["Authentication","Authentication","API Keys"],"parameters":[{"name":"page","in":"query","description":"","required":false,"schema":{"type":"integer","minimum":1,"default":1,"title":"Page"}},{"name":"limit","in":"query","description":"","required":false,"schema":{"type":"integer","minimum":1,"default":10,"title":"Limit"}},{"name":"x-project-id","in":"header","description":"Project ID to operate on","required":true,"schema":{"type":"string","description":"Project ID to operate on","title":"X-Project-Id"}},{"name":"x-api-key","in":"header","description":"Auth with API Key, optional, just for test","required":false,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{}}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListApiKeysResponse"}}},"headers":{}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}},"headers":{}}}}}}}
```

## POST /auth/api-keys/

> Create a new API key

```json
{"openapi":"3.0.1","info":{"title":"Unturned.AI.API","version":"1.0.0"},"tags":[{"name":"Authentication"},{"name":"API Keys"}],"servers":[{"url":"http://localhost:8000","description":"Develop Env"}],"security":[{"测试用  Bearer Token":[]}],"components":{"securitySchemes":{"测试用  Bearer Token":{"scheme":"bearer","type":"http"}},"schemas":{"CreateApiKeyRequest":{"properties":{"name":{"type":"string","title":"Name","description":"API key name"},"expires_in_days":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Expires In Days","description":"Expiration in days (optional)"},"scopes":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Scopes","description":"List of scopes (optional)"}},"type":"object","required":["name"],"title":"CreateApiKeyRequest"},"SuccessResponse_ApiKeyResponse_":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"data":{"$ref":"#/components/schemas/ApiKeyResponse"},"error":{"anyOf":[{"additionalProperties":true,"type":"object","properties":{}},{"type":"null"}],"title":"Error"}},"type":"object","required":["data"],"title":"SuccessResponse[ApiKeyResponse]"},"ApiKeyResponse":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"prefix":{"type":"string","title":"Prefix"},"name":{"type":"string","title":"Name"},"full_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Full Key"},"scopes":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Scopes"},"last_used_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Used At"},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Expires At"},"is_active":{"type":"boolean","title":"Is Active"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"updated_at":{"type":"string","format":"date-time","title":"Updated At"}},"type":"object","required":["id","prefix","name","is_active","created_at","updated_at"],"title":"ApiKeyResponse"},"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":{"summary":"Create a new API key","deprecated":false,"description":"","operationId":"create_api_key_auth_api_keys__post","tags":["Authentication","Authentication","API Keys"],"parameters":[{"name":"x-project-id","in":"header","description":"Project ID to operate on","required":true,"schema":{"type":"string","description":"Project ID to operate on","title":"X-Project-Id"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateApiKeyRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse_ApiKeyResponse_"}}},"headers":{}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}},"headers":{}}}}}}}
```

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

> Deactivate an API key

```json
{"openapi":"3.0.1","info":{"title":"Unturned.AI.API","version":"1.0.0"},"tags":[{"name":"Authentication"},{"name":"API Keys"}],"servers":[{"url":"http://localhost:8000","description":"Develop Env"}],"security":[{"测试用  Bearer Token":[]}],"components":{"securitySchemes":{"测试用  Bearer Token":{"scheme":"bearer","type":"http"}},"schemas":{"SuccessResponse_RevokeKeyResponse_":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"data":{"$ref":"#/components/schemas/RevokeKeyResponse"},"error":{"anyOf":[{"additionalProperties":true,"type":"object","properties":{}},{"type":"null"}],"title":"Error"}},"type":"object","required":["data"],"title":"SuccessResponse[RevokeKeyResponse]"},"RevokeKeyResponse":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"is_active":{"type":"boolean","title":"Is Active"},"deactivated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Deactivated At"}},"type":"object","required":["id","is_active"],"title":"RevokeKeyResponse"},"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":{"summary":"Deactivate an API key","deprecated":false,"description":"","operationId":"revoke_api_key_auth_api_keys__key_id__delete","tags":["Authentication","Authentication","API Keys"],"parameters":[{"name":"key_id","in":"path","description":"","required":true,"schema":{"type":"string","format":"uuid","title":"Key Id"}},{"name":"x-project-id","in":"header","description":"Project ID to operate on","required":true,"schema":{"type":"string","description":"Project ID to operate on","title":"X-Project-Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse_RevokeKeyResponse_"}}},"headers":{}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}},"headers":{}}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.unturned.ai/references/authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
