Update a Pattern

Updates an existing Pattern.

Access control

Endpoints

Updating an existing Pattern is possible via these endpoints:

MethodPathAuthentication
PUT
/patterns/:id/jwtJSON Web Token
PUT
/patterns/:id/keyAPI Key & Secret

Request URL

The URL should contain the ID of the Pattern you wish to remove. It replaces the :id placeholder in the endpoints listed above.

Request body

PropertyTypeDescription
dataobjectAny additional data to store with the pattern
designstringThe name of the design this Pattern is an instance of
imgobjectAn image data-uri to store with this Pattern
namestringA name for the Pattern
notesstringUser notes for the pattern
personobjectThe ID of the person to associate with this pattern
settingsobjectThe settings object to (re-)create the Pattern

Response status codes

Possible status codes for these endpoints are:

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

If the status code is not

200
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.
pattern.idNumberThe ID of the Pattern
pattern.createdAtStringDate string indicating the moment the pattern was created
pattern.dataObjectAny additional data that was stored with Pattern data
pattern.designStringThe name of the design of which this Pattern is an instance
pattern.imgStringThe URL to the image stored with this Pattern
pattern.nameStringThe name of the Pattern
pattern.notesStringThe notes stored with the Pattern
pattern.personIdNumberThe ID of the Person for whom the Pattern was created
pattern.publicBooleanIndicates whether the Pattern is publicly accessible or not
pattern.settingsObjectThe settings used to (re-)create the Pattern
pattern.userIdNumberThe ID of the user who created the Pattern
pattern.updatedAtStringDate string indicating the last time the pattern was updated

Example request

Javascript
const udpate = await axios.put(
  'https://backend.freesewing.org/patterns/10/jwt',
  {
    data: {
      some: 'new value',
    }
    public: false,
  },
  {
    headers: {
      Authorization: `Bearer ${token}`
    }
  }
)

Example response

JSON
200
{
  "result": "success",
  "pattern": {
    "id": 10,
    "createdAt": "2022-11-19T16:29:33.346Z",
    "data": {
      "some": "new value"
    },
    "design": "aaron",
    "img": "https://cdn.sanity.io/images/hl5bw8cj/production/a1565c8c6c70cfe7ea0fdf5c65501cd885adbe78-200x187.png",
    "name": "Just a test",
    "notes": "These are my notes",
    "personId": 17,
    "public": false,
    "settings": {
      "sa": 5
    },
    "userId": 10,
    "updatedAt": "2022-11-19T16:43:39.223Z"
  }
}