# Codes

Referral code management

## Get user code

> Get or generate a referral code for the authenticated user

```json
{"openapi":"3.0.3","info":{"title":"Decentraland Referral Service API","version":"1.0.0"},"tags":[{"name":"Codes","description":"Referral code management"}],"servers":[{"url":"https://rewards.decentraland.org","description":"Production server"},{"url":"https://rewards.decentraland.zone","description":"Development server"},{"url":"http://localhost:8000","description":"Local Development server"}],"security":[],"paths":{"/api/code":{"get":{"tags":["Codes"],"summary":"Get user code","description":"Get or generate a referral code for the authenticated user","responses":{"200":{"description":"User referral code","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","required":["user","code","created_at","updated_at"],"properties":{"user":{"type":"string","format":"address","description":"User address"},"code":{"type":"string","description":"Referral code"},"created_at":{"type":"string","format":"date-time","description":"Code creation time"},"updated_at":{"type":"string","format":"date-time","description":"Code last update time"}}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","required":["ok","error"],"properties":{"ok":{"type":"boolean","description":"Whether the request was successful"},"error":{"type":"string","description":"Error message"},"code":{"type":"string","description":"Error code"},"data":{"type":"object","description":"Additional error data"}}}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"type":"object","required":["ok","error"],"properties":{"ok":{"type":"boolean","description":"Whether the request was successful"},"error":{"type":"string","description":"Error message"},"code":{"type":"string","description":"Error code"},"data":{"type":"object","description":"Additional error data"}}}}}}}}}}}
```


---

# 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.decentraland.org/apis/apis/rewards/codes.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.
