> This page is for version V1 (default).
> For other versions, use one of these documentation indexes:
> - V1 (default): https://docs.ottimate.com/v-1/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ottimate.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ottimate.com/_mcp/server.

# Catalog Entries

This section explains how to interact with catalog entries using the Ottimate SDK.

### Fetching Catalog Entries

You can retrieve a list of catalog entries for a specific company. It's also possible to filter these entries or paginate results.

```python
# main.py

# Fetch catalog entries for a company
catalog_entries = client.catalog.get_catalog_entries(
    ottimate_company_id=ottimate_company_id
)

print(f"Fetched {len(catalog_entries.results)} catalog entries.")
for entry in catalog_entries.results:
    print(f" - Catalog Entry: Ottimate ID: {entry.id} | Name: {entry.description}")
```

### Fetching Catalog Entries with Pagination

```python
# main.py

catalog_entries = client.catalog.get_catalog_entries(
    ottimate_company_id=ottimate_company_id,
    page=1,
    limit=10
)
```

### Fetching Catalog Entries with Filters

You can filter catalog entries by vendor, search term, or expand related fields.

```python
# main.py

# Filter by vendor
catalog_entries = client.catalog.get_catalog_entries(
    ottimate_company_id=ottimate_company_id,
    erp_vendor_id="sample-001"
)

# Search by term
catalog_entries = client.catalog.get_catalog_entries(
    ottimate_company_id=ottimate_company_id,
    search="test"
)

# Expand related fields
catalog_entries = client.catalog.get_catalog_entries(
    ottimate_company_id=ottimate_company_id,
    expand="prices,allowances"
)
```

### Creating a Catalog Entry

This example shows how to create a new catalog entry with required fields.

```python
# main.py

new_catalog_entry = client.catalog.post_catalog_entries(
    ottimate_company_id=ottimate_company_id,
    erp_vendor_id=erp_vendor_id,
    description=f"SDK Catalog Item {time_now}"
)

print(f"Created catalog entry with ID: {new_catalog_entry.id}")
```

### Fetching a Single Catalog Entry

You can retrieve a specific catalog entry by its ID.

```python
# main.py

fetched_entry = client.catalog.get_catalog_entries_id(
    id=catalog_entry_id
)
print(f"Fetched catalog entry: {fetched_entry}")
```

### Updating a Catalog Entry

This shows how to update an existing catalog entry, for example, to change its price or description.

```python
# main.py

updated_entry = client.catalog.patch_catalog_entries_id(
    id=catalog_entry_id,
    description=f"Updated Item {time_now}",
    price=29.99
)
print(f"Updated catalog entry price to: {updated_entry.price}")
```

### Bulk Creating Catalog Entries

You can create multiple catalog entries in a single request.

```python
# main.py

from ottimate.catalog.types.catalog_entry_bulk_create_request_entries_item import CatalogEntryBulkCreateRequestEntriesItem

entries = [
    CatalogEntryBulkCreateRequestEntriesItem(
        erp_vendor_id=erp_vendor_id,
        description=f"Bulk Item 1 {time_now}",
        catalog_unique_key=f"bulk-1-{time_now}"
    ),
    CatalogEntryBulkCreateRequestEntriesItem(
        erp_vendor_id=erp_vendor_id,
        description=f"Bulk Item 2 {time_now}",
        catalog_unique_key=f"bulk-2-{time_now}"
    ),
]

bulk_response = client.catalog.post_catalog_entries_bulk(
    ottimate_company_id=ottimate_company_id,
    entries=entries
)

print(f"Bulk created {bulk_response.success_count} catalog entries.")

# Print details of created entries
if hasattr(bulk_response, "created") and bulk_response.created:
    print("Created entries:")
    for entry in bulk_response.created:
        print(f"  - ID: {entry.get('id')}, Description: {entry.get('description')}")

# Print details of updated entries
if hasattr(bulk_response, "updated") and bulk_response.updated:
    print("Updated entries:")
    for entry in bulk_response.updated:
        print(f"  - ID: {entry.get('id')}, Description: {entry.get('description')}")

# Print details of errors
if hasattr(bulk_response, "errors") and bulk_response.errors:
    print("Failed entries:")
    for error in bulk_response.errors:
        print(f"  - Error: {error}")
```

### Bulk Creating Catalog Entries with Prices

```python
# main.py

from ottimate.catalog.types.catalog_entry_bulk_create_request_entries_item import CatalogEntryBulkCreateRequestEntriesItem

entries = [
    CatalogEntryBulkCreateRequestEntriesItem(
        erp_vendor_id=erp_vendor_id,
        description=f"Bulk Item Prices {time_now}",
        catalog_unique_key=f"bulk-prices-{time_now}",
        prices=[
            {"price": 19.99, "effective_date": "2024-01-01"},
            {"price": 21.99, "effective_date": "2024-06-01"},
        ]
    ),
]

bulk_response = client.catalog.post_catalog_entries_bulk(
    ottimate_company_id=ottimate_company_id,
    entries=entries
)
```