# Problems

Endpoints for managing problems

## \[ADMIN] Get all problems

> Retrieves a list of all problems.

```json
{"openapi":"3.1.0","info":{"title":"Codebattles backend","version":"0.1.0"},"tags":[{"name":"Problems","description":"Endpoints for managing problems"}],"servers":[{"url":"http://localhost:8080","description":"Generated server url"}],"security":[{"JWT":[]}],"components":{"securitySchemes":{"JWT":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"UnauthorizedResponse":{"type":"object","description":"Response returned when the user is not authenticated.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}},"AccessDeniedResponse":{"type":"object","description":"Response returned when the user does not have permission to access the requested resource.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}},"ConflictResponse":{"type":"object","description":"Response returned when the conflict in data.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}},"InternalServerErrorResponse":{"type":"object","description":"Response returned when an unexpected error occurs on the server.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}}}},"paths":{"/api/problems":{"get":{"tags":["Problems"],"summary":"[ADMIN] Get all problems","description":"Retrieves a list of all problems.","operationId":"getAll_1","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"object"}}}},"401":{"description":"Unauthorized","content":{"*/*":{"schema":{"$ref":"#/components/schemas/UnauthorizedResponse"}}}},"403":{"description":"Forbidden","content":{"*/*":{"schema":{"$ref":"#/components/schemas/AccessDeniedResponse"}}}},"409":{"description":"Conflict","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ConflictResponse"}}}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"$ref":"#/components/schemas/InternalServerErrorResponse"}}}}}}}}}
```

## \[ADMIN] Create a new problem

> Creates a new problem using the provided data.

```json
{"openapi":"3.1.0","info":{"title":"Codebattles backend","version":"0.1.0"},"tags":[{"name":"Problems","description":"Endpoints for managing problems"}],"servers":[{"url":"http://localhost:8080","description":"Generated server url"}],"security":[{"JWT":[]}],"components":{"securitySchemes":{"JWT":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"CreateProblemDto":{"type":"object","properties":{"name":{"type":"string","description":"Name of the problem"},"description":{"type":"string","description":"Description of the problem"},"inData":{"type":"string","description":"Input data for the problem"},"outData":{"type":"string","description":"Expected output data for the problem"},"tests":{"type":"string","description":"Test cases for the problem (JSON)"}},"required":["description","examples","inData","name","outData","tests"]},"ProblemDto":{"type":"object","properties":{"id":{"type":"integer","format":"int64","description":"Unique identifier of the problem"},"name":{"type":"string","description":"Name of the problem"},"description":{"type":"string","description":"Description of the problem"},"inData":{"type":"string","description":"Input data for the problem"},"outData":{"type":"string","description":"Expected output data for the problem"},"public":{"type":"boolean","description":"Indicates if the problem is public"}},"required":["description","examples","id","inData","name","outData"]},"UnauthorizedResponse":{"type":"object","description":"Response returned when the user is not authenticated.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}},"AccessDeniedResponse":{"type":"object","description":"Response returned when the user does not have permission to access the requested resource.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}},"ConflictResponse":{"type":"object","description":"Response returned when the conflict in data.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}},"InternalServerErrorResponse":{"type":"object","description":"Response returned when an unexpected error occurs on the server.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}}}},"paths":{"/api/problems":{"post":{"tags":["Problems"],"summary":"[ADMIN] Create a new problem","description":"Creates a new problem using the provided data.","operationId":"create_1","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateProblemDto"}}},"required":true},"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ProblemDto"}}}},"401":{"description":"Unauthorized","content":{"*/*":{"schema":{"$ref":"#/components/schemas/UnauthorizedResponse"}}}},"403":{"description":"Forbidden","content":{"*/*":{"schema":{"$ref":"#/components/schemas/AccessDeniedResponse"}}}},"409":{"description":"Conflict","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ConflictResponse"}}}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"$ref":"#/components/schemas/InternalServerErrorResponse"}}}}}}}}}
```

## \[ADMIN] Get problem by ID

> Retrieves a problem by its ID. Required admin role

```json
{"openapi":"3.1.0","info":{"title":"Codebattles backend","version":"0.1.0"},"tags":[{"name":"Problems","description":"Endpoints for managing problems"}],"servers":[{"url":"http://localhost:8080","description":"Generated server url"}],"security":[{"JWT":[]}],"components":{"securitySchemes":{"JWT":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"ProblemDto":{"type":"object","properties":{"id":{"type":"integer","format":"int64","description":"Unique identifier of the problem"},"name":{"type":"string","description":"Name of the problem"},"description":{"type":"string","description":"Description of the problem"},"inData":{"type":"string","description":"Input data for the problem"},"outData":{"type":"string","description":"Expected output data for the problem"},"public":{"type":"boolean","description":"Indicates if the problem is public"}},"required":["description","examples","id","inData","name","outData"]},"UnauthorizedResponse":{"type":"object","description":"Response returned when the user is not authenticated.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}},"AccessDeniedResponse":{"type":"object","description":"Response returned when the user does not have permission to access the requested resource.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}},"ConflictResponse":{"type":"object","description":"Response returned when the conflict in data.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}},"InternalServerErrorResponse":{"type":"object","description":"Response returned when an unexpected error occurs on the server.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}}}},"paths":{"/api/problems/{id}":{"get":{"tags":["Problems"],"summary":"[ADMIN] Get problem by ID","description":"Retrieves a problem by its ID. Required admin role","operationId":"getById_1","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ProblemDto"}}}},"401":{"description":"Unauthorized","content":{"*/*":{"schema":{"$ref":"#/components/schemas/UnauthorizedResponse"}}}},"403":{"description":"Forbidden","content":{"*/*":{"schema":{"$ref":"#/components/schemas/AccessDeniedResponse"}}}},"409":{"description":"Conflict","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ConflictResponse"}}}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"$ref":"#/components/schemas/InternalServerErrorResponse"}}}}}}}}}
```

## \[ADMIN] Update a problem

> Applies partial updates to a problem by its ID.

```json
{"openapi":"3.1.0","info":{"title":"Codebattles backend","version":"0.1.0"},"tags":[{"name":"Problems","description":"Endpoints for managing problems"}],"servers":[{"url":"http://localhost:8080","description":"Generated server url"}],"security":[{"JWT":[]}],"components":{"securitySchemes":{"JWT":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"JsonNode":{},"Problem":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"description":{"type":"string"},"inData":{"type":"string"},"outData":{"type":"string"},"tests":{"type":"string"}},"required":["description","examples","id","inData","name","outData","tests"]},"UnauthorizedResponse":{"type":"object","description":"Response returned when the user is not authenticated.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}},"AccessDeniedResponse":{"type":"object","description":"Response returned when the user does not have permission to access the requested resource.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}},"ConflictResponse":{"type":"object","description":"Response returned when the conflict in data.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}},"InternalServerErrorResponse":{"type":"object","description":"Response returned when an unexpected error occurs on the server.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}}}},"paths":{"/api/problems/{id}":{"patch":{"tags":["Problems"],"summary":"[ADMIN] Update a problem","description":"Applies partial updates to a problem by its ID.","operationId":"patch","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/JsonNode"}}},"required":true},"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"401":{"description":"Unauthorized","content":{"*/*":{"schema":{"$ref":"#/components/schemas/UnauthorizedResponse"}}}},"403":{"description":"Forbidden","content":{"*/*":{"schema":{"$ref":"#/components/schemas/AccessDeniedResponse"}}}},"409":{"description":"Conflict","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ConflictResponse"}}}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"$ref":"#/components/schemas/InternalServerErrorResponse"}}}}}}}}}
```

## \[ADMIN] Get problem by ID (extra fields)

> Retrieves a problem by its ID with admin-level access. Required admin role

```json
{"openapi":"3.1.0","info":{"title":"Codebattles backend","version":"0.1.0"},"tags":[{"name":"Problems","description":"Endpoints for managing problems"}],"servers":[{"url":"http://localhost:8080","description":"Generated server url"}],"security":[{"JWT":[]}],"components":{"securitySchemes":{"JWT":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"Problem":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"description":{"type":"string"},"inData":{"type":"string"},"outData":{"type":"string"},"tests":{"type":"string"}},"required":["description","examples","id","inData","name","outData","tests"]},"UnauthorizedResponse":{"type":"object","description":"Response returned when the user is not authenticated.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}},"AccessDeniedResponse":{"type":"object","description":"Response returned when the user does not have permission to access the requested resource.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}},"ConflictResponse":{"type":"object","description":"Response returned when the conflict in data.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}},"InternalServerErrorResponse":{"type":"object","description":"Response returned when an unexpected error occurs on the server.","properties":{"message":{"type":"string","description":"Detailed message about the error."},"code":{"type":"integer","format":"int32","description":"HTTP status code representing the error."}}}}},"paths":{"/api/problems/{id}/admin":{"get":{"tags":["Problems"],"summary":"[ADMIN] Get problem by ID (extra fields)","description":"Retrieves a problem by its ID with admin-level access. Required admin role","operationId":"getByIdAdmin","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"401":{"description":"Unauthorized","content":{"*/*":{"schema":{"$ref":"#/components/schemas/UnauthorizedResponse"}}}},"403":{"description":"Forbidden","content":{"*/*":{"schema":{"$ref":"#/components/schemas/AccessDeniedResponse"}}}},"409":{"description":"Conflict","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ConflictResponse"}}}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"$ref":"#/components/schemas/InternalServerErrorResponse"}}}}}}}}}
```


---

# 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.codebattles.ru/api/backend/problems.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.
