# Challenges

Challenge creation and management for missions

## Get challenges for a game

> Retrieve all active challenges for a specific game

```json
{"openapi":"3.0.3","info":{"title":"Exploration Games API","version":"1.0.0"},"tags":[{"name":"Challenges","description":"Challenge creation and management for missions"}],"servers":[{"url":"https://exploration-games.decentraland.org","description":"Production server"},{"url":"https://exploration-games.decentraland.zone","description":"Development server"}],"security":[],"paths":{"/api/games/{id}/challenges":{"get":{"tags":["Challenges"],"summary":"Get challenges for a game","description":"Retrieve all active challenges for a specific game","operationId":"getChallengesForGame","parameters":[{"name":"id","in":"path","description":"Game ID (UUID)","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"List of challenges","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Unique challenge identifier"},"description":{"type":"string","description":"Challenge description"},"game_id":{"type":"string","format":"uuid","description":"Associated game ID"},"mission_id":{"type":"string","format":"uuid","description":"Associated mission ID"},"target_level":{"type":"integer","minimum":1,"description":"Required level to complete challenge"},"data":{"type":"object","description":"Challenge conditions (e.g., score >= 1000)","additionalProperties":true},"active":{"type":"boolean","description":"Whether the challenge is active"}},"required":["id","description","game_id","mission_id","target_level","active"]}}}}}}},"400":{"description":"Invalid UUID","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message"},"message":{"type":"string","description":"Detailed error description"}}}}}}}}}}}
```

## Get user completed challenges by game

> Retrieve all challenges completed by the authenticated user for a specific game

```json
{"openapi":"3.0.3","info":{"title":"Exploration Games API","version":"1.0.0"},"tags":[{"name":"Challenges","description":"Challenge creation and management for missions"}],"servers":[{"url":"https://exploration-games.decentraland.org","description":"Production server"},{"url":"https://exploration-games.decentraland.zone","description":"Development server"}],"security":[],"paths":{"/api/games/{id}/challenges/completed":{"get":{"tags":["Challenges"],"summary":"Get user completed challenges by game","description":"Retrieve all challenges completed by the authenticated user for a specific game","operationId":"getUserCompletedChallengesByGame","parameters":[{"name":"id","in":"path","description":"Game ID (UUID)","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"List of completed challenges","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"allOf":[{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Unique challenge identifier"},"description":{"type":"string","description":"Challenge description"},"game_id":{"type":"string","format":"uuid","description":"Associated game ID"},"mission_id":{"type":"string","format":"uuid","description":"Associated mission ID"},"target_level":{"type":"integer","minimum":1,"description":"Required level to complete challenge"},"data":{"type":"object","description":"Challenge conditions (e.g., score >= 1000)","additionalProperties":true},"active":{"type":"boolean","description":"Whether the challenge is active"}},"required":["id","description","game_id","mission_id","target_level","active"]},{"type":"object","properties":{"completed":{"type":"boolean","description":"Whether the user completed this challenge"},"completed_at":{"type":"string","description":"Completion timestamp (ISO 8601)"}},"required":["completed","completed_at"]}]}}}}}}},"400":{"description":"Invalid UUID","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message"},"message":{"type":"string","description":"Detailed error description"}}}}}}}}}}}
```

## Create a new challenge

> Create a new challenge for a game and mission (Admin only)

```json
{"openapi":"3.0.3","info":{"title":"Exploration Games API","version":"1.0.0"},"tags":[{"name":"Challenges","description":"Challenge creation and management for missions"}],"servers":[{"url":"https://exploration-games.decentraland.org","description":"Production server"},{"url":"https://exploration-games.decentraland.zone","description":"Development server"}],"security":[],"paths":{"/api/challenges":{"post":{"tags":["Challenges"],"summary":"Create a new challenge","description":"Create a new challenge for a game and mission (Admin only)","operationId":"createChallenge","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"description":{"type":"string","description":"Challenge description"},"gameId":{"type":"string","format":"uuid","description":"Associated game ID"},"missionId":{"type":"string","format":"uuid","description":"Associated mission ID"},"targetLevel":{"type":"integer","minimum":1,"description":"Required level to complete challenge"},"data":{"type":"object","description":"Challenge conditions","additionalProperties":true}},"required":["description","gameId","missionId","targetLevel"]}}}},"responses":{"201":{"description":"Challenge created successfully","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Unique challenge identifier"},"description":{"type":"string","description":"Challenge description"},"game_id":{"type":"string","format":"uuid","description":"Associated game ID"},"mission_id":{"type":"string","format":"uuid","description":"Associated mission ID"},"target_level":{"type":"integer","minimum":1,"description":"Required level to complete challenge"},"data":{"type":"object","description":"Challenge conditions (e.g., score >= 1000)","additionalProperties":true},"active":{"type":"boolean","description":"Whether the challenge is active"}},"required":["id","description","game_id","mission_id","target_level","active"]}}}}}},"400":{"description":"Invalid request payload","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message"},"message":{"type":"string","description":"Detailed error description"}}}}}}}}}}}
```

## Update a challenge

> Update an existing challenge (Admin only)

```json
{"openapi":"3.0.3","info":{"title":"Exploration Games API","version":"1.0.0"},"tags":[{"name":"Challenges","description":"Challenge creation and management for missions"}],"servers":[{"url":"https://exploration-games.decentraland.org","description":"Production server"},{"url":"https://exploration-games.decentraland.zone","description":"Development server"}],"security":[],"paths":{"/api/challenges/{id}":{"patch":{"tags":["Challenges"],"summary":"Update a challenge","description":"Update an existing challenge (Admin only)","operationId":"updateChallenge","parameters":[{"name":"id","in":"path","description":"Challenge ID (UUID)","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"description":{"type":"string","description":"Challenge description"},"gameId":{"type":"string","format":"uuid","description":"Associated game ID"},"missionId":{"type":"string","format":"uuid","description":"Associated mission ID"},"targetLevel":{"type":"integer","minimum":1,"description":"Required level to complete challenge"},"data":{"type":"object","description":"Challenge conditions","additionalProperties":true}},"required":["description","gameId","missionId","targetLevel"]}}}},"responses":{"204":{"description":"Challenge updated successfully"},"400":{"description":"Invalid request or challenge not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message"},"message":{"type":"string","description":"Detailed error description"}}}}}}}}}}}
```
