# Authentication

User authentication and management

## Sync authentication token

> Syncs a Privy access token with the MeshMap auth service to obtain a session token.

```json
{"openapi":"3.0.0","info":{"title":"Zones API","version":"1.0.0"},"tags":[{"name":"Authentication","description":"User authentication and management"}],"servers":[{"url":"/api","description":"API base path"}],"paths":{"/auth/sync":{"post":{"summary":"Sync authentication token","description":"Syncs a Privy access token with the MeshMap auth service to obtain a session token.","tags":["Authentication"],"parameters":[{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"},"description":"Bearer token (Privy access token)"}],"responses":{"200":{"description":"Token synced successfully","content":{"application/json":{"schema":{"type":"object","description":"Session token response from auth service"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Auth service not configured","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Auth service unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"schemas":{"Error":{"type":"object","properties":{"error":{"type":"string"},"details":{"type":"object"}}}}}}
```

## GET /auth/user

> Get user by ID

```json
{"openapi":"3.0.0","info":{"title":"Zones API","version":"1.0.0"},"tags":[{"name":"Authentication","description":"User authentication and management"}],"servers":[{"url":"/api","description":"API base path"}],"paths":{"/auth/user":{"get":{"summary":"Get user by ID","tags":["Authentication"],"parameters":[{"name":"userId","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"User found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalServerError"}}}}},"components":{"schemas":{"User":{"type":"object","properties":{"id":{"type":"string"},"walletAddress":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"Error":{"type":"object","properties":{"error":{"type":"string"},"details":{"type":"object"}}}},"responses":{"BadRequest":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotFound":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"InternalServerError":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}
```

## POST /auth/user

> Create or retrieve a user

```json
{"openapi":"3.0.0","info":{"title":"Zones API","version":"1.0.0"},"tags":[{"name":"Authentication","description":"User authentication and management"}],"servers":[{"url":"/api","description":"API base path"}],"paths":{"/auth/user":{"post":{"summary":"Create or retrieve a user","tags":["Authentication"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["dynamicUserId"],"properties":{"dynamicUserId":{"type":"string"},"walletAddress":{"type":"string","nullable":true}}}}}},"responses":{"200":{"description":"Existing user returned","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"201":{"description":"New user created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"500":{"$ref":"#/components/responses/InternalServerError"}}}}},"components":{"schemas":{"UserResponse":{"allOf":[{"$ref":"#/components/schemas/User"},{"type":"object","properties":{"isNewUser":{"type":"boolean"}}}]},"User":{"type":"object","properties":{"id":{"type":"string"},"walletAddress":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"Error":{"type":"object","properties":{"error":{"type":"string"},"details":{"type":"object"}}}},"responses":{"BadRequest":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"InternalServerError":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}
```
