# Authentication

Client authentication APIs. Used by client applications to register users, log in players, and refresh session tokens.

## Register a new player account

> Register a new player account using Sverse backend.\
> \
> This API is intended for \*\*game developers without their own backend\*\*.\
> Sverse manages user authentication, identity generation, and player metadata.\
> \
> The returned \`identity\` is a unique player identifier used across all other APIs.<br>

```json
{"openapi":"3.0.3","info":{"title":"Sverse Managed Backend (Client SDK)","version":"1.0.0"},"tags":[{"name":"Authentication","description":"Client authentication APIs.\nUsed by client applications to register users,\nlog in players, and refresh session tokens.\n"}],"servers":[{"url":"https://be.sverse.io","description":"Sverse Managed Backend (Production)"}],"paths":{"/api/public/auth/register":{"post":{"tags":["Authentication"],"summary":"Register a new player account","description":"Register a new player account using Sverse backend.\n\nThis API is intended for **game developers without their own backend**.\nSverse manages user authentication, identity generation, and player metadata.\n\nThe returned `identity` is a unique player identifier used across all other APIs.\n","operationId":"registerAccount","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["gameCode","email","username","password"],"properties":{"gameCode":{"type":"string","description":"Unique code of the game registered on Sverse"},"email":{"type":"string","format":"email","description":"Player email address"},"username":{"type":"string","description":"Display name of the player"},"password":{"type":"string","format":"password","description":"Player password"},"metadata":{"type":"object","description":"Custom metadata defined by the game developer.\nStored and returned as-is.\n","additionalProperties":true}}}}}},"responses":{"200":{"description":"Register successfully","content":{"application/json":{"schema":{"type":"object","required":["error","data"],"properties":{"error":{"type":"boolean"},"data":{"type":"object","required":["identity","username"],"properties":{"identity":{"type":"string","description":"Unique player identity in Sverse system"},"username":{"type":"string"},"metadata":{"type":"object","description":"Custom metadata defined by the game developer.\nStored and returned as-is.\n","additionalProperties":true}}}}}}}},"400":{"description":"Invalid request data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Account already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too many requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"components":{"schemas":{"ErrorResponse":{"type":"object","required":["error","code","message"],"properties":{"error":{"type":"boolean"},"message":{"type":"string","description":"Human-readable error message (dynamic)"},"details":{"type":"object","description":"Optional additional error details","additionalProperties":true},"requestId":{"type":"string","description":"Unique request identifier for tracing"}}}}}}
```

## Login player account

> Authenticate an existing player using Sverse backend.\
> \
> This API is designed for \*\*game developers without their own backend\*\*.\
> Sverse handles authentication and session management.\
> \
> After successful login, a \`sessionId\` will be returned.\
> This \`sessionId\` must be included in subsequent authenticated requests.<br>

```json
{"openapi":"3.0.3","info":{"title":"Sverse Managed Backend (Client SDK)","version":"1.0.0"},"tags":[{"name":"Authentication","description":"Client authentication APIs.\nUsed by client applications to register users,\nlog in players, and refresh session tokens.\n"}],"servers":[{"url":"https://be.sverse.io","description":"Sverse Managed Backend (Production)"}],"paths":{"/api/public/auth/login":{"post":{"tags":["Authentication"],"summary":"Login player account","description":"Authenticate an existing player using Sverse backend.\n\nThis API is designed for **game developers without their own backend**.\nSverse handles authentication and session management.\n\nAfter successful login, a `sessionId` will be returned.\nThis `sessionId` must be included in subsequent authenticated requests.\n","operationId":"loginAccount","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["gameCode","email","password"],"properties":{"gameCode":{"type":"string","description":"Unique code of the game registered on Sverse"},"email":{"type":"string","format":"email","description":"Player email address"},"password":{"type":"string","format":"password","description":"Player password"}}}}}},"responses":{"200":{"description":"Login successfully","content":{"application/json":{"schema":{"type":"object","required":["error","data"],"properties":{"error":{"type":"boolean"},"data":{"type":"object","required":["identity","sessionId","expiresIn"],"properties":{"identity":{"type":"string","description":"Unique player identity in Sverse system"},"username":{"type":"string"},"email":{"type":"string","format":"email"},"metadata":{"type":"object","description":"Custom player metadata stored during registration","additionalProperties":true},"sessionId":{"type":"string","description":"Session identifier generated by Sverse.\nUsed for authenticating subsequent API calls.\n"},"expiresIn":{"type":"integer","description":"Session expiration time in seconds"}}}}}}}},"400":{"description":"Invalid request data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Game is disabled or access denied","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too many requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"components":{"schemas":{"ErrorResponse":{"type":"object","required":["error","code","message"],"properties":{"error":{"type":"boolean"},"message":{"type":"string","description":"Human-readable error message (dynamic)"},"details":{"type":"object","description":"Optional additional error details","additionalProperties":true},"requestId":{"type":"string","description":"Unique request identifier for tracing"}}}}}}
```

## Logout player session

> Logs out the current player by invalidating the active session.\
> \
> The Bearer token \*\*must be the \`sessionId\`\*\* returned from the Login API.\
> Once logged out, the sessionId will no longer be valid for authenticated requests.\
> \
> This API is intended for \*\*game developers without their own backend\*\*,\
> using Sverse authentication services.<br>

```json
{"openapi":"3.0.3","info":{"title":"Sverse Managed Backend (Client SDK)","version":"1.0.0"},"tags":[{"name":"Authentication","description":"Client authentication APIs.\nUsed by client applications to register users,\nlog in players, and refresh session tokens.\n"}],"servers":[{"url":"https://be.sverse.io","description":"Sverse Managed Backend (Production)"}],"security":[{"sessionAuth":[]}],"components":{"securitySchemes":{"sessionAuth":{"type":"http","scheme":"bearer","bearerFormat":"sessionId","description":"Use the `sessionId` returned from the Login API.\nExample:\nAuthorization: Bearer 9d7b6121-30d3-44cf-8b4f-c00e2f4f016e\n"}}},"paths":{"/api/public/auth/logout":{"post":{"tags":["Authentication"],"summary":"Logout player session","description":"Logs out the current player by invalidating the active session.\n\nThe Bearer token **must be the `sessionId`** returned from the Login API.\nOnce logged out, the sessionId will no longer be valid for authenticated requests.\n\nThis API is intended for **game developers without their own backend**,\nusing Sverse authentication services.\n","operationId":"logoutAccount","responses":{"200":{"description":"Logout successfully","content":{"application/json":{"schema":{"type":"object","required":["error","message"],"properties":{"error":{"type":"boolean"},"message":{"type":"string"}}}}}},"default":{"description":"Logout failed","content":{"application/json":{"schema":{"type":"object","required":["error","message"],"properties":{"error":{"type":"boolean"},"message":{"type":"string"}}}}}}}}}}}
```


---

# 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://sverse-1.gitbook.io/sverse-docs/api-reference/client/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.
