POST children - ocariot/api-gateway GitHub Wiki

Description

Register a new children.

Permissions:

  • Only Admin user can do this.

Scope

children:create

URL

POST https://localhost/v1/children

Request body

{
  "username": "BR9999",
  "password": "mys3cr3tp4ss",
  "institution_id": "5a62be07de34500146d9c624",
  "gender": "male",
  "age": 11
}

Curl example

curl -X POST "https://localhost/v1/children" -H "accept: application/json" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d "{"username":"BR9999","password":"mys3cr3tp4ss","institution_id":"5a62be07de34500146d9c624","gender":"male","age":11}"

Response body

  • 201 Child saved sucessfully.

    {
      "id": "5db1cf6c099ed31587a74cf4",
      "username": "BR99999",
      "institution_id": "5a62be07de34500146d9c624",
      "gender": "male",
      "age": 11
    }
    
  • 400 Validation errors

    • Invalid JSON format

    • Invalid institution id

    • Unregistered institution

    • Missing fields

      • Example
      {
        "code": 400,
        "message": "Required fields were not provided...",
        "description": "username, password, institution, gender, age are required!"
      }
      
    • Empty string

      • Example
      {
        "code": 400,
        "message": "One or more request fields are invalid...",
        "description": "Username must have at least one character!"
      }
      
    • Invalid string

      • Example
      {
        "code": 400,
        "message": "One or more request fields are invalid...",
        "description": "username must be a string!"
      }
      
    • Invalid gender

      {
        "code": 400,
        "message": "One or more request fields are invalid...",
        "description": "The names of the allowed genders are: male, female."
      }
      
    • Invalid age

      {
        "code": 400,
        "message": "One or more request fields are invalid...",
        "description": "Provided age is not a valid number!" || "Age cannot be less than or equal to zero!"
      }
      
  • 401 Unauthorized Error

  • 403 Permission Error

  • 409 Conflict Error

  • 429 Too Many Requests Error

  • 500 Internal Server Error