# 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** `/v2/AttributeSets`
- **GET** `/v2/AttributeSets({id})`
- **GET** `/v2/AttributeSets({id})/Products`
- **GET** `/v2/AttributeSets/$metadata`

### 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:**
```http
GET /v2/AttributeSets HTTP/1.1
X-API-KEY: your-api-key-here
```

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

### 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" }
          ]
        }
      ]
    }
  ]
}
```

### Required attributes
These attributes must always be present in their respective layout:
| Layout | Required attribute IDs |
| --- | --- |
| `productLayout` | `typ_id`, `prod_ref`, `prod_title`, `cat_ref`, `prod_stat`, `prod_description`, `prod_image`, `prod_tags` |
| `variantLayout` | `frmt_stat`, `prod_ref`, `frmt_ref`, `frmt_tags` |

### Responses
1. **201 Created** — The `Location` header points to the new resource: `/v2/AttributeSets({id})`. The response body contains the created attribute set (`CreateAttributeSet2Response`).
2. **400 Bad Request** — Missing body, missing `name`, duplicate name, or layout validation failure.
3. **401 Unauthorized** — Missing or invalid tenant identifier.
4. **500 Internal Server Error** — Unexpected technical error.

### Delete Attribute Set
- **DELETE** `/v2/AttributeSets({id})`
- Requires a valid API key in the `X-API-KEY` header.  
- Query Parameters: 
  | Parameter | Required | Description |
  | --- | --- | --- |
  | `deleteAssociatedProductsAndVariants` | ❌ No | When `true`, products and variants associated to the attribute set are deleted along with it.
  
### Example:
**Request:**
```http
DELETE /v2/AttributeSets(7)?deleteAssociatedProductsAndVariants=false HTTP/1.1
X-API-KEY: your-api-key-here
```

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

## Conclusion
The Sales Layer API allows for a high degree of customization and automation in managing catalog-related data, making it a powerful tool for developers and businesses.
