Managing CMS Collections and Items

An end-to-end guide for creating and managing CMS content programmatically.

This page covers how to programmatically manage your Webflow CMS content. You’ll learn how to:

  1. Create a collection and define its schema.
  2. Populate the collection with content and perform CRUD operations on those items.
  3. Publish a collection and its items.
Generate schemas and content with AI

Use the MCP Server to create a Collection and its Items from a single natural language prompt. Go from a simple description to a fully populated Collection in seconds.


1. Creating a collection

The first step in managing your content is to create a collection, which serves as a blueprint for your items. This process involves getting your site_id, defining a schema, and then creating the collection via the API. To learn more about collections, see the Collections Reference.

1

Get your site ID

Every collection is associated with a specific Webflow site. You’ll need your site_id to create a collection. You can find this by calling the List Sites endpoint and locating the site you want to work with in the response.

GET
/v2/sites
1from webflow import Webflow
2
3client = Webflow(
4 access_token="YOUR_ACCESS_TOKEN",
5)
6client.sites.list()
2

Define the collection schema

Next, you’ll define the schema for your collection. This includes the displayName for the collection, the singularName for its items, the slug for the collection, and an array of fields.

Default fields

Each collection will always have the following fields in its schema:

  • name - The name of the item
  • slug - The slug of the item. Slugs should be unique, and formatted as all lowercase with no spaces. Any spaces will be converted to ”-”.

Custom fields

You can add additional custom fields to the collection. Each field will have its own type, displayName, slug, and other properties to configure its behavior. A collection’s schema can have up to 60 fields. To see the different field types and their properties, see the Field Types & Item Values Reference.

Here is an example of a schema for a “Hitchhiker’s Guide” collection that includes various field types:

Example collection schema
1{
2 "displayName": "Guide Entries",
3 "singularName": "Guide Entry",
4 "slug": "guide-entries",
5 "fields": [
6 {
7 "type": "PlainText",
8 "displayName": "Entry Title",
9 "slug": "entry-title",
10 "isRequired": true
11 },
12 {
13 "type": "RichText",
14 "displayName": "Entry HTML",
15 "slug": "entry-html"
16 },
17 {
18 "type": "Image",
19 "displayName": "Illustration Image",
20 "slug": "illustration-image"
21 },
22 {
23 "type": "Number",
24 "displayName": "Importance Level",
25 "slug": "importance-level"
26 },
27 {
28 "type": "Switch",
29 "displayName": "Is Essential",
30 "slug": "is-essential"
31 },
32 {
33 "type": "Reference",
34 "displayName": "Related Entry",
35 "slug": "related-entry",
36 "metadata": {
37 "collectionId": "7f15043107e2fc95644e93807ee25dd6"
38 }
39 },
40 {
41 "type": "Option",
42 "displayName": "Item Type",
43 "slug": "item-type",
44 "metadata": {
45 "options": [
46 {"name": "Survival Gear"},
47 {"name": "Gadget"},
48 {"name": "Other"}
49 ]
50 }
51 }
52 ]
53}
Field Validations

When defining a field in the Webflow UI, you can also specify validations for the field. Currently, the API doesn’t support field validations. All validations must be specified in the Webflow UI.

3

Create the collection

With your site_id and schema, you can now create the collection by making a POST request to the Create Collection endpoint.

POST
/v2/sites/:site_id/collections
1from webflow import ReferenceField, ReferenceFieldMetadata, StaticField, Webflow
2
3client = Webflow(
4 access_token="YOUR_ACCESS_TOKEN",
5)
6client.collections.create(
7 site_id="580e63e98c9a982ac9b8b741",
8 display_name="Blog Posts",
9 singular_name="Blog Post",
10 slug="posts",
11 fields=[
12 StaticField(
13 is_required=True,
14 type="PlainText",
15 display_name="Title",
16 help_text="The title of the blog post",
17 ),
18 StaticField(
19 is_required=True,
20 type="RichText",
21 display_name="Content",
22 help_text="The content of the blog post",
23 ),
24 ReferenceField(
25 is_required=True,
26 type="Reference",
27 display_name="Author",
28 help_text="The author of the blog post",
29 metadata=ReferenceFieldMetadata(
30 collection_id="23cc2d952d4e4631ffd4345d2743db4e",
31 ),
32 ),
33 ],
34)

Adding advanced field types

When defining a collection’s schema, Option and Reference fields require a metadata object to be configured.

The Option field allows you to create a predefined list of choices for an item, which can be selected from a dropdown menu in the CMS.

When creating an Option field, you must provide a metadata object containing an options array. Each object in the array defines a choice with a name. Webflow will automatically generate an id for each option.

1{
2 "type": "Option",
3 "displayName": "Item Type",
4 "slug": "item-type",
5 "metadata": {
6 "options": [
7 {"name": "Survival Gear"},
8 {"name": "Gadget"},
9 {"name": "Other"}
10 ]
11 }
12}

The Reference and Multi-Reference fields allow you to link a collection item to one or more other items from another collection.

When creating Reference or Multi-Reference fields, you must provide a metadata object containing the collectionId of the collection you intend to reference.

1

Get the Collection ID

First, you need the id of the collection you want to reference. You can get this by calling the List Collections endpoint and finding the target collection in the response.

GET
/v2/sites/:site_id/collections
1from webflow import Webflow
2
3client = Webflow(
4 access_token="YOUR_ACCESS_TOKEN",
5)
6client.collections.list(
7 site_id="580e63e98c9a982ac9b8b741",
8)
2

Define the Field

Use the retrieved collectionId in the metadata object when defining your Reference or Multi-Reference field in a “Create Collection” or “Create Field” request.

1{
2 "type": "Reference",
3 "displayName": "Related Entry",
4 "slug": "related-entry",
5 "metadata": {
6 "collectionId": "7f15043107e2fc95644e93807ee25dd6" // ID of the collection to reference
7 }
8}

2. Managing collection items

Once your collection is created, you can begin to populate it with items. The following sections demonstrate how to perform CRUD (Create, Read, Update, Delete) operations on the items in your new collection.

When creating collection items, you can use the staged or live endpoints to manage the item’s publishing state. For more details on publishing options when creating an item, see the Publishing Guide.

Creating an item

1

Get the collection ID

First, you need the id of the collection you want to create an item for. The Create Collection response will include the collection’s id. However, you can also get the collection ID by calling the List Collections endpoint and finding the collection in the response.

GET
/v2/collections/:collection_id
1from webflow import Webflow
2
3client = Webflow(
4 access_token="YOUR_ACCESS_TOKEN",
5)
6client.collections.get(
7 collection_id="580e63fc8c9a982ac9b8b745",
8)
2

Create a collection item

To add an item, send a POST request to the Create Collection Item endpoint. The fieldData object in the request body must match the schema you defined for the collection.

POST
/v2/collections/:collection_id/items
1from webflow import (
2 CollectionItemPostSingle,
3 CollectionItemPostSingleFieldData,
4 Webflow,
5)
6
7client = Webflow(
8 access_token="YOUR_ACCESS_TOKEN",
9)
10client.collections.items.create_item(
11 collection_id="580e63fc8c9a982ac9b8b745",
12 request=CollectionItemPostSingle(
13 is_archived=False,
14 is_draft=False,
15 field_data=CollectionItemPostSingleFieldData(
16 name="Pan Galactic Gargle Blaster Recipe",
17 slug="pan-galactic-gargle-blaster",
18 ),
19 ),
20)

Populating advanced field types

Most fields accept simple values like strings or numbers. However, fields like Option, and Reference require specific identifiers. The sections below explain how to get the correct IDs to populate these fields when creating or updating an item.

Option fields require the unique id of the choice, which is defined in the collection’s schema.

1

Get collection details

To find the id for each option, retrieve the collection’s schema by calling the Get Collection Details endpoint.

GET
/v2/collections/:collection_id
1from webflow import Webflow
2
3client = Webflow(
4 access_token="YOUR_ACCESS_TOKEN",
5)
6client.collections.get(
7 collection_id="580e63fc8c9a982ac9b8b745",
8)
2

Find the option ID

In the response, locate your Option field within the fields array. The validations.options array will contain each choice with its name and id.

1// Snippet from GET /v2/collections/{collection_id} response
2{
3 "fields": [
4 {
5 "type": "Option",
6 "slug": "item-type",
7 "validations": {
8 "options": [
9 { "name": "Survival Gear", "id": "66f6e966c9e1dc700a857ca3" },
10 { "name": "Gadget", "id": "66f6e966c9e1dc700a857ca4" },
11 { "name": "Other", "id": "66f6e966c9e1dc700a857ca5" }
12 ]
13 }
14 }
15 ]
16}
3

Use the option ID

When creating or updating an item, pass the id of your chosen option as a string in the fieldData.

1{
2 "fieldData": {
3 "item-type": "66f6e966c9e1dc700a857ca3" // ID for "Survival Gear"
4 }
5}

Reference and Multi-Reference fields link an item to one or more other collection items. To create a reference, you need the id of the item you want to link to.

To reference a collection item, the collection must be published to the site.

1

Find the item IDs

To get the id of the item you want to reference, call the List Items endpoint on the collection that contains the target item. You can filter the results to find the specific items you need.

2

Use the item IDs

For a Reference field, pass the item id as a string. For a Multi-Reference field, pass an array of item id strings.

1{
2 "fieldData": {
3 "related-entry": "42b720ef280c7a7a3be8cabe", // Single item reference
4 "mentioned-in": [
5 "62b720ef280c7a7a3be8cabd",
6 "62c880ef281c7b7b4cf9dabc"
7 ] // Multi-item reference
8 }
9}

Listing, updating, and deleting items

1

List collection items

To get a list of all items in a collection, send a GET request to the List Collection Items endpoint.

GET
/v2/collections/:collection_id/items
1from webflow import Webflow
2
3client = Webflow(
4 access_token="YOUR_ACCESS_TOKEN",
5)
6client.collections.items.list_items(
7 collection_id="580e63fc8c9a982ac9b8b745",
8)

Pagination

When listing items, the response will be paginated. You can control the pagination using the limit and offset query parameters.

  • limit: The maximum number of items to return (up to 100).
  • offset: The number of items to skip from the beginning of the list.

By default, the API will return up to 100 items. If a collection contains more than 100 items, you can use offset to retrieve additional pages of results. For example, to get the second page of 100 items, you would set offset to 100.

The response will include a pagination object with total, limit, and offset fields, which you can use to loop through the pages of results.

Example pagination object
1// Snippet from GET /v2/collections/{collection_id}/items response
2{
3 "items": [
4 // ... item data ...
5 ],
6 "pagination": {
7 "total": 250,
8 "limit": 100,
9 "offset": 100
10 }
11}
2

Update a collection item

To modify an existing item, you’ll first need its id. You can get the item’s id by calling the List Collection Items endpoint and finding the item in the response.

Then, use the PATCH endpoint to Update a Collection Item. You only need to provide the fields you want to change in the fieldData object.

PATCH
/v2/collections/:collection_id/items/:item_id
1from webflow import CollectionItemPatchSingleFieldData, Webflow
2
3client = Webflow(
4 access_token="YOUR_ACCESS_TOKEN",
5)
6client.collections.items.update_item(
7 collection_id="580e63fc8c9a982ac9b8b745",
8 item_id="580e64008c9a982ac9b8b754",
9 is_archived=False,
10 is_draft=False,
11 field_data=CollectionItemPatchSingleFieldData(
12 name="Pan Galactic Gargle Blaster Recipe",
13 slug="pan-galactic-gargle-blaster",
14 ),
15)
3

Delete a collection item

To remove an item from a collection, you’ll need its id. You can get the item’s id by calling the List Collection Items endpoint and finding the item in the response.

Then, use the DELETE endpoint to Delete a Collection Item.

DELETE
/v2/collections/:collection_id/items/:item_id
1from webflow import Webflow
2
3client = Webflow(
4 access_token="YOUR_ACCESS_TOKEN",
5)
6client.collections.items.delete_item(
7 collection_id="580e63fc8c9a982ac9b8b745",
8 item_id="580e64008c9a982ac9b8b754",
9)

3. Publishing a collection

Once you’ve created your collection and its items, you can publish the collection. This will make the collection and its items visible on your live site. Additionally, this allows the collection’s items to be referenced by other collections.

To publish a collection or any collection items, you’ll need to publish the entire site. You can publish the site by calling the Publish Site endpoint.

POST
/v2/sites/:site_id/publish
1from webflow import Webflow
2
3client = Webflow(
4 access_token="YOUR_ACCESS_TOKEN",
5)
6client.sites.publish(
7 site_id="580e63e98c9a982ac9b8b741",
8 custom_domains=["660c6449dd97ebc7346ac629", "660c6449dd97ebc7346ac62f"],
9 publish_to_webflow_subdomain=False,
10)

Next steps

Once you have created your collections and populated them with content, you can explore more advanced topics like publishing and localization.