# 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`

## Attribute Sets v2

### Operations

- `get /v2/AttributeSets`
- `post /v2/AttributeSets`
- `get /v2/AttributeSets({id})`
- `patch /v2/AttributeSets({id})`
- `delete /v2/AttributeSets({id})`

## Get Attribute Sets

### Request

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

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

### Response

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

### 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
```

## Create Attribute Set

### 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.   |
| `variantLayout`   | ❌ No    | Form layout for Variants. When omitted, no Variant layout is created. |

### Response

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

### Example

**Request:**
```
POST /v2/AttributeSets HTTP/1.1
X-API-KEY: your-api-key-here
Content-Type: application/json

{ "name": "Electronics" }
```

**Response:**
```
HTTP/1.1 201 Created
Location: /v2/AttributeSets(7)
```

## Update Attribute Set

### Request Body
All fields are optional. Omitted (null) fields are left unchanged.

| 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.

### Example

**Request:**
```
PATCH /v2/AttributeSets(1) HTTP/1.1
X-API-KEY: your-api-key-here
Content-Type: application/json

{ "name": "Electronics v2" }
```

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

## Delete Attribute Set

### Request
Deletes the attribute set identified by `id` (a positive integer). The tenant's default attribute set cannot be deleted.

### Response
- **200 OK** — Attribute set deleted; the response body summarizes the operation.
- **204 No Content** — Nothing to delete (idempotent success).

### Example

**Request:**
```
DELETE /v2/AttributeSets(7)?deleteAssociatedProductsAndVariants=false HTTP/1.1
X-API-KEY: your-api-key-here
```

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

## Metadata

Operators can also use the following actions related to metadata for more comprehensive data management:

- `get /$metadata`

This provides metadata about the API endpoints available.

## Error Responses

- **400 Bad Request** – Invalid request parameters or body.
- **401 Unauthorized** – Missing or invalid tenant identifier.
- **404 Not Found** – Resource not found.
- **500 Internal Server Error** – Unexpected error.
