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

# Authentication

Player authentication endpoints

## Register a new player account

> Creates a new player account in the system

```json
{"openapi":"3.0.0","info":{"title":"Terragon API Document","version":"1.0.0"},"tags":[{"name":"Authentication","description":"Player authentication endpoints"}],"servers":[{"url":"https://api.terragon.io/player/api","description":"Staging server"}],"security":[],"paths":{"/v1/signup":{"post":{"tags":["Authentication"],"summary":"Register a new player account","description":"Creates a new player account in the system","operationId":"playerSignup","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["username","email","password","confirm_password","language"],"properties":{"username":{"type":"string","description":"Player's username"},"email":{"type":"string","format":"email","description":"Player's email address"},"password":{"type":"string","format":"password","description":"Player's password (min 8 characters)"},"confirm_password":{"type":"string","format":"password","description":"Confirmation of the password"},"language":{"type":"string","description":"User's preferred language"},"d_id":{"type":"string","description":"Device identifier (optional)"}}}}}},"responses":{"201":{"description":"Player account created successfully","content":{"application/json":{"schema":{"type":"object","properties":{"token":{"type":"string","description":"JWT access token"},"token_type":{"type":"string"},"refresh_token":{"type":"string","description":"JWT refresh token"},"expires_in":{"type":"integer","description":"Token expiration time in seconds"}}}}}},"422":{"description":"Validation errors","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}}}}}}},"components":{"schemas":{"ValidationError":{"type":"object","properties":{"message":{"type":"string","description":"Error message"},"errors":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}},"description":"Validation errors by field"}}}}}}
```

## Player login

> Authenticate a player and get access token

```json
{"openapi":"3.0.0","info":{"title":"Terragon API Document","version":"1.0.0"},"tags":[{"name":"Authentication","description":"Player authentication endpoints"}],"servers":[{"url":"https://api.terragon.io/player/api","description":"Staging server"}],"security":[],"paths":{"/v1/signin":{"post":{"tags":["Authentication"],"summary":"Player login","description":"Authenticate a player and get access token","operationId":"playerSignin","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["username","password"],"properties":{"username":{"type":"string","description":"Player's username or email"},"password":{"type":"string","format":"password","description":"Player's password"},"d_id":{"type":"string","description":"Device identifier (optional)"}}}}}},"responses":{"200":{"description":"Login successful","content":{"application/json":{"schema":{"type":"object","properties":{"token":{"type":"string","description":"JWT access token"},"refresh_token":{"type":"string","description":"JWT refresh token for obtaining new access tokens"}}}}}},"401":{"description":"Invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation errors","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}}}}}}},"components":{"schemas":{"Error":{"type":"object","properties":{"message":{"type":"string","description":"Error message"}}},"ValidationError":{"type":"object","properties":{"message":{"type":"string","description":"Error message"},"errors":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}},"description":"Validation errors by field"}}}}}}
```

## Player logout

> Invalidate the current access token

```json
{"openapi":"3.0.0","info":{"title":"Terragon API Document","version":"1.0.0"},"tags":[{"name":"Authentication","description":"Player authentication endpoints"}],"servers":[{"url":"https://api.terragon.io/player/api","description":"Staging server"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"Error":{"type":"object","properties":{"message":{"type":"string","description":"Error message"}}}}},"paths":{"/v1/signout":{"get":{"tags":["Authentication"],"summary":"Player logout","description":"Invalidate the current access token","operationId":"playerSignout","responses":{"204":{"description":"Logout successful, no content returned"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```

## Refresh access token

> Get a new access token using refresh token

```json
{"openapi":"3.0.0","info":{"title":"Terragon API Document","version":"1.0.0"},"tags":[{"name":"Authentication","description":"Player authentication endpoints"}],"servers":[{"url":"https://api.terragon.io/player/api","description":"Staging server"}],"security":[],"paths":{"/v1/refresh-access":{"post":{"tags":["Authentication"],"summary":"Refresh access token","description":"Get a new access token using refresh token","operationId":"refreshToken","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["refresh_token"],"properties":{"refresh_token":{"type":"string","description":"Refresh token obtained during login"},"d_id":{"type":"string","description":"Device identifier (optional)"}}}}}},"responses":{"200":{"description":"Token refreshed successfully","content":{"application/json":{"schema":{"type":"object","properties":{"token":{"type":"string","description":"New JWT access token"},"token_type":{"type":"string"},"refresh_token":{"type":"string","description":"New JWT refresh token"},"expires_in":{"type":"integer","description":"Token expiration time in seconds"}}}}}},"401":{"description":"Invalid refresh token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"schemas":{"Error":{"type":"object","properties":{"message":{"type":"string","description":"Error message"}}}}}}
```

## Resend email verification

> Resend email verification code

```json
{"openapi":"3.0.0","info":{"title":"Terragon API Document","version":"1.0.0"},"tags":[{"name":"Authentication","description":"Player authentication endpoints"}],"servers":[{"url":"https://api.terragon.io/player/api","description":"Staging server"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}}},"paths":{"/v1/email/verify/resend":{"post":{"tags":["Authentication"],"summary":"Resend email verification","description":"Resend email verification code","operationId":"resendEmailVerification","responses":{"200":{"description":"Verification email sent successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","description":"Success message"}}}}}}}}}}}
```
