# Collections API

## Get Collections

> Retrieves a list of available collections. Optionally filter by catalog UUID.

```json
{"openapi":"3.1.0","info":{"title":"Dynamic Mockups API","version":"1.0"},"servers":[{"url":"https://app.dynamicmockups.com/api/v1"}],"security":[{"apiKeyAuth":[]}],"components":{"securitySchemes":{"apiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","description":"API key required for authentication."}}},"paths":{"/collections":{"get":{"summary":"Get Collections","description":"Retrieves a list of available collections. Optionally filter by catalog UUID.","operationId":"getCollections","parameters":[{"in":"header","name":"Accept","required":true,"schema":{"type":"string","enum":["application/json"]},"description":"The request must accept JSON responses."},{"in":"header","name":"x-api-key","required":true,"schema":{"type":"string"},"description":"API key required for authentication."},{"in":"query","name":"catalog_uuid","required":false,"schema":{"type":"string"},"description":"Optional UUID of the catalog to filter collections by."},{"in":"query","name":"include_all_catalogs","required":false,"schema":{"type":"boolean"},"description":"Optional parameter to include collections from all catalogs. If false or omitted, only collections from the default catalog are returned. Set to true to fetch from all catalogs."}],"responses":{"200":{"description":"A list of collections retrieved successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"uuid":{"type":"string","description":"The UUID of the collection."},"name":{"type":"string","description":"The name of the collection."},"mockup_count":{"type":"integer","description":"The number of mockups in this collection."},"created_at":{"type":"string","format":"date-time","description":"The creation time of the collection."},"updated_at":{"type":"string","format":"date-time","description":"The last update time of the collection."},"created_at_timestamp":{"type":"integer","description":"The creation time of the collection in UNIX timestamp format."},"updated_at_timestamp":{"type":"integer","description":"The last update time of the collection in UNIX timestamp format."}}}},"success":{"type":"boolean","description":"Indicates if the operation was successful."},"message":{"type":"string","description":"A message about the operation."}}}}}},"400":{"description":"Bad request due to invalid input parameters."},"401":{"description":"Unauthorized request, invalid or missing API key."}}}}}}
```

## Create Collection

> Creates a new collection.

```json
{"openapi":"3.1.0","info":{"title":"Dynamic Mockups API","version":"1.0"},"servers":[{"url":"https://app.dynamicmockups.com/api/v1"}],"security":[{"apiKeyAuth":[]}],"components":{"securitySchemes":{"apiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","description":"API key required for authentication."}}},"paths":{"/collections":{"post":{"summary":"Create Collection","description":"Creates a new collection.","operationId":"createCollection","parameters":[{"in":"header","name":"Accept","required":true,"schema":{"type":"string","enum":["application/json"]},"description":"The request must accept JSON responses."},{"in":"header","name":"x-api-key","required":true,"schema":{"type":"string"},"description":"API key required for authentication."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string","description":"The name of the collection to create."},"catalog_uuid":{"type":"string","nullable":true,"description":"Optional UUID of the catalog to place this collection in. If not provided, uses the default catalog."}}}}}},"responses":{"200":{"description":"Collection created successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"id":{"type":"integer","description":"The ID of the newly created collection."},"uuid":{"type":"string","description":"The UUID of the newly created collection."},"workspace_id":{"type":"integer","description":"The workspace ID this collection belongs to."},"catalog_id":{"type":"integer","description":"The catalog ID this collection belongs to."},"name":{"type":"string","description":"The name of the collection."},"slug":{"type":"string","description":"The URL-friendly slug of the collection."},"is_published":{"type":"integer","description":"Whether the collection is published (1 = yes, 0 = no)."},"created_at":{"type":"string","format":"date-time","description":"The creation time of the collection."},"updated_at":{"type":"string","format":"date-time","description":"The last update time of the collection."}}},"success":{"type":"boolean","description":"Indicates if the operation was successful."},"message":{"type":"string","description":"A message about the operation."}}}}}},"400":{"description":"Bad request due to invalid input parameters."},"401":{"description":"Unauthorized request, invalid or missing API key."}}}}}}
```

Export OpenAPI specification for Collections API

{% file src="<https://1410134351-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXeuL34FauPTZ6yb0wAep%2Fuploads%2FDeg7VAHNRQQSCGIVvZ4m%2Fcollections_api.json?alt=media&token=176c4028-fb5e-4a5d-9d2c-615beddced40>" %}

### Example Use case

Let's say you need to render images for all tea mugs with your company logo on them, but there's a problem: you have more than 100 mug mockups, and you have mugs for coffee, tea, and oatmeal.

Without collections, you would need to hardcode more than 30 mockup UUIDs manually for each tea mug.

The best way to achieve flexibility and render only mugs that are designed for the tea is to create a collection of "Tea mugs", put all tea mug mockups inside that collection, and call [Get Mockups API](https://docs.dynamicmockups.com/api-reference/get-mockups-api) with an optional `collection_uuid` filter.

Now that you have all the tea mug mockups retrieved, you can easily call [Render API](https://docs.dynamicmockups.com/api-reference/render-api) for each tea mug mockup and render an image.
