# Create Category Attribute

Adds a custom attribute to the Category definition and places it on the category form. The
attribute's identifier is derived from its `title` and reported back.
## Request Body
The body is the attribute. Its `type` says which kind it is, and which fields it takes beyond
the ones every attribute has:
| `type` | Fields |
|  --- | --- |
| `shortText`, `longText`, `number`, `boolean`, `url`, `date` | `isLocalized` |
| `table` | `isLocalized`, `templates` |
| `checklist` | `isSingleSelect`, `options` (at least one) |
| `image` | `isLocalized`, `requiredVariants`, `additionalVariants`, `linkingPattern` |
| `file` | `isLocalized`, `linkingPattern` |
| `relatedItems` | `targetEntityIdentifier` (mandatory), `itemLimit`, `pickerDisplayAttributes`, `labelAttributes` |

Every attribute takes `title` (mandatory), `isFormReadonly`, `titleTranslations`, and where
it goes on the form: `pageTitle` (left out, the last page) and `fieldSize` (`quarter`,
`half`, `threeQuarters` or `row`; left out, `row`). `attributeSet` is for Products and
Variants only: Categories refuse it.
## Response
**201 Created** — the attribute as created, under `value`.
## Example

```http
POST /Metadata/Categories/attributes HTTP/1.1
X-API-KEY: your-api-key-here
Content-Type: application/json
            
{ "type": "shortText", "title": "Box material" }
```

Endpoint: POST /Metadata/Categories/attributes
Version: 2.0.0

## Description:

  - `Request Body` ()
    The body is the attribute. Its `type` says which kind it is, and which fields it takes beyond
the ones every attribute has: | `type` | Fields |
|  --- | --- |
| `shortText`, `longText`, `number`, `boolean`, `url`, `date` | `isLocalized` |
| `table` | `isLocalized`, `templates` |
| `checklist` | `isSingleSelect`, `options` (at least one) |
| `image` | `isLocalized`, `requiredVariants`, `additionalVariants`, `linkingPattern` |
| `file` | `isLocalized`, `linkingPattern` |
| `relatedItems` | `targetEntityIdentifier` (mandatory), `itemLimit`, `pickerDisplayAttributes`, `labelAttributes` | Every attribute takes `title` (mandatory), `isFormReadonly`, `titleTranslations`, and where
it goes on the form: `pageTitle` (left out, the last page) and `fieldSize` (`quarter`,
`half`, `threeQuarters` or `row`; left out, `row`). `attributeSet` is for Products and
Variants only: Categories refuse it.

  - `Response` ()
    **201 Created** — the attribute as created, under `value`.

  - `Example` ()
    ```http
POST /Metadata/Categories/attributes HTTP/1.1
X-API-KEY: your-api-key-here
Content-Type: application/json
            
{ "type": "shortText", "title": "Box material" }
```

## Header parameters:

  - `X-API-KEY` (string)
    Tenant's API key (required)

## Request body:

  - `application/json` (unknown)
    The attribute to create

## Request fields (application/json):

  - `type` (string, required)
    Enum: "shortText", "longText", "number", "boolean", "url", "date", "table", "checklist", "imagePack", "file", "linkItems"

  - `title` (string)
    Mandatory. The attribute's title in the tenant's default language; its identifier is derived
from it.

  - `isFormReadonly` (boolean)
    Whether the form renders it read-only. It stays writable through the write operations.

  - `pageTitle` (string)
    The page of the form it is placed on, by title. Left out, the last page.

  - `fieldSize` (string)
    How wide its field is on that page. Left out, a full row.
    Enum: "quarter", "half", "threeQuarters", "row"

  - `titleTranslations` (array)
    What it is called in the tenant's other languages.

  - `titleTranslations.language` (string)

  - `titleTranslations.text` (string)

  - `attributeSet` (object)
    Which form of an entity with one per attribute set (Products, Variants) a request is made from.

  - `attributeSet.id` (integer)
    The attribute set whose form is selected. Left out, the default form: it belongs to no attribute
set. A sent value is read as given, `0` included, and refused when it names no attribute set.

  - `attributeSet.addToEveryAttributeSet` (boolean)
    Whether every other form of the entity receives the attribute too, under the page of the same title
as the one it is on in the selected form.

  - `isLocalized` (boolean)
    Whether it holds one value per language. Only accepted for a type that can.

  - `isLocalized` (boolean)
    Whether it holds one table per language.

  - `templates` (array)
    The table an item starts from, per language. Left out, none.

  - `templates.language` (string)

  - `templates.rows` (array)

  - `isSingleSelect` (boolean)
    Whether only one option may be picked at a time.

  - `options` (array)
    The complete set of options, in the order they are offered. At least one.

  - `options.identifier` (string)

  - `options.translations` (array)

  - `isLocalized` (boolean)
    Whether it holds one set of images per language.

  - `requiredVariants` (array)
    What is different about the platform's three. Left out, they are created as the platform declares them.

  - `requiredVariants.code` (string)

  - `requiredVariants.quality` (integer)

  - `requiredVariants.fit` (string)
    Enum: "cropToFill", "fitInside"

  - `requiredVariants.title` (string)

  - `requiredVariants.outputFormat` (string)
    Enum: "mostSuitable", "jpg", "png", "gif", "webp"

  - `additionalVariants` (array)
    The tenant's own variants, beyond the platform's three.

  - `additionalVariants.title` (string)

  - `additionalVariants.width` (integer)

  - `additionalVariants.height` (integer)

  - `additionalVariants.quality` (integer)

  - `additionalVariants.fit` (string)
    Enum: "cropToFill", "fitInside"

  - `additionalVariants.outputFormat` (string)
    Enum: "mostSuitable", "jpg", "png", "gif", "webp"

  - `linkingPattern` (string)
    The formula images are linked by. Left out, it links nothing; an empty formula is a formula,
and refused.

  - `isLocalized` (boolean)
    Whether it holds one set of files per language.

  - `linkingPattern` (string)
    The formula files are linked by. Left out, it links nothing; an empty formula is a formula,
and refused.

  - `targetEntityIdentifier` (string)
    Mandatory. The entity whose items it links.

  - `itemLimit` (integer)
    How many items one item may link. `0`, or left out, is no limit.

  - `pickerDisplayAttributes` (array)
    The picker's columns beyond the target's reference. Left out, the reference alone.

  - `labelAttributes` (array)
    The label's attributes beyond the target's reference. Left out, the reference alone.

  - `type` (string)
    Enum: "longText"

  - `type` (string)
    Enum: "number"

  - `type` (string)
    Enum: "boolean"

  - `type` (string)
    Enum: "url"

  - `type` (string)
    Enum: "date"

  - `type` (string)
    Enum: "table"

  - `type` (string)
    Enum: "checklist"

  - `type` (string)
    Enum: "imagePack"

  - `type` (string)
    Enum: "file"

  - `type` (string)
    Enum: "linkItems"

## Request examples:

  - `A short text attribute` (unknown)

  - `A checklist with its options` (unknown)

## Response 201:

  - `201` (unknown)
    Created

## Response 201 fields (application/json):

  - `@readLink` (string)

  - `@editLink` (string)

  - `@etag` (string)

  - `@navigationLinks` (array)

  - `@navigationLinks.uri` (string)

  - `@associationLinks` (array)

  - `@associationLinks.uri` (string)

  - `@context` (string)

  - `value` (any)

## Response 400:

  - `400` (unknown)
    Bad Request

## Response 400 fields (application/json):

  - `validationFailures` (object)

## Response 401:

  - `401` (unknown)
    Unauthorized

## Response 401 fields (application/json):

  - `message` (string)

  - `request_id` (string)

## Response 403:

  - `403` (unknown)
    Forbidden

## Response 403 fields (application/json):

  - `message` (string)

  - `request_id` (string)

## Response 500:

  - `500` (unknown)
    Internal Server Error

## Response 500 fields (application/json):

  - `error` (string)

  - `details` (any)

## Response 201 examples:

  - `The short text attribute, as created` (unknown)

  - `The checklist, as created` (unknown)

## Response 400 examples:

  - `The attribute names no type` (unknown)

  - `A field size REST does not know` (unknown)

  - `An attribute set sent to Categories` (unknown)

