POST /users

Registrace nového uživatele do systému

application/json

Body Required

  • username string Required

    Uživatelské jméno

  • email string(email) Required

    Emailová adresa uživatele (unique)

  • password string(password) Required

    Heslo uživatele

    Minimum length is 8.

  • role string

    Uživatelské role

    Values are user or admin. Default value is user.

Responses

  • 201 application/json

    Uživatel úspěšně vytvořen

    Hide response attributes Show response attributes object
    • id
    • username string
    • email string
  • 400 application/json

    Chyba v požadavku klienta

    Hide response attributes Show response attributes object
    • code string
    • message string
  • 409 application/json

    Konflikt - email již existuje

    Hide response attributes Show response attributes object
    • code string
    • message string
  • 422 application/json

    Validační chyba (chybný formát dat)

    Hide response attributes Show response attributes object
    • code string
    • message string
    • errors array[object]

      Pole konkrétních chyb validace

      Hide errors attributes Show errors attributes object
      • field string

        Název chybného pole

      • message string

        Popis chyby

  • 500 application/json

    Chyba serveru

    Hide response attributes Show response attributes object
    • code string
    • message string
POST /users
curl \
 --request POST 'https://api.mstonjek.cz/v1/users' \
 --header "Content-Type: application/json" \
 --data '{"username":"mr-robot","email":"mr-robot@evilcorp.com","password":"string","role":"user"}'
Request examples
{
  "username": "mr-robot",
  "email": "mr-robot@evilcorp.com",
  "password": "string",
  "role": "user"
}
Response examples (201)
{
  "id": "8d3f7e7a-6a6b-4b99-9b52-6f9d7d2a0a11",
  "username": "petr-jisa",
  "email": "mr@jisa.com"
}
Response examples (400)
{
  "code": "BAD_REQUEST",
  "message": "Neplatný formát dat v těle požadavku."
}
Response examples (409)
{
  "code": "CONFLICT",
  "message": "Uživatel s touto e-mailovou adresou již existuje."
}
Response examples (422)
{
  "code": "VALIDATION_FAILED",
  "message": "Vstupní data obsahují chyby.",
  "errors": [
    {
      "field": "email",
      "message": "Emailová adresa není platná."
    }
  ]
}
Response examples (500)
{
  "code": "INTERNAL_SERVER_ERROR",
  "message": "Server momentálně nedostupný"
}