Create a Person

Creates a new Person.

Access control

Endpoints

Creating a new Person is possible via these endpoints:

MethodPathAuthentication
POST
/people/jwtJSON Web Token
POST
/people/keyAPI Key & Secret

Request body

PropertyTypeDescription
imgstringAn image data-uri to store with this Person
imperialbooleanWhether this Person prefers imperial measurements (true) or not (false)
namestringA name for the Person
notesstringUser notes for the person
measiesobjectThe measurements for this person
publicstringThe name of the design this Pattern is an instance of

Response status codes

Possible status codes for these endpoints are:

Status codeDescription
201
success
400
the request was malformed
401
the request lacks authentication
403
authentication failed
500
server error
NOTE

If the status code is not

201
the error property in the response body should indicate the nature of the problem.

Response body

ValueTypeDescription
resultStringEither success or error
errorStringWill give info on the nature of the error. Only set if an error occurred.
person.idNumberThe ID of the Person
person.createdAtStringDate string indicating the moment the Person was created
person.imgStringThe URL to the image stored with this Person
person.nameStringThe name of the Person
person.notesStringThe notes stored with the Person
person.userIdNumberThe ID of the user who created the Person
person.measiesObjectThe measurements of the Person
person.publicBooleanIndicates whether the Person is publicly accessible or not
person.updatedAtStringDate string indicating the last time the Person was updated

Example request

Javascript
const person = await axios.post(
  'https://backend.freesewing.org/people/jwt',
  {
    name: "Someone",
    notes: "These are some notes",
    measies: {
      "chest": 930,
      "neck": 360
    },
    public: true,
    imperial: false,
    img: "data:image/png;base64,iVBORw0KGgoAAAANSUhEU...truncated"
  },
  {
    headers: {
      Authorization: `Bearer ${token}`
    }
  }
)

Example response

JSON
201
{
  "result": "success",
  "person": {
    "id": 27,
    "createdAt": "2022-11-19T17:36:41.342Z",
    "img": "https://cdn.sanity.io/images/hl5bw8cj/production/a1565c8c6c70cfe7ea0fdf5c65501cd885adbe78-200x187.png",
    "imperial": false,
    "name": "Someone",
    "notes": "These are some notes",
    "userId": 12,
    "measies": {
      "chest": 930,
      "neck": 360
    },
    "public": true,
    "updatedAt": "2022-11-19T17:36:41.342Z"
  }
}