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

# 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"}}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.meshmap.com/api/zones/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.
