# Sales Layer Catalog REST API (2.0.0)

The Sales Layer Catalog REST API provides programmatic access to the catalog data managed in Sales Layer.

Use this reference to retrieve, filter, create, update, or delete products, variants, categories, attribute sets, custom entities, metadata, and changelog records. These endpoints support synchronization, enrichment, publishing, reporting, and other integration workflows across ecommerce platforms, ERPs, marketplaces, DAM systems, supplier systems, and internal tools.

Start with metadata endpoints when your integration needs to discover available fields and relationships, use pagination and filtering for large reads, and rely on changelogs for incremental synchronization whenever possible.

## Attribute Sets

### Operations

- `get /AttributeSets`
- `get /AttributeSets({attributeSetIdentifier})`
- `get /AttributeSets({attributeSetIdentifier})/Products`
- `get /AttributeSets/$metadata`

### Request

Returns all attribute sets defined for the tenant, each including its name, identifier, and form layout configuration for Products and Variants (`ProductLayout`, `VariantLayout`).

**See also:** A legacy OData-style version of this endpoint is available at `GET /AttributeSets`.

### Authentication

Requires a valid API key in the `X-API-KEY` header.

### Response

**200 OK** — `GetAttributeSetsResponse` containing the list of attribute sets.

### Error Responses

- **401 Unauthorized** — Missing or invalid tenant identifier.
- **500 Internal Server Error** — Unexpected technical error.

### Example

**Request:**

```
GET /v2/AttributeSets HTTP/1.1
X-API-KEY: your-api-key-here
```

**Response:**

```
HTTP/1.1 200 OK
Content-Type: application/json
```

### Responses

1. 200
2. 401
3. 500

```json
{
  "@readLink": "string",
  "@nextLink": "string",
  "@deltaLink": "string",
  "@context": "string",
  "value": null,
  "@count": 0
}
```

### Create Attribute Set

#### Operations

- `post /v2/AttributeSets`

### Request Body

| Field | Required | Description |
| --- | --- | --- |
| `name` | ✅ Yes | Unique name for the attribute set within the tenant. |
| `productLayout` | ❌ No | Form layout for Products. Defaults to the standard layout when omitted. |
| `variantLayout` | ❌ No | Form layout for Variants. When omitted, no Variant layout is created (it can be added later via `PATCH`). |

### Layout Structure

Each layout is a JSON document with a `sections` array. Each section has a `title` and a `rows` array. Each row has a `fields` array and an optional divider (`dividerType`, `dividerTitle`). Each field carries an `attributeId` and a `size`.

```json
{
  "sections": [
    {
      "title": "General",
      "rows": [
        {
          "fields": [
            { "attributeId": "prod_title", "size": "half" },
            { "attributeId": "prod_ref",   "size": "half" }
          ]
        },
        {
          "dividerType": "normal",
          "dividerTitle": "Details",
          "fields": [
            { "attributeId": "prod_description", "size": "row" }
          ]
        }
      ]
    }
  ]
}
```

### Response

**201 Created** — The `Location` header points to the new resource: `/v2/AttributeSets({id})`. The response body contains the created attribute set (`CreateAttributeSet2Response`).

### Error Responses

- **400 Bad Request** — Missing body, missing `name`, duplicate name, or layout validation failure.
- **401 Unauthorized** — Missing or invalid tenant identifier.
- **500 Internal Server Error** — Unexpected technical error.

### Update Attribute Set

#### Operations

- `patch /v2/AttributeSets({id})`

### Request Body

All fields are optional. Omitted (null) fields are left unchanged. When a layout is supplied it fully replaces the currently stored layout.

| Field | Description |
| --- | --- |
| `name` | New unique name for the attribute set. |
| `productLayout` | Replacement form layout for Products. |
| `variantLayout` | Form layout for Variants. |

### Response

**200 OK** — The updated attribute set.

### Error Responses

- **400 Bad Request** — Invalid `id`, missing body, or layout validation failure.
- **401 Unauthorized** — Missing or invalid tenant identifier.
- **404 Not Found** — No attribute set with the given identifier exists for this tenant.
- **500 Internal Server Error** — Unexpected technical error.

### Delete Attribute Set

#### Operations

- `delete /v2/AttributeSets({id})`

### Query Parameters

| Parameter | Required | Description |
| --- | --- | --- |
| `deleteAssociatedProductsAndVariants` | ❌ No | When `true`, products and variants associated to the attribute set are deleted along with it. |

### Response

- **200 OK** — Attribute set deleted; the response body summarises the operation.
- **204 No Content** — Nothing to delete.

### Error Responses

- **400 Bad Request** — `id` is not a positive integer or the request is otherwise invalid.
- **401 Unauthorized** — Missing or invalid tenant identifier.
- **404 Not Found** — No attribute set with the given identifier exists for this tenant.
- **500 Internal Server Error** — Unexpected technical error.
