# Add a collection

`POST /shop/collections` · Rivier · shop

Add a collection.

- Scope: shop:admin
- Mcp: rivier_shop_collection_create
- Sdk: shop.collection.create
- Cli: shop collection create

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "slug": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9-]{0,62}$"
    },
    "kind": {
      "type": "string",
      "enum": [
        "manual",
        "rule"
      ],
      "default": "manual"
    },
    "rule": {
      "type": "object",
      "properties": {
        "match": {
          "type": "string",
          "enum": [
            "all",
            "any"
          ],
          "default": "all"
        },
        "conditions": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "field": {
                "type": "string",
                "pattern": "^(price|stock|on_sale|in_stock|name|slug|tag|attribute:[a-z][a-z0-9_]{0,39})$"
              },
              "op": {
                "type": "string",
                "enum": [
                  "eq",
                  "neq",
                  "gte",
                  "lte",
                  "gt",
                  "lt",
                  "contains",
                  "in"
                ]
              },
              "value": {
                "anyOf": [
                  {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 200
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  },
                  {
                    "type": "array",
                    "items": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 200
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "maxItems": 50
                  }
                ]
              }
            },
            "required": [
              "field",
              "op",
              "value"
            ],
            "additionalProperties": false
          },
          "minItems": 1,
          "maxItems": 10
        }
      },
      "required": [
        "conditions"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "name",
    "slug"
  ],
  "additionalProperties": false
}
```

## Responses

- `201`: Success
- `400`: The request was malformed
- `401`: No valid credential
- `403`: The credential lacks the scope, origin or address
- `429`: Over the key's rate limit; see Retry-After

## Example

```sh
curl -X POST 'https://api.rivier.ai/shop/collections' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string",
  "slug": "string"
}'
```
