Link Resources with References
Connect your resources and fetch related data in one API call. Use reference fields to link articles to authors, products to categories, or any resources that belong together — then retrieve them with the populate parameter.
What are Reference Fields?
Reference fields create associations between resources in different collections:
- Reference — Links to a single resource in another collection
- Relation — Links to multiple resources in another collection
Common use cases include:
- Author field on articles pointing to a Users collection
- Category field on products pointing to a Categories collection
- Related articles linking to other articles in the same collection
Reference fields are different from strict reference which creates a parent-child ownership relationship. Use regular references when resources can exist independently.
Prerequisites
Before creating reference fields, you need:
- Two collections — one to hold the reference field, another as the target
- At least one published resource in the target collection
- Appropriate permissions to modify schemas in the target environment
Step 1 – Create the Target Collection
First, create the collection that will be referenced. For this example, we'll create a Users collection:
- Open your environment in the FoxNose dashboard.
- Click Database in the sidebar.
- Click Add collection and configure:
| Field | Value |
|---|---|
| Collection Name | Users |
| Collection Alias | users |
| Collection Type | Collection |
- Add fields to the schema (e.g.,
name,nickname). - Click Publish version to activate the schema.
- Add at least one resource to the Users collection.
Step 2 – Add Reference Field to Source Collection
Now add a reference field to the collection that will link to Users:
- Navigate to the source collection (e.g., Comments).
- Switch to the Schema tab.
- Click Add field and select Reference as the field type.
- Configure the reference field:
| Field | Description | Example |
|---|---|---|
| Field Name | Display name | Author |
| Field Key | API identifier | author |
| Target Collection | Collection to reference | Users |
- Click Add field to add the reference.
- Click Publish version to apply the schema changes.
Step 3 – Set Reference Values
When editing a resource with a reference field:
- Navigate to the source collection and open a resource.
- Find the reference field (e.g., Author).
- Use the dropdown to search and select a resource from the target collection.
- Save and publish the resource.
The reference stores the target resource's key internally (e.g., b5qarwj6we70).
Step 4 – Connect Collections to Flux API
For the populate feature to work, both collections must be connected to your Flux API:
- Go to Delivery → Flux API in the sidebar.
- Select your API.
- In the Connected Collections tab, ensure both the source collection (Comments) and target collection (Users) are connected.
- Enable both List/Search and Get Resource access methods for each collection.
If the target collection isn't connected to the API, the populate feature will silently return just the resource key instead of the expanded object.
Step 5 – Use Populate in API Requests
By default, reference fields return only the target resource's key:
GET /content/articles/{article_key}/comments
{
"results": [
{
"_sys": { "key": "6en834phv3uj", "folder": "comments" },
"data": {
"body": "Great article!",
"author": "b5qarwj6we70"
}
}
]
}
Add populate=author to expand the reference into the full object:
GET /content/articles/{article_key}/comments?populate=author
{
"results": [
{
"_sys": { "key": "6en834phv3uj", "folder": "comments" },
"data": {
"body": "Great article!",
"author": {
"name": "Alice Johnson",
"nickname": "alice_j"
}
}
}
]
}
Populate Multiple Fields
Populate multiple reference fields by separating them with commas:
GET /content/articles?populate=author,category
Nested Population
Populate nested references using dot notation (up to 3 levels deep):
GET /content/articles?populate=author.company,category.parent
This expands:
- The
authorreference, then the author'scompanyreference - The
categoryreference, then the category'sparentreference
Population Limits
| Limit | Value | Notes |
|---|---|---|
| Depth | 3 levels | Deeper paths are ignored |
| Response size | ~1 MiB | Reduce populate fields if exceeded |
Reference vs Strict Reference
| Feature | Reference | Strict Reference |
|---|---|---|
| Relationship | Association | Ownership |
| Independence | Resources exist independently | Child requires parent |
| API URLs | Separate endpoints | Nested under parent |
| Use case | Author on article | Comments on article |
Choose Reference when:
- Resources can exist without each other
- You need many-to-many relationships
- Resources are managed independently
Choose Strict Reference when:
- Child has no meaning without parent
- You want nested URL structure
- Child lifecycle depends on parent
Best Practices
- Connect all referenced collections to your Flux API before using populate
- Use specific populate paths — only request fields you need to minimize response size
- Consider response size — deeply nested population can create large responses
- Cache populated responses — they require additional database lookups
Next Step
References work great for associations where both sides can exist independently. But what about true ownership — where a child resource has no meaning without its parent? Comments belong to articles. Order items belong to orders.