Pattern

Patterns represent the products that are available for users to generate drafts from. They contain, among other information, the list of options to customise the product and the measurements required to generate a draft. Be aware that different patterns will require different sets of measurements.

List all patterns

Get the list of all patterns that are available to the current user.

API Request

GET https://api.bespokify.com/v2/patterns

Request parameters

Parameter Type Required Description
gender string no The gender used to filter patterns
measurementType string no The measurementType used to filter patterns. Possible values: body, final
ids number array no List of IDs to filter patterns by
search string no The text to search patterns' names and descriptions by
orderBy string no The field to order patterns by. Default is updatedAt
sort string no The order to sort patterns in. Possible values: asc, desc. Default: desc

Example response

[
  {
    "id": 1,
    "name": "Pattern 1",
    "gender": "male",
    "description": "Example pattern",
    "updatedAt": "2018-12-29T02:43:00.331Z"
  },
  {
    "id": 2,
    "name": "Pattern 2",
    "gender": "female",
    "description": "Another example pattern",
    "updatedAt": "2019-02-19T10:56:41.331Z"
  }
]

List all patterns with their presets

Get the list of all patterns that are available to the current user along with their presets.

API Request

GET https://api.bespokify.com/v2/patterns?mode=withPresets

Request parameters

Parameter Type Required Description
gender string no The gender used to filter patterns
hasDisabledPresets boolean no true returns only patterns having at least one disabled preset along with the data for all their disabled presets. false returns only patterns having no disabled presets along with the data for all their enabled presets.
search string no The text used to search pattern and preset names

Example response

[
  {
    "id": 1,
    "name": "Pattern 1",
    "presets": []
  },
  {
    "id": 2,
    "name": "Pattern 2",
    "presets": [
      {
        "id": "5ba68d6d-9fc3-4ded-a97c-9f29b96efcd3",
        "name": "Default",
        "enabled": true
      }
    ]
  }
]

List all references

Get the list of all references of a pattern by its ID.

API Request

GET https://api.bespokify.com/v2/patterns/{id}/refs

Request parameters

Parameter Type Required Description
id integer yes The pattern ID
all boolean no If set to false, only the latest reference for each unique reference name will be returned. Otherwise, all references are returned. Default: false
search string no The text used to search pattern reference names
orderBy string no The field to order pattern references by. Possible values: name, createdAt. Default: createdAt
sort string no The order to sort patterns in. Possible values: asc, desc. Default: desc

Example response

[
  {
    "id": "40176ec6397c4d065564393fd8d7915790a07834",
    "name": "master",
    "commitHash": "e69421dc00aa9941058bbdff295ed8c5e4aeee33",
    "parentCommitHash": "318cd8359e18c75e22cf9f5929cc6ac6b706e3b8",
    "createdAt": "2018-12-27T03:16:29.706Z"
  }
]

Get latest data

Get the data of the latest master reference of a pattern.

This is an alias of Get data of pattern reference using the latest Master Ref ID.

API Request

GET https://api.bespokify.com/v2/patterns/{id}

Request parameters

Parameter Type Required Description
id integer yes The pattern ID

Get data of pattern reference

API Request

GET https://api.bespokify.com/v2/patterns/{id}/refs/{refId}

Request parameters

Parameter Type Required Description
id integer yes The pattern ID
refId string yes The pattern reference ID

Example response

{
  "id": "92974b5991c71f3630ef67bfbd5570088ff3a8d0",
  "name": "master",
  "patternId": 1,
  "patternName": "Male Business Shirt",
  "patternDescription": "Male Business Shirt Project",
  "gender": "male",
  "options": [
    {
      "id": "collar",
      "type": "string",
      "enum": ["regular", "wide", "buttonDown"]
    },
    {
      "id": "necklineAdj",
      "type": "number",
      "enum": [-0.5, 0, 0.5]
    },
    {
      "id": "bustEase",
      "type": "number",
      "step": 1,
      "suffix": "cm",
      "default": 12,
      "maximum": 16,
      "minimum": 5
    }
  ],
  "measurements": {
    "body": [
      {
        "group": "neck",
        "items": ["mbMidNeckGirth", "mbCollarGirth"],
        "required": true
      },
      {
        "group": "waist",
        "items": ["mbWaistGirth"],
        "required": false
      }
    ],
    "final": [
      {
        "group": "neck",
        "items": ["mfCollarGirth"],
        "required": true
      },
      {
        "group": "bust",
        "items": ["mfBustGirth"],
        "required": true
      }
    ]
  },
  "seams": {
    "armhole": 0.5,
    "attachment": 1
  },
  "garmentMeasurements": ["neckline", "shoulderWidth"],
  "materials": ["shellFabric", "interlining"],
  "bodyShapes": [
    {
      "id": "shoulderSlope",
      "type": "string",
      "enum": ["14Deg", "17Deg", "regular", "23Deg", "26Deg"]
    }
  ]
}

options

These are the available options to customise a product. In the example shown above, you can set the shirt's collar to be Regular, Wide, or Button-down.

An option always has as least two attributes: id and type. A pattern cannot have more than one option with the same ID. An option type be either string or number.

Options can either be an array of choices (enum), or a value within a numerical range (like the bustEase example). To understand more about these different formats, visit the Option types page.

bodyShapes

These are the available body shape features to support the pattern calculation. This section is not required (by default, a standard body shape is used for draft generation), but if body shape values are specified, they will be taken into account during a draft generation.

The format for bodyShapes is the same as options. Visit the Option types page to understand more.

measurements

The two measurement types we support are: body and final.

Parameter Type Description
group string The name of the measurement group, e.g. neck, waist, etc.
items array The supported measurements for this group. Exactly one of these must be selected for draft generation
required boolean false means the input measurement value for this group is optional, but if it is present, the fit of the output will be better
{
  "measurements": {
    "body": [
      {
        "group": "neck",
        "items": ["mbMidNeckGirth", "mbCollarGirth"],
        "required": true
      },
      {
        "group": "waist",
        "items": ["mbWaistGirth"],
        "required": false
      }
    ],
    "final": [
      {
        "group": "neck",
        "items": ["mfCollarGirth"],
        "required": true
      },
      {
        "group": "bust",
        "items": ["mfBustGirth"],
        "required": true
      }
    ]
  }
}

Using the information provided by the pattern in the example above, we can put together a couple of request examples.

This is a valid request:

{
  "measurements": {
    "mbMidNeckGirth": 36.17,
    "mbWaistGirth": 77.61
  }
}

This is an invalid request:

{
  "measurements": {
    "mbMidNeckGirth": 36.17,
    "mbCollarGirth": 39.17,
    "mbWaistGirth": 77.61
  }
}

Two values were provided for the neck group (mbMidNeckGirth and mbCollarGirth). Only one must be provided.

Get latest schema

Get the schema of the most recent master reference of a pattern.

This is an alias of Get schema of pattern reference using the latest Master Ref ID.

API Request

GET https://api.bespokify.com/v2/patterns/{id}/schema

Request parameters

Parameter Type Required Description
id integer yes The pattern ID

Get schema of pattern reference

API Request

GET https://api.bespokify.com/v2/patterns/{id}/refs/{refId}/schema

Request parameters

Parameter Type Required Description
id integer yes The pattern ID
refId string yes The pattern reference ID

Example response

{
  "if": {
    "properties": {
      "measurementType": {
        "const": "body"
      }
    }
  },
  "then": {
    "properties": {
      "measurements": {
        "allOf": [
          {
            "oneOf": [
              {
                "required": ["mbHeight"]
              }
            ],
            "errorMessage": {
              "oneOf": "measurements section: Required one of these properties: mbHeight"
            }
          },
          {
            "oneOf": [
              {
                "required": ["mbMidNeckGirth"]
              },
              {
                "required": ["mbCollarGirth"]
              }
            ],
            "errorMessage": {
              "oneOf": "measurements section: Required one of these properties: mbMidNeckGirth, mbCollarGirth"
            }
          }
        ],
        "errorMessage": {
          "patternProperties": "measurements section: All properties should have number value"
        },
        "patternProperties": {
          ".": {
            "type": "number"
          }
        }
      }
    }
  },
  "required": ["patternId", "measurementType", "measurements"],
  "properties": {
    "seams": {
      "required": ["armhole", "collar", "attachment"],
      "errorMessage": {
        "required": {
          "collar": "seams section: collar is required",
          "armhole": "seams section: armhole is required",
          "attachment": "seams section: attachment is required"
        },
        "patternProperties": "seams section: All properties should have number value",
        "additionalProperties": "seams section: Accept only these properties: armhole, collar, attachment"
      },
      "patternProperties": {
        ".": {
          "type": "number"
        }
      },
      "additionalProperties": false
    },
    "options": {
      "allOf": [
        {
          "if": {
            "required": ["pocket"],
            "properties": {
              "pocket": {
                "const": "none"
              }
            }
          },
          "then": {
            "properties": {
              "pocket.leftBreast.style": {
                "not": {}
              }
            },
            "errorMessage": {
              "properties": {
                "pocket.leftBreast.style": "options section: pocket.leftBreast.style are not allowed if have pocket.none"
              }
            }
          }
        },
        {
          "if": {
            "required": ["pocket"],
            "properties": {
              "pocket": {
                "const": "leftBreast"
              }
            }
          },
          "then": {
            "required": ["pocket.leftBreast.style"],
            "errorMessage": {
              "required": {
                "pocket.leftBreast.style": "options section: Require pocket.leftBreast.style if have pocket.leftBreast"
              }
            }
          }
        }
      ],
      "required": ["collar", "pocket", "bodyLengthAdj", "necklineAdj"],
      "properties": {
        "collar": {
          "enum": ["shortRegular", "regular", "longRegular"],
          "errorMessage": {
            "enum": "options section: collar accept only these values: shortRegular, regular, longRegular"
          }
        },
        "pocket": {
          "enum": ["none", "leftBreast"],
          "errorMessage": {
            "enum": "options section: pocket accept only these values: none, leftBreast"
          }
        },
        "necklineAdj": {
          "type": "number",
          "maximum": 5,
          "minimum": -5,
          "multipleOf": 0.5,
          "errorMessage": {
            "type": "options section: necklineAdj should be number",
            "maximum": "options section: necklineAdj should be less than 5",
            "minimum": "options section: necklineAdj should be greater than -5",
            "multipleOf": "options section: necklineAdj should be multiple of 0.5"
          }
        },
        "bodyLengthAdj": {
          "enum": [-1, 0, 1],
          "errorMessage": {
            "enum": "options section: bodyLengthAdj accept only these values: -1, 0, 1"
          }
        },
        "pocket.leftBreast.style": {
          "enum": ["buttoned", "rounded", "angled"],
          "errorMessage": {
            "enum": "options section: pocket.leftBreast.style accept only these values: buttoned, rounded, angled"
          }
        }
      },
      "errorMessage": {
        "required": {
          "collar": "options section: collar is required",
          "pocket": "options section: pocket is required",
          "necklineAdj": "options section: necklineAdj is required",
          "bodyLengthAdj": "options section: bodyLengthAdj is required"
        },
        "additionalProperties": "options section: Should not have additional properties"
      },
      "additionalProperties": false
    },
    "bodyShapes": {},
    "measurementType": {
      "enum": ["body"],
      "errorMessage": {
        "enum": "measurementType section: Accept only these values: body"
      }
    }
  },
  "errorMessage": {
    "required": {
      "patternId": "patternId is required",
      "measurements": "measurements is required",
      "measurementType": "measurementType is required"
    }
  }
}

Get latest meta-information

Get the information of the most recent master reference of a pattern.

This is an alias of Get meta-information of pattern reference using the latest Master Ref ID.

API Request

GET https://api.bespokify.com/v2/patterns/{id}/info

Request parameters

Parameter Type Required Description
id integer yes The pattern ID

Get meta-information of pattern reference

API Request

GET https://api.bespokify.com/v2/patterns/{id}/refs/{refId}/info

Request parameters

Parameter Type Required Description
id integer yes The pattern ID
refId string yes The pattern reference ID

Example response

{
  "id": "40176ec6397c4d065564393fd8d7915790a07834",
  "name": "master",
  "commitHash": "e69421dc00aa9941058bbdff295ed8c5e4aeee33",
  "parentCommitHash": "318cd8359e18c75e22cf9f5929cc6ac6b706e3b8",
  "createdAt": "2018-12-27T03:16:29.706Z"
}