This document is a detailed reference to Contentstack’s Content Delivery API.
The Content Delivery API is used to retrieve content from your Contentstack account and deliver it to your web or mobile properties. If you are looking for APIs to manage content, you should use the Content Management API.
Our APIs serve content via a powerful and robust content delivery network (CDN). Multiple datacenters around the world store a cached copy of your content. When a page request is made, the content is delivered to the user from the nearest server. This greatly accelerates content delivery and reduces latency.
Warning: The Content Delivery API (CDA), available at cdn.contentstack.io, should be used to only fetch content from Contentstack. We recommend users to NOT use this endpoint for any other content management activities, because all content management activities using this endpoint will be blocked soon.
The CDN includes many points of presence (POPs) located in high-density internet exchange regions around the world. These POPs are continually expanding to ensure faster and more reliable content delivery.
Warning: We only support version 3 on the CDN. If you're still using version 2 (which we recommend you should not), switch to the CDN version for even faster loading. And, we have a URL size limitation of 8KB on API Requests that hit our CDN services. Any Request URL that goes above this size limit will receive the 414 - URI Too Long error response. Please make sure you limit the size of your API Requests.
Contentstack provides SDKs, API references, getting started guides, and sample apps for popular programming languages and platforms. These resources help you build applications and fetch content efficiently using the Content Delivery API.
The SDKs are read-only and are designed to retrieve published content from the nearest server via the global CDN.
You will find a list of all the available SDKs under the Development Resources and SDKs section.
We provide SDKs for the following platforms:
The process for building sample apps and working with the SDKs differ based on the platform. We have covered them in detail in their respective sections.
Since the Content Delivery APIs (CDAs) are private APIs, you will need to pass the following as HTTP headers to make authorized CDA requests:
The API Key is a unique key assigned to each stack. The Delivery Token is a read-only credential that you can create for different environments of your stack.
While Content Delivery API requests may work with Access Token (instead of Delivery Token), we strongly recommend that you not use it, since we have already deprecated Access Token for new stacks.
Note: The nomenclature for the use of delivery tokens in CDA requests will remain the same, i.e. you need to pass the value of the delivery token against the access_token key.
Note: We have deprecated the usage of Access Tokens for all stacks. We strongly recommend that you use Delivery Tokens for fetching published content via the Content Delivery API and Management Tokens for fetching draft content via the Content Management API.
To retrieve the stack API key and the delivery token of a specific publishing environment of your stack, perform the steps given below after logging into your Contentstack account:
Additional Resource: Read more about how you can create a new delivery token.
Note: Only the stack owners, developers, and admin can create delivery tokens.
Rate limiting defines the maximum number of API requests your organization can make within a specific timeframe.
By default, the rate limit for origin server requests is 100 requests per second per organization. Rate limit depends on your plan, and you can request an increase if needed.
Note: While CDN requests do not count toward rate limiting, all API requests—whether to the CDN or the origin server—count toward your organization’s overall API usage.
HTTP headers let the client and the server pass additional information with an HTTP request or response. An HTTP header consists of its case-insensitive name followed by a colon (:), then by its value.
Here’s what an HTTP response body looks like:
< x-served-by: cache-lax8631-LAX, cache-bur17525-BUR
< x-cache: MISS, HIT
< x-cache-hits: 0, 1
< x-runtime: 27ms
< age: 5182
< x-timer: S1557441707.643683,VS0,VE0Let’s understand what the above HTTP Header means:
x-served-by: cache-lax8631-LAX, cache-bur17525-BUR< x-cache: MISS, HIT< x-cache-hits: 0, 1< x-runtime: 27ms< age: 5182< x-timer: S1557441707.643683,VS0,VE0If there is something wrong with the API request, Contentstack returns an error.
Contentstack uses conventional, standard HTTP status codes for errors, and returns a JSON body containing details about the error. In general, codes in the 2xx range signify success. The codes in the 4xx range indicate error, mainly due to information provided (for example, a required parameter or field was omitted). Lastly, codes in the 5xx range mean that there is something wrong with Contentstack’s servers; it is very rare though.
Let’s look at the error codes and their meanings.
| HTTP status code | Description |
|---|---|
| 400 Bad Request | The request was incorrect or corrupted. |
| 401 Access Denied | The login credentials are invalid. |
| 403 Forbidden Error | The page or resource that is being accessed is forbidden. |
| 404 Not Found | The requested page or resource could not be found. |
| 412 Pre Condition Failed | The entered API key is invalid. |
| 422* Unprocessable Entity (also includes Validation Error and Unknown Field) | The request is syntactically correct but contains semantic errors |
| 429** Rate Limit Exceeded | The number of requests exceeds the allowed limit for the given time period. |
| 500 Internal Server Error | The server is malfunctioning and is not specific on what the problem is. |
| 502 Bad Gateway Error | A server received an invalid response from another server. |
| 504 Gateway Timeout Error | A server did not receive a timely response from another server that it was accessing while attempting to load the web page or fill another request by the browser. |
* Contentstack returns the 422 HTTP status code for an error along with the "UID is not valid" message in the response body either when an entry doesn’t exist within the stack, has been deleted from the content type, or exists within a different content type. As the entry has been deleted or unpublished, the Content Delivery Network (CDN) cannot identify the specified entry UID through the cache servers. To check whether the entry has been deleted, try retrieving the entry from CDN first. If the API request fails to retrieve the entry from CDN, then make an API request to the Origin server to check whether the entry exists.
Also, if the content type doesn't exist within the stack, Contentstack returns the 422 HTTP status code for an error along with the "UID is not valid" message in the response body.
** Here are a few use cases where you might get a 429 error:
Note: For uncached requests, the common rate limit is 100 requests per second per organization.
Contentstack offers you a Postman Collection that helps you try out our Content Delivery API. You can download this collection, connect to your Contentstack account, and try out the Content Delivery API with ease.
Learn more about how to get started with using the Postman Collection for Contenstack Content Delivery API.
Contentstack provides the OpenAPI files of the Contentstack’s Content Delivery APIs (CDA) that you can use to try out Contentstack APIs on any OpenAPI platform such as Swagger. You can download the OpenAPI JSON file of the Content Delivery API and open it on Swagger Editor to start using it.
Learn more about how to get started with using the OpenAPI files for Contenstack Content Delivery API.
Content type defines the structure or schema of a page or a section of your web or mobile property. To create content for your application, you are required to first create a content type, and then create entries using the content type.
Additional Resource: To get an idea of building your content type as per webpage’s layout, we recommend you to check out our Content Modeling guide.
You can now pass the branch header in the API request to fetch or manage modules located within specific branches of the stack.
Note: Branches is a plan-based feature that is available only in the new Contentstack interface.
Additionally, you can also set the include_branch query parameter to true to include the _branch top-level key in the response. This key specifies the unique ID of the branch where the concerned Contentstack module resides.
The Get all content types call returns comprehensive information of all the content types available in a particular stack in your account.
When executing the API call, you can add queries to extend the functionality of this API call.
Tip: If any of your content types contains a Global field and you wish to fetch the content schema of the Global field, then you need to pass theinclude_global_field_schema:true parameter. This parameter helps return the Global field's schema along with the content type schema.
To query your content types, under the Query Parameters section, insert a parameter named query and provide the query in JSON format as the value. To learn more about the queries, refer to the Queries section of the Content Delivery API doc.
Note: This API request will return a maximum of 100 content types. To retrieve the next batch of content types, make use of the skip parameter (or refer Pagination for more details).
This call returns information of a specific content type. It returns the content type schema, but does not include its entries.
A Global field is a reusable field (or group of fields) that you can define once and reuse across multiple content types within your stack. This eliminates the need to recreate the same set of fields multiple times, saving effort and ensuring consistency.
You can pass the branch header in API requests to fetch or manage modules within specific branches of the stack. Additionally, setting the include_branch query parameter to true includes the _branch key in the response, specifying the unique ID of the branch where the module resides.
Additional Resource: You can create dynamic and flexible Global Fields by nesting Global fields within a Modular Block, Global, or a Group fields.
The Get all global fields request returns comprehensive information of all the global fields available in a particular stack in your organization. If you have nested global fields, it appears in the response.
The Get a single global field request allows you to fetch comprehensive details of a specific global field.
When executing the API call, in the 'URL Parameters' section, provide the unique ID of your global field.
An entry is the actual piece of content created using one of the defined content types.
You can now pass the branch header in the API request to fetch or manage modules located within specific branches of the stack.
Note: Branches is a plan-based feature that is available only in the new Contentstack interface.
Additionally, you can also set the include_branch query parameter to true to include the _branch top-level key in the response. This key specifies the unique ID of the branch where the concerned Contentstack module resides.
The Get all entries request fetches the list of all the entries of a particular content type. It returns the content of each entry in JSON format.
Additionally, if you wish to fetch the metadata attached to each entry, then you need to pass include_metadata as a query parameter. Set this parameter to true to include the entry metadata along with all entries in the response body.
You will find the entry metadata under the _metadata key in the response. It will be associated with a specific extension UID as follows:
"_metadata": {
"extensions": {
"{extension_uid}": [{
"image_copyrights": "Contentstack Branding",
"scope": "local"
}]
}
}
If an entry is not published in a specific locale, make use of the “include_fallback=true” query parameter to fetch the published content from its fallback locale.
Note: If the fallback language of the specified locale is the master language itself, this parameter won't be applicable.
To include the publish details in the response, make use of the include_publish_details=true parameter. This will return the publishing details of the entry in every environment along with the version number that is published in each of the environments.
You can add other Queries to extend the functionality of this API call. Add a query parameter named query and provide your query (in JSON format) as the value.
When using Delivery Tokens
Passing the environment as a query parameter is optional but recommended to ensure that the CDN delivers the most recent content
Tip: This request returns only the first 100 entries of the specified content type. Refer to the Pagination section to retrieve the rest of your entries in a paginated form.
The Get a single entry request fetches a particular entry of a content type.
Tip: To get a specific version, refer to the Get a Single Entry management API. This request returns only the latest version.
Additionally, if you wish to fetch the metadata attached to each entry, then you need to pass include_metadata as a query parameter. Set this parameter to true to include the entry metadata along with all entries in the response body.
You will find the entry metadata under the _metadata key in the response. It will be associated with a specific extension UID as follows:
"_metadata": {
"extensions": {
"{extension_uid}": [{
"image_copyrights": "Contentstack Branding",
"scope": "local"
}]
}
}
If an entry is not published in a specific locale, make use of the “include_fallback=true” query parameter to fetch the published content from its fallback locale.
Note: If the fallback language of the specified locale is the master language itself, this parameter won't be applicable.
To include the publish details in the response, make use of the include_publish_details=true parameter. This will return the publishing details of the entry in every environment along with the version number that is published in each of the environments.
Note: To retrieve an entry from a particular branch, provide the branch_uid under the branch header.
You can add other Queries to extend the functionality of this API call. Add a query parameter named query and provide your query (in JSON format) as the value.
When using Delivery Tokens
Passing the environment as a query parameter is optional but recommended to ensure that the CDN delivers the most recent content
The Get information on embedded RTE objects request returns comprehensive information on all entries and/or assets embedded within the Rich Text Editor field.
If your entry contains a Rich Text Editor field and you wish to fetch the content schema of the items embedded inside the rich text, then you need to pass the include_embedded_items[]=BASE query parameter.
You can view information about the embedded objects under the _embedded_items parameter in the JSON response body.
Note: Contentstack’s Content Delivery SDKs help consume the embedded entries and assets returned in the API response. You can then render the embedded objects on the front end however required.
The Get all entries with defined taxonomies request returns comprehensive information of all the entries that contain taxonomy(ies) available in a particular stack in your organization.
To retrieve entries that match only taxonomy and term UID and belong to a specific content type.
query={
"taxonomies.taxonomy_uid" : "term_uid",
"_content_type_uid": "_content_type_uid"
}Example: If you wish to match entries with the term red from the products content type.
query={
"taxonomies.color" : "red",
"_content_type_uid": "products"
}To retrieve entries that match only taxonomy and term UID and belong to multiple content types.
query={
"taxonomies.taxonomy_uid" : "term_uid",
"_content_type_uid": { "$in" : ["_content_type_uid1", "_content_type_uid2"] }
}Example: If you wish to match entries with the term red from the products or blogs content types.
query={
"taxonomies.color" : "red",
"_content_type_uid": { "$in" : ["products", "blogs"] }
}Note: Refer to the Taxonomy section in Queries for more query filters.
Entry Variants allows you to create content variations for different audiences, languages, and marketing experiments. The key concepts include Base Entry, Entry Variant, and Variant Group. This feature streamlines personalized content management, improves consistency, and simplifies updates.
Note: The Entry Variants feature is currently available as part of an Early Access Program and may not be available to all users. For more information, you can reach out to our support team.
The Get all entry variants retrieves all variants of a given entry and their customizations.
Pass your variant UID(s) or aliases in the x-cs-variant-uid header to get all the variants applied to the entries.
Note: By default you can add up to 3 variant UIDs or aliases (comma-separated) simultaneously. The limit can vary based on your organization plan. The variant UID or alias added first takes priority and will be applied to the base entry fields. For example, if you pass UIDs for Red, Green, and Blue variants in that order, the Red variant will have the highest priority. Sample header request, x-cs-variant-uid: cs6c42daef493fb432, cs7697ce80c9bbcc3e, cs8697ce80c9bbcc4f or x-cs-variant-uid: cs_personalize_0_0, cs_personalize_0_1, cs_personalize_0_2.
You can add other queries to extend the functionality of this API call.
When using Delivery Tokens
Tip: This request returns only the first 100 entries of the specified content type. Refer to the Pagination section to retrieve the rest of your entries in a paginated form.
Error Handling
If the number of variants exceeds the configured limit:
Sample response when the show_errors=true query parameter is passed and allowed variant limit is exceeded:
{
"entries": [ ... ],
"errors": [
{
"code": "VARIANT_LIMIT_EXCEEDED",
"message": "x-cs-variant-uid should not be greater than {{your_set_limit}}",
"details": {
"provided_count": 7,
"limit": {{your_set_limit}},
"applied_count": {{your_set_limit}}
}
}
]
}The Get single entry variant request retrieves a single variant entry of a given base entry.
Pass your variant UID(s) or aliases in the x-cs-variant-uid header to get all the variants applied to the entries.
Note: By default you can add up to 3 variant UIDs or aliases (comma-separated) simultaneously. The limit can vary based on your organization plan. The variant UID or alias added first takes priority and will be applied to the base entry fields. For example, if you pass UIDs for Red, Green, and Blue variants in that order, the Red variant will have the highest priority. Sample header request, x-cs-variant-uid: cs6c42daef493fb432, cs7697ce80c9bbcc3e, cs8697ce80c9bbcc4f or x-cs-variant-uid: cs_personalize_0_0, cs_personalize_0_1, cs_personalize_0_2.
You can add other queries to extend the functionality of this API call.
When using Delivery Tokens
Tip: This request returns only the first 100 entries of the specified content type. Refer to the Pagination section to retrieve the rest of your entries in a paginated form.
Error Handling
If the number of variants exceeds the configured limit:
Sample response when the show_errors=true query parameter is passed and allowed variant limit is exceeded:
{
"entries": [ ... ],
"errors": [
{
"code": "VARIANT_LIMIT_EXCEEDED",
"message": "x-cs-variant-uid should not be greater than {{your_set_limit}}",
"details": {
"provided_count": 7,
"limit": {{your_set_limit}},
"applied_count": {{your_set_limit}}
}
}
]
}Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded in your Contentstack repository for future use. These files can be attached and used in multiple entries.
You can now pass the branch header in the API request to fetch or manage modules located within specific branches of the stack.
Note: Branches is a plan-based feature that is available only in the new Contentstack interface.
Additionally, you can also set the include_branch query parameter to true to include the _branch top-level key in the response. This key specifies the unique ID of the branch where the concerned Contentstack module resides.
The Get all assets request fetches the list of all the assets of a particular stack. It returns the content of each asset in JSON format. You can also specify the environment of which you want to get the assets.
Additionally, if you wish to fetch the metadata attached to each asset, then you need to pass include_metadata as a query parameter. Set this parameter to true to include the asset metadata along with all assets in the response body.
You will find the entry metadata under the _metadata key in the response. It will be associated with a specific extension UID as follows:
"_metadata": {
"extensions": {
"{extension_uid}": [{
"image_copyrights": "Contentstack Branding",
"scope": "local"
}]
}
}
If an asset is not published in a specific locale, make use of the include_fallback=true query parameter to fetch the published version from the fallback locale.
You can apply Queries to filter assets/entries. Add a query parameter named query and provide your query (in JSON format) as the value.
When using Delivery Tokens
The Get a single asset request fetches the latest version of a specific asset of a particular stack.
Tip: If no version is mentioned, the request will retrieve the latest published version of the asset. To get a specific version of an asset, refer to the Get a Single Asset management API.
Additionally, if you wish to fetch the metadata attached to each asset, then you need to pass include_metadata as a query parameter. Set this parameter to true to include the asset metadata along with all assets in the response body.
You will find the entry metadata under the _metadata key in the response. It will be associated with a specific extension UID as follows:
"_metadata": {
"extensions": {
"{extension_uid}": [{
"image_copyrights": "Contentstack Branding",
"scope": "local"
}]
}
}
If an asset is not published in a specific locale, make use of the include_fallback=true query parameter to fetch the published version from the fallback locale.
When using Delivery Tokens
The Sync API takes care of syncing your Contentstack data with your app and ensures that the data is always up-to-date by providing delta updates.
Note: When executing the following synchronization API Requests, you need to pass the Delivery Token as the value to the access_token parameter.
The Initial Sync request syncs the entries and assets of a stack, published on a specific environment.
Set init to ‘true’ if you want to sync all the published entries and assets. This is usually used when the app does not have any content and you want to get all the content for the first time.
Note: When executing the API request, pass the Delivery Token as the value to the access_token parameter.
Applicable parameters:
| Parameter | Values |
| content_type_uid | Enter content type UID. e.g., products This retrieves published entries of specified content type. |
| locale | Enter locale code. e.g., en-us This retrieves published entries of specific locale. |
| start_from | Enter the start date. e.g., 2018-08-14T00:00:00.000Z This retrieves published entries starting from a specific date. |
| type | Applicable values are:
If you do not specify any value, it will bring all published entries and published assets. You can pass multiple types as comma-separated values, for example, entry_published,entry_unpublished,asset_published. |
Note: If you specify any value for content_type_uid, locale, start_from, or type, the values for these parameters will remain unchanged for all subsequent sync requests.
Once you perform an initial sync, you will either get a sync_token or a pagination_token in response. These tokens don't have an expiry time.
You can use the sync_token later to perform subsequent sync, which fetches only new changes through delta updates.
If there are more than 100 records, you get a pagination_token in response. This token can be used to fetch the next batch of data. Read Sync using pagination token for more details.
When running the Initial Synchronization or the Subsequent Sync request, if the result of the sync (initial or subsequent) request exceeds 100 records you will get a pagination_token.
The Sync using pagination token request uses the pagination_token to retrieve the next batch of data (100 records) while performing the sync. You can reiterate the process until you get a sync_token.
Note: When executing the API request, pass the Delivery Token as the value to the access_token parameter.
The Subsequent Sync request is used to retrieve the updated content (i.e., published or unpublished content, or any published content that has been deleted) since the last performed complete Sync.
In this API request, you need to provide the sync_token that you received in the last complete sync process. If there are more than 100 records, you will get a pagination_token instead. This token can be used to fetch the next batch of data. Refer the Sync using pagination token section for more details.
Tip: Once you have performed the Initial Sync process, you do not need to perform it again. For retrieving the subsequent delta changes, use the sync_token received either in the Initial Sync process or the previous Subsequent Sync requests to sync new changes. Also, when executing the API request, pass the Delivery Token as the value to the access_token parameter.
Contentstack provides certain queries that you can use to fetch filtered results. Queries can be used across all CDA API requests.
You can now pass the branch header in the API request to fetch or manage modules located within specific branches of the stack.
Note: Branches is a plan-based feature that is available only in the new Contentstack interface.
Additionally, you can also set the include_branch query parameter to true to include the _branch top-level key in the response. This key specifies the unique ID of the branch where the concerned Contentstack module resides
Taxonomy, simplifies the process of organizing content in your system, making it effortless to find and retrieve information.
You can retrieve filtered entries using taxonomy through two different endpoints:
Get all entries for a specific taxonomy that satisfy the given conditions provided in the "$in" query.
Your query should be as follows:
query={"taxonomies.taxonomy_uid" : { "$in" : ["term_uid1" , "term_uid2" ] }}Example: If you want to retrieve entries with the color taxonomy applied and linked to the term red and/or yellow.
query={"taxonomies.color" : { "$in" : ["red" , "yellow" ] }}Get all entries for a specific taxonomy that satisfy at least one of the given conditions provided in the “$or” query.
Your query should be as follows:
query={
"$or": [
{ "taxonomies.taxonomy_uid_1" : "term_uid1" },
{ "taxonomies.taxonomy_uid_2" : "term_uid2" }
]
}Example: If you want to retrieve entries with either the color or size taxonomy applied and linked to the terms black and small, respectively.
query={
"$or": [
{ "taxonomies.color" : "black" },
{ "taxonomies.size" : "small" }
]
}Get all entries for a specific taxonomy that satisfy all the conditions provided in the “$and” query.
Your query should be as follows:
query={
"$and": [
{ "taxonomies.taxonomy_uid_1" : "term_uid1" },
{ "taxonomies.taxonomy_uid_2" : "term_uid2" }
]
}Example: If you want to retrieve entries with the color and category taxonomies applied and linked to the terms black and mobile, respectively.
query={
"$and": [
{ "taxonomies.color" : "black" },
{ "taxonomies.category" : "mobile" }
]
}Get all entries for a specific taxonomy that if the value of the field, mentioned in the condition, exists.
Your query should be as follows:
query={"taxonomies.taxonomy_uid" : { "$exists": true }}Example: If you want to retrieve entries with the color taxonomy applied.
query={"taxonomies.color" : { "$exists": true }}Get all entries for a specific taxonomy that match a specific term and all its descendant terms, requiring only the target term and a specified level.
Note: If you don't specify the level, the default behavior is to retrieve terms up to level 10.
query={
"taxonomies.taxonomy_uid" : { "$eq_below": "term_uid", "levels" : 2}
}Example: If you want to retrieve all entries with terms nested under blue, such as navy blue and sky blue, while also matching entries with the target term blue.
query={
"taxonomies.color" : { "$eq_below": "blue" }
}Get all entries for a specific taxonomy that match all of their descendant terms by specifying only the target term and a specific level.
Note: If you don't specify the level, the default behavior is to retrieve terms up to level 10.
query={
"taxonomies.taxonomy_uid" : { "$below": "term_uid", "levels" : 2}
}Example: If you want to retrieve all entries containing terms nested under blue, such as navy blue and sky blue, but exclude entries that solely have the target term blue.
query={
"taxonomies.color" : { "$below": "blue" }
}Get all entries for a specific taxonomy that match a specific term and all its ancestor terms, requiring only the target term and a specified level.
Note: If you don't specify the level, the default behavior is to retrieve terms up to level 10.
query = {
"taxonomies.taxonomy_uid": { "$eq_above": "term_uid", "levels": 2 }
}Example: If you want to obtain all entries that include the term navy_blue and its parent term blue.
query = {
"taxonomies.color": { "$eq_above": "navy_blue"}
}Get all entries for a specific taxonomy that match only the parent term(s) of a specified target term, excluding the target term itself. You can also specify a specific level.
Note: If you don't specify the level, the default behavior is to retrieve terms up to level 10.
query = {
"taxonomies.taxonomy_uid": { "$above": "term_uid", "levels": 2 }
}Example: If you wish to match entries with all the terms above the target term navy_blue, excluding navy_blue itself.
query = {
"taxonomies.color": { "$above": "navy_blue" }
}Get entries containing the field values matching the condition in the query.
This query will work for both entries as well as assets.
Example: In the Products content type, you have a field named Title ("uid":"title") field. If, for instance, you want to retrieve all the entries in which the value for the Title field is 'Redmi 3S', you can set the parameters as:
{"title": "Redmi 3S"}
Let’s consider another example. You want to retrieve all the entries that have their start date as 8th December, 2017. Now, you need to set this parameter with the date in the ISO Date format as below:
{ "start_date": "2017-12-08T00:00:00.000Z" }
This will give you all the entries where the start date is 8th December, 2017.
Get entries where the value of a field within a Group field matches the condition in the query. This query is specifically for fields that are part of the Group field.
This query will work for entries only.
Example: In the Products content type, we have a Group field named Bank Offers ("uid":"bank_offers"). And, within this Group field, we have a subfield named Card Type ("uid":"card_type"). If, for instance, you want to retrieve the entries in which the value for the Card Type field is 'Debit Card', you can use the following value in the ‘query’ parameter:
{"bank_offers.card_type": "Debit Card"}
Get entries where the value of a field within a Modular Blocks field matches the condition in the query. This query is specifically for fields that are part of the Modular Blocks field.
This query will work for entries only.
Example: In the Products content type, we have a Modular Blocks field named Additional Info ("uid":"additional_info") that contains the Deals ("uid":"deals") block. And, within this Deals block, we have a field named Deal Name ("uid":"deal_name"). If, for instance, you want to retrieve the entries in which the value for the Deal Name field is 'Christmas Deal', you can use the following value in the query parameter:
{"additional_info.deals.deal_name": "Christmas Deal"}
Get all the entries in which the value of a field does not match the value provided in the condition.
This query will work for both entries as well as assets.
Example: In the Product content type, you have a field named Price in USD. Now, you need to retrieve all entries where the value of this field not equal to '146' for this field. The parameter can be used as:
{ "price_in_usd": { "$ne": 146 } }
This will give you all the entries that have the value for Price in USD not set to '146'.
Let’s consider another example. You want to retrieve all the entries except the ones that have their start date as 8th December, 2017. Now, you need to set this parameter with the date in the ISO Date format as below:
{ "start_date": { "$ne": "2017-12-08T00:00:00.000Z" } }
This will give you all the entries where the start date is not 8th December, 2017.
Get entries where the value of a field does not match the value provided in the condition. This query is specifically for fields that are part of the Group field.
This query will work for entries only.
Example: In the Products content type, we have a Group field named Bank Offers ("uid":"bank_offers"). And, within this Group field, we have a subfield named Card Type ("uid":"card_type"). If, for instance, you want to retrieve the entries in which the value for the Card Type field is NOT 'Debit Card', use the following value in the query parameter:
{"bank_offers.card_type": {"$ne": "Debit Card"}}
Get entries where the value of a field within the Modular Blocks field does not match the condition in the query. This query is specifically for fields that are part of any block within a Modular Block field.
This query will work for entries only.
Example: In the Products content type, we have a Modular Group field named Additional Info ("uid":"additional_info") that contains the Deals ("uid":"deals") block. And, within this Deals block, we have a field named Deal Name ("uid":"deal_name"). If, for instance, you want to retrieve the entries in which the value for the Deal Name field is NOT 'Christmas Deal', use the following value in the query parameter:
{"additional_info.deals.deal_name": {"$ne": "Christmas Deal"}}
Get entries in which the value of a field matches to any of the given values. This parameter will compare field values of entries to that of the values provided in the condition.
This query will work for entries only.
Example: In the Product content type, you have a field named Price in USD. Now, you need to retrieve all the entries where value of this field is one among the given set of values. The query fired using the '$in' parameter is given below:
{ "price_in_usd": { "$in": [ 101, 749 ] } }
This will retrieve all the entries that have the value of Price in USD field set to '101' or 749'.
Get entries where the value of a field, within a Group field, matches any of the given values. This parameter will compare field values of entries to that of the values provided in the condition. This query is specifically for fields that are part of the Group field.
This query will work for entries only.
Example: In the Products content type, we have a Group field named Bank Offers ("uid":"bank_offers"). And, within this Group field, we have a subfield named Card Type ("uid":"card_type"). If, for instance, you want to retrieve the entries in which the values for the Card Type field are ‘Credit Card’ and 'Debit Card', use the following value in the query parameter:
{"bank_offers.card_type": {"$in": ["Credit Card", "Debit Card"]}}
Get entries where the value of a field within Modular Blocks matches to any of the given values. This query is specifically for fields that are part of any block within a Modular Block field.
This query will work for entries only.
Example: In the Products content type, we have a Modular Group field named Additional Info ("uid":"additional_info") that contains the Deals ("uid":"deals") block. And, within this Deals block, we have a field named Deal Name ("uid":"deal_name"). If, for instance, you want to retrieve the entries in which the values for the Deal Name field are 'Christmas Deal’ and ‘Summer Deal', use the following value in the query parameter:
{"additional_info.deals.deal_name": {"$in": ["Christmas Deal", "Summer Deal"]}}
Get all entries in which the value of a field does not match to any of the given values. This parameter will compare field values of entries to that of the values provided in the condition, and the query will retrieve entries that have field values that does not match to any of the values provided.
This query will work for entries only.
Example: In the Product content type, you have a field named Price in USD. Now, you need to retrieve the entries where the field value does not fall in the given set. You can send the parameter as:
{ "price_in_usd": { "$nin": [ 101, 749 ] } }
This will give you all the entries that do not have the value for Price in USD set to '101' or '749'.
Get entries in which the value of a field does not match any of the values provided in the condition. This query is specifically for fields that are part of the Group field.
This query will work for entries only.
Example: In the Products content type, we have a Group field named Bank Offers ("uid":"bank_offers"). And, within this Group field, we have a subfield named Card Type ("uid":"card_type"). If, for instance, you want to retrieve the entries in which the values for the Card Type field are NOT 'Debit Card', use the following value in the query parameter:
{"bank_offers.card_type": {"$nin": ["Debit Card"]}}
Get entries where the values of the fields within Modular Blocks does not match the condition in the query. This query is specifically for fields that are part of any block within a Modular Block field.
This query will work for entries only.
Example: In the Products content type, we have a Modular Group field named Additional Info ("uid":"additional_info") that contains the Deals ("uid":"deals") block. And, within this Deals block, we have a field named Deal Name ("uid":"deal_name"). If, for instance, you want to retrieve the entries in which the values for the Deal Name field are NOT 'Christmas Deal’ and ‘Summer Deal', use the following value in the query parameter:
{ "additional_info.deals.deal_name": { "$nin": [ "Christmas Deal", "Summer Deal" ] } }
When fetching an entry, the content of referred entries that are part of the parent entry is NOT included in the Response body; you only get their UIDs. To include the content of the referred entries in your response, you need to use the include[] parameter and specify the UID of the reference field as value.The API request should be as follows: https://cdn.contentstack.io/v3/content_types/product/entries?include[]={reference_field_UID. This query will work for entries only.
Example: In the Product content type, there is a reference field called Categories, which refers entries of another content type. Let’s assume that you had created an entry for the Product content type, and the value selected in the Categories field was ‘Mobiles’. If you fetch the entry using the Get a Single Entry API request, you would get all the details of the entry in the response, but the value against the Categories field would be UID of the referenced entry (i.e., UID of the ‘Mobiles’ entry in this case).
In order to fetch the details of the entry used in the Categories reference field, you need to use the include[] parameter in the following manner:
https://cdn.contentstack.io/v3/content_types/product/entries?include[]=categories
In case you wish to fetch the data of the entries of multiple reference fields, use the include[] parameter in the following manner:
https://cdn.contentstack.io/v3/content_types/product/entries?include[]=categories&include[]=brands
If the reference field is part of a Group field, you need to use the Group field UID as well as the reference field UID using a dot operator.
This query will work for entries only.
Example: In the Products content type, we have a Group field named Bank Offers ("uid":"bank_offers"). And, within this Group field, we have a Reference field named Bank ("uid":"bank"). If, for instance, you want to retrieve entries and include the data of the reference field as well, you need to use the include[] parameter in the following manner:
https://cda.contentstack.io/v3/content_types/product/entries?include[]=bank_offers.bank
In case the referenced entry further has reference to another entry (nested referencing), you can use the dot operator to fetch the content of the nested references as well.
This query will work for entries only.
Example: Consider that you have a content type named ‘Blogs’ which has two reference fields (‘Authors’ and ‘Related Articles’) referring to the ‘Authors’ and ‘Blogs’ content types (self-referencing), respectively. So, we have the following reference relationships between the content types:
Now, consider that you want to retrieve an entry of the ‘Blogs’ content type along with the data of the author (details from the ‘Author’ content type) who authored the entry. You also want to fetch the data of the authors who wrote the ‘Related Articles’ as well that are referenced in this entry, (details from the ‘Blogs’ content type).
In this case, you need to use related_articles.authors in the include[] parameter as follows:
https://cdn.contentstack.io/v3/content_types/content_type_uid/entries?include[]=authors&include[]=related_articles.authors
If the reference field is part of a Modular Blocks field, you need to use the Modular Blocks UID, Block UID, as well as the reference field UID using a dot operator.
This query will work for entries only.
Example: In the Products’ content type, we have a Modular Group field named Additional Info ("uid":"additional_info") that contains the Related Products ("uid":"related_products") block. And, within this Block field, we have a field named Products ("uid":"products"). If, for instance, you want to retrieve entries and include the data of the reference field, you need to use the include[] parameter in the following manner:
https://cda.contentstack.io/v3/content_types/product/entries?include[]=additional_info.related_products.products
When fetching an entry or a list of entries, the referenced entries are not included in the response by default—you only get their UIDs.
To retrieve the content of referenced entries (up to depth 1), use the include_all=true parameter. To fetch deeper references, use the include_all_depth parameter to specify the depth (up to 5 levels).
Each level reflects a reference chain—for example, an entry referencing a blog (level 1), which references articles (level 2), and further, articles linking to authors (level 3).
Example API Request:
https://cdn.contentstack.io/v3/content_types/home/entries/?include_all=true&include_all_depth=3Get entries having values based on referenced fields. This query retrieves all entries that satisfy the query conditions made on referenced fields.
This query will work for entries only.
Example: In the Product content type, if you wish to retrieve all entries that have their brand (Reference field) title set to Apple Inc. So, the query that needs to be run is given below:
{"brand": { "$in_query": { "title": "Apple Inc."}}}
If you have enabled multiple content type referencing, you need to mention the content type UID of the parent content type as follows:
{"brand":{"$in_query":{"title":"Apple Inc.", "_content_type_uid":"brand"}, "_content_type_uid":"product"}}
You can use queries within this query (nested querying) in order to query on the referred entries. In this case, the syntax of the query will be as follows:
Additionally, to retrieve entries that also include references to entries of multiple content types, you need to specify the content type UIDs of all the referred entries when querying.
For example, “Parent Reference” has a Reference field that points to “Reference content type 1” and “Reference content type 1” has a Reference field that points to both “Reference content type 2” and “Reference content type 3”.
So, to retrieve an entry in “Parent Reference” that has referred to an entry of “Reference content type 1” whose Reference field has referred an entry titled “Sample” of “Reference content type 2”. The query format is as follows:
You can use queries within this query (nested querying) in order to query on the referred entries.This query will work for entries only.
The syntax of the query will be as follows:
Example: If you want to retrieve all entries that have referenced entries with title that starts with ‘S’ within the frequently_bought_together field, you need to run the query given below:
In the above query, ‘Search by Regex’ query has been applied on the referred field. Other queries that can be applied are: Equals Operator, Equals Within Group Operator, Not-equals Operator, Array Equals Operator, Array Not-equals Operator, AND Operator, OR Operator, Less Than, Less Than Or Equal To, Greater Than, Greater Than Or Equal To, and Exists.
Get entries having values based on referenced fields. This query retrieves all entries that satisfy query conditions made on referenced fields.
If the reference field is part of a Group field, you need to mention the Group field UID as well as the reference field UID using a dot operator, as given below.
Example: In the Products content type, we have a Group field named Bank Offers ("uid":"bank_offers"). And, within this Group field, we have a Reference field named Bank ("uid":"bank"). If, for instance, you want to retrieve the entries in which the value for the Bank field is ‘Citigroup,’ use the following value in the query parameter:
Get entries having values based on referenced fields. This query retrieves all entries that satisfy query conditions made on referenced fields.If the reference is part of a Modular Blocks field, you need to mention the Modular Blocks UID, Block UID, as well as the reference field UID using a dot operatorNote that this query will work for entries only.
Example: In the Products content type, we have a Modular Group field named Additional Info ("uid":"additional_info") that contains the Related Products ("uid":"related_products") block. And, within this Related Products block, we have a field named Products ("uid":"products"). If, for instance, you want to retrieve the entries in which the values for the Title field is iPhone 7 128GB, use the following value in the ‘query’ parameter:
Get entries having values based on referenced fields. This query works the opposite of $in_query and retrieves all entries that does not satisfy query conditions made on referenced fields.
Note that this query will work for entries only.
Example: Let’s say you wish to retrieve all entries that have brand names other than Apple Inc. So, the query that needs to be made is given below:
Note: When querying on Reference field, users need to specify the Content Type UID (using the_content_type_uid parameter) of entry to which the Reference field belongs to.
Get entries having values based on referenced fields. This query works the opposite of $in_query and retrieves all entries that does not satisfy query conditions made on referenced fields.Note that this query will work for entries only.If the reference is part of a Group field, you need to use the Group field UID as well as the reference field UID using a dot operator.
Example: In the Products content type, we have a Group field named Bank Offers ("uid":"bank_offers"). And, within this Group field, we have a Reference field named Bank ("uid":"bank"). If, for instance, you want to retrieve the entries in which the value for the Bank field is NOT ‘Citigroup', use the following query:
Get entries having values based on referenced fields. This query works the opposite of $in_query and retrieves all entries that does not satisfy query conditions made on referenced fields.
Note: This query will work for entries only.
If the reference is part of a Modular Blocks field, you need to use the Modular Blocks UID, Block UID, as well as the reference field UID using a dot operator.
Example: In the Products content type, we have a Modular Group field named Additional Info ("uid":"additional_info") that contains the Related Products ("uid":"related_products") block. And, within this Block field, we have a field named Products ("uid":"products"). If, for instance, you want to retrieve the entries in which the value for the Title field is NOT ‘iPhone 7 128GB', use the following query:
Get entries by using regular expressions to query fields of a content type. These regex queries will help to retrieve all the entries of a content type that have field values matching the condition provided in the query parameter.This query will work for both entries as well as assets.
Example: In the Product content type, you have a field named Color ("uid":"color") in your content type, and you want to retrieve all the entries within this content type that have values for this field starting with 'Bl'. You can use the parameter as:
{ "color": { "$regex": "^Bl" } }.
Now, in order to perform a case-insensitive search, you can use the $options key to specify any regular expressions options:
{ "color": { "$regex": "^bl", "$options": "i" } }.
Tip: Some useful values for $options are m for making dot match newlines and x for ignoring whitespace in regex.
Get entries by using regular expressions to query fields of a Group field. These regex queries will help to retrieve all the entries of a content type that have field values matching the condition provided in the query parameter.
Note: This query is specifically for fields that are part of the Group field.
Example: In the Products content type, we have a Group field named Bank Offers ("uid":"bank_offers"). And, within this Group field, we have a Reference field named Bank ("uid":"bank"). If, for instance, you want to retrieve the entries in which the value for the Card Type starts with “Credit Card,” use the following value in the query parameter:
{ "bank_offers.card_type": { "$regex": "^Credit Card" } }
Get entries by using regular expressions to query fields of a Modular Block. These Regex queries will help to retrieve all the entries of a content type that have field values matching the condition provided in the query parameter.
This query will work for entries only and works specifically for fields that are part of any block within a Modular Block field.
Example: In the Products content type, we have a Modular Group field named Additional Info ("uid":"additional_info") that contains the Deals ("uid":"deals") block. And, within this Deals block, we have a field named Deal Name ("uid":"deal_name"). If, for instance, you want to retrieve the entries where Deal Name starts with “Christmas Deal,” use the following value in the query parameter:
{ "additional_info.deals.deal_name": { "$regex": "^Christmas Deal" }}
Get entries that satisfy all the conditions provided in the '$and' query.This query will work for both entries as well as assets.
Example: Let’s say you want to retrieve entries in which the Title field is set to 'Redmi Note 3' and the Color field is 'Gold'. The query to be used for such a case would be:
{"$and":[{"title": "Redmi Note 3"},{"color": "Gold"}]}
The response will contain the entries where the values for Title is 'Redmi Note 3' and Color is 'Gold'.
Get entries that satisfy all the conditions provided in the $and query.This query is specifically for entries and works on fields that are part of the Group field.
Example: In the Products content type, we have a Group field named Bank Offers ("uid":"bank_offers"). And, within this Group field, we have fields named Card Type ("uid":"card_type") and Discount in Percentage ("uid":"discount_in_percentage"). If, for instance, you want to retrieve the entries in where the value for Card Type is ‘Credit Card’ and ‘Discount in Percentage’ is '12', use the following value in the query parameter:
{"$and":[{"bank_offers.card_type": "Credit Card"},{"bank_offers.discount_in_percentage": 12}]}
Get entries that satisfy all the conditions provided in the $and query.This query is specifically for entries and works on fields that are part of any block within a Modular Block field.
Example: In the Products content type, we have a Modular Group field named Additional Info ("uid":"additional_info") that contains the Deals ("uid":"deals") and Rating ("uid":"rating") blocks. And, within the Deals and Rating blocks, we have the Deal Name ("uid":"deal_name") and Stars ("uid":"stars") fields, respectively. If, for instance, you want to retrieve the entries in where the values for Deals and Ratings fields are ‘Christmas Deal’ and '2', respectively, use the following value in the query parameter:
{"$and":[{"additional_info.deals.deal_name": "Christmas Deal"},{"additional_info.rating.stars": 2}]}
Get all entries that satisfy at least one of the given conditions provided in the '$or' query.
This query will work for both entries as well as assets.
Example: Let’s say you want to retrieve entries in which either the value for the Color field is 'Gold' or 'Black'. The query to be used for such a case would be:
{ "$or": [{ "color": "Gold" }, { "color": "Black" }] }
The response will contain the entries that have their Color fields set to either 'Gold' or 'Black'.
Get all entries that satisfy at least one of the given conditions provided in the $or query.
This query is specifically for entries and works for fields that are part of the Group field.
Example: In the Products content type, we have a Group field named Bank Offers ("uid":"bank_offers"). And, within this Group field, we have fields named Card Type ("uid":"card_type") and Discount in Percentage ("uid":"discount_in_percentage"). If, for instance, you want to retrieve the entries where either the value for Card Type is ‘Debit Card’ or the value for Discount in Percentage is '12', use the following value in the query parameter:
{ "$or": [{ "bank_offers.card_type": "Debit Card" }, { "bank_offers.discount_in_percentage": 12}]}
Get all entries that satisfy at least one of the given conditions provided in the '$or' query.
This query is specifically for entries and works on fields that are part of any block within a Modular Block field.
Example: In the ‘Products’ content type, we have a Modular Group field named ‘Additional Info’ ("uid":"additional_info") that contains the Deals ("uid":"deals") and Rating ("uid":"rating") blocks. And, within the Deals and Rating blocks, we have the Deal Name ("uid":"deal_name") and Stars ("uid":"stars") fields, respectively. If, for instance, you want to retrieve the entries where either the value for Deal Name is ‘Christmas Deal’ or the value for Stars is '2', respectively, use the following value in the query parameter:
{"$or":[{"additional_info.deals.deal_name": "Christmas Deal"},{"additional_info.rating.stars": 2}]}
Get entries in which the value of a field is lesser than the value provided in the condition.
This query will work for both entries as well as assets.
Example: Let’s say you want to retrieve all the entries that have value of the Price in USD field set to a value that is less than but not equal to 600. You can send the parameter as:
{ "price_in_usd": { "$lt": 600 } }
This will give you all the entries of mobile phones costing less than but not equal to $600.
Let’s consider another example. You want to retrieve all the entries that have their start date before 8th December, 2017. Now, you need to set this parameter with the date in the ISO Date format as below:
{ "start_date": { "$lt": "2017-12-08T00:00:00.000Z" } }
This will give you all the entries where the start date is before 8th December, 2017, but you will not get the entries of the same date.
Note: Avoid using seconds and milliseconds in date/time queries. We recommend to round off to the nearest minute (at most 5 minutes).
Get entries in which the value of a field is lesser than the value provided in the condition.
This query is specifically for fields that are part of the Group field.
Example: In the Products content type, we have a Group field named Bank Offers ("uid":"bank_offers"). And, within this Group field, we have a subfield named Discount in Percentage ("uid":"discount_in_percentage"). If, for instance, you want to retrieve the entries in which the values for the Discount in Percentage field is less than ‘25’, use the following value in the query parameter:
{ "bank_offers.discount_in_percentage": { "$lt": 25 } }
Note: Avoid using seconds and milliseconds in date/time queries. We recommend to round off to the nearest minute (at most 5 minutes).
Get entries in which the value of a field is lesser than the value provided in the condition.
This query is specifically for fields that are part of any block within a Modular Block field.
Example: In the Products content type, we have a Modular Group field named Additional Info ("uid":"additional_info") that contains the Rating ("uid":"rating") block. And, within this Block field, we have a field named Stars ("uid":"stars"). If, for instance, you want to retrieve the entries in which the values for the Stars field is less than ‘3’, use the following value in the query parameter:
{ "additional_info.rating.stars": { "$lt": 3 } }
Note: Avoid using seconds and milliseconds in date/time queries. We recommend to round off to the nearest minute (at most 5 minutes).
Get entries in which the value of a field is lesser than or equal to the value provided in the condition.This query will work for both entries as well as assets.
Example: Let’s say you want to retrieve all the entries that have value of the Price in USD field set to a value that is less than or equal to 146. To achieve this, send the parameter as:
{ "price_in_usd": { "$lte": 146 } }
This will give you all the entries of mobile phones costing less than and equal to $146.
Let’s consider another example. If you want to retrieve all the entries that have their start date before and on 8th December, 2017. Now, you need to set this parameter with the date in the ISO Date format as below:
{ "start_date": { "$lte": "2017-11-08T00:00:00.000Z" } }
This will give you all the entries before 8th December, 2017, along with the entries of 8th December, 2017.
Note: Avoid using seconds and milliseconds in date/time queries. We recommend to round off to the nearest minute (at most 5 minutes).
Get entries in which the value of a field is lesser than or equal to the value provided in the condition.This query is specifically for fields that are part of the Group field.
Example: In the Products content type, we have a Group field named Bank Offers ("uid":"bank_offers"). And, within this Group field, we have a subfield named Discount in Percentage ("uid":"discount_in_percentage"). If, for instance, you want to retrieve the entries in which the values for the Discount in Percentage field is less than or equal to ‘24’, use the following value in the query parameter:
{ "bank_offers.discount_in_percentage": { "$lte": 27 } }
Note: Avoid using seconds and milliseconds in date/time queries. We recommend to round off to the nearest minute (at most 5 minutes).
Get entries in which the value of a field is lesser than or equal to the value provided in the condition.This query is specifically for entries and works on fields that are part of any block within a Modular Block field.
Example: In the Products content type, we have a Modular Group field named Additional Info ("uid":"additional_info") that contains the Rating ("uid":"rating") block. And, within this Rating block, we have a field named Stars ("uid":"stars"). If, for instance, you want to retrieve the entries in which the values for the Stars field is less than or equal to ‘3’, use the following value in the query parameter:
{ "additional_info.rating.stars": { "$lte": 3 } }
Note: Avoid using seconds and milliseconds in date/time queries. We recommend to round off to the nearest minute (at most 5 minutes).
Get entries in which the value for a field is greater than the value provided in the condition.This query will work for both entries as well as assets.
Example: Let’s say you want to retrieve all the entries that have value of the Price in USD field set to a value that is greater than but not equal to 146. You can send the parameter as:
{ "price_in_usd": { "$gt": 146 } }
This will give you all the entries of mobile phones costing greater than and not equal to $146.
Let’s consider another example. If you want to retrieve all the entries that have their start date later than 8th December, 2017. Now, you need to set this parameter with the date in the ISO Date format as below:
{ "start_date": { "$gt": "2017-11-08T00:00:00.000Z" } }
This will give you all the entries after 8th December, 2017.
Note: Avoid using seconds and milliseconds in date/time queries. We recommend to round off to the nearest minute (at most 5 minutes).
Get entries in which the value for a field is greater than the value provided in the condition.This query is specifically for entries and works on fields that are part of the Group field.
Example: In the Products content type, we have a Group field named Bank Offers ("uid":"bank_offers"). And, within this Group field, we have a subfield named Discount in Percentage ("uid":"discount_in_percentage"). If, for instance, you want to retrieve the entries in which the values for the Discount in Percentage field is greater than ‘20’, use the following value in the query parameter:
{ "bank_offers.discount_in_percentage": { "$gt": 20 } }
Note: Avoid using seconds and milliseconds in date/time queries. We recommend to round off to the nearest minute (at most 5 minutes).
Get entries in which the value for a field is greater than the value provided in the condition.This query is specifically for entries and works on fields that are part of any block within a Modular Block field.
Example: In the Products content type, we have a Modular Group field named Additional Info ("uid":"additional_info") that contains the Rating ("uid":"rating") block. And, within this Block field, we have a field named Stars ("uid":"stars"). If, for instance, you want to retrieve the entries in which the values for the Stars field is greater than ‘3’, use the following value in the query parameter:
{"additional_info.rating.stars": {"$gt": 3}}
Note: Avoid using seconds and milliseconds in date/time queries. We recommend to round off to the nearest minute (at most 5 minutes).
Get entries in which the value of a field is greater than or equal to the value provided in the condition.
This query will work for both entries as well as assets.
Example: Let’s say you want to retrieve all the entries that have value of the Price in USD field set to a value that is greater than or equal to 146. You can send the parameter as:
{ "price_in_usd": { "$gte": 146 } }
This will give you all the entries of mobile phones costing greater than and equal to $146.
Let’s consider another example. You want to retrieve all the entries that have their start date 8th December, 2017, and later. Now, you need to set this parameter with the date in the ISO Date format as below:
{ "start_date": { "$gte": "2017-11-08T00:00:00.000Z" } }
This will give you all the entries where the start date falls after 8th December, 2017, along with the entries of the same date.
Note: Avoid using seconds and milliseconds in date/time queries. We recommend to round off to the nearest minute (at most 5 minutes).
Get entries in which the value of a field is greater than or equal to the value provided in the condition.This query is specifically for fields that are part of the Group field.
Example: In the Products content type, we have a Group field named Bank Offers ("uid":"bank_offers"). And, within this Group field, we have a subfield named Discount in Percentage ("uid":"discount_in_percentage"). If, for instance, you want to retrieve the entries in which the values for the Discount in Percentage field is greater than or equal to ‘20’, use the following value in the query parameter:
{ "bank_offers.discount_in_percentage": { "$gte": 20 } }
Note: Avoid using seconds and milliseconds in date/time queries. We recommend to round off to the nearest minute (at most 5 minutes).
Get entries in which the value of a field is greater than or equal to the value provided in the condition.
This query is specifically for fields that are part of any block within a Modular Block field.
Example: In the Products content type, we have a Modular Group field named Additional Info ("uid":"additional_info") that contains the Rating ("uid":"rating") block. And, within this Rating block, we have a field named Stars' ("uid":"stars"). If, for instance, you want to retrieve the entries in which the values for the Stars field is greater than or equal to ‘3’, use the following value in the query parameter:
{"additional_info.rating.stars": {"$gte": 3}
Note: Avoid using seconds and milliseconds in date/time queries. We recommend to round off to the nearest minute (at most 5 minutes).
The limit parameter will return a specific number of entries in the output. So for example, if the content type contains more than 100 entries and you wish to fetch only the first 2 entries, you need to specify '2' as value in this parameter.
This query will work for both entries as well as assets.
Example:
https://cdn.contentstack.io/v3/content_types/product/entries?environment=production&limit=2
Note: By default, the limit for response details per request is 100.
The skip parameter will skip a specific number of entries in the output. So, for example, if the content type contains around 12 entries and you want to skip the first 2 entries to get only the last 10 in the response body, you need to specify ‘2’ here.This query will work for both entries as well as assets.
Example:
https://cdn.contentstack.io/v3/content_types/product/entries?environment=production&skip=2
When fetching entries, you can sort them in the ascending order with respect to the value of a specific field in the response body.
This query will work for both entries as well as assets.
Example: In the Product content type, if you wish to sort the entries with respect to their prices, the parameter can be used as:
https://cdn.contentstack.io/v3/content_types/product/entries?environment=production&asc=price_in_usd
This will give you all the entries sorted in the ascending order with respect to the Price in USD field.
Note: In situations where identical or empty/null values are present in the field selected for sorting, the sorting process may not yield accurate results, potentially leading to duplicate results in the output. To avoid this, consider utilizing fields without duplicate values, or fields that are indexed (for e.g., updated_at), to effectively sort your data. Alternatively, if you must use the non-indexed fields for sorting, please contact our Support team for assistance in adding indexes to the field and ensuring the correct sorting of your data within the query results. Please note that a maximum of 5 fields can be indexed per Organization.
Sort your fetched entries in the ascending order with respect to the value of a specific field in the response body.This query is specifically for entries and works on fields that are part of the Group field.
Example: In the Products content type, we have a Group field named Bank Offers ("uid":"bank_offers"). And, within this Group field, we have a subfield named Discount in Percentage ("uid":"discount_in_percentage"). If, for instance, you want to retrieve entries in the ascending order with respect to the Discount in Percentage field, use the following URL:
https://cdn.contentstack.io/v3/content_types/product/entries?environment=production&asc=bank_offers.discount_in_percentage
When fetching entries, you can sort your fetched entries in the ascending order with respect to the values of any block within a Modular Block field.
This query is specifically for entries and works on fields that are part of any block within a Modular Block field.
Note: Currently, this query is not applicable for Reference fields within Modular Blocks.
Example: In the Products content type, we have a Modular Block field named Additional Info ("uid":"additional_info") that contains the Rating ("uid":"rating") block. And, within this Rating block, we have a field named Stars ("uid":"stars"). Use the following URL to retrieve entries in ascending order based on the values of the Stars field:
https://cdn.contentstack.io/v3/content_types/product/entries?environment=production&asc=additional_info.rating.stars
When fetching entries, you can sort them in the descending order with respect to the value of a specific field in the response body.
This query will work for both entries as well as assets.
Example: In the Product content type, if you wish to sort the entries with respect to their prices, the parameter can be used as:
https://cdn.contentstack.io/v3/content_types/product/entries?environment=production&desc=price_in_usd
This will give you all the entries sorted in the descending order with respect to the Price in USD field.
Note: In situations where identical or empty/null values are present in the field selected for sorting, the sorting process may not yield accurate results, potentially leading to duplicate results in the output. To avoid this, consider utilizing fields without duplicate values, or fields that are indexed (for e.g., updated_at), to effectively sort your data. Alternatively, if you must use the non-indexed fields for sorting, please contact our Support team for assistance in adding indexes to the field and ensuring the correct sorting of your data within the query results. Please note that a maximum of 5 fields can be indexed per Organization.
Sort your fetched entries in the descending order with respect to the value of a specific field in the response body.This query is specifically for entries and works on fields that are part of the Group field.
Example: In the Products content type, we have a Group field named Bank Offers ("uid":"bank_offers"). And, within this Group field, we have a subfield named Discount in Percentage ("uid":"discount_in_percentage"). If, for instance, you want to retrieve entries in the descending order with respect to the values of the Discount in Percentage field, use the following URL:
https://cdn.contentstack.io/v3/content_types/product/entries?environment=production&desc=bank_offers.discount_in_percentage
Sort your fetched entries in the descending order with respect to the value of a specific field in the response body.This query is specifically for entries and works on fields that are part of any block within a Modular Block field.
Note: Currently, this query is not applicable for Reference fields within Modular Blocks.
Example: In the Products content type, we have a Modular Group field named Additional Info ("uid":"additional_info") that contains the Rating ("uid":"rating") block. And, within this Rating block, we have a field named Stars ("uid":"stars"). If, for instance, you want to retrieve entries in the descending order with respect to the values of the Stars field, use the following URL:
https://cdn.contentstack.io/v3/content_types/product/entries?environment=production&desc=additional_info.rating.stars
Get entries if value of the field, mentioned in the condition, exists.This query will work for entries only.
Example: In the Product content type, we have a field named Price in USD. Now, you want to retrieve all the entries in the content type in which the field exists. You can send the parameter as:
{ "price_in_usd": { "$exists": true } }.
Get entries if value of the field, mentioned in the condition, exists.This query is specifically for entries and work on fields that are part of the Group field.
Example: In the Products content type, we have a Group field named Bank Offers ("uid":"bank_offers"). And, within this Group field, we have a subfield named Card Type ("uid":"card_type"). If, for instance, you want to retrieve the entries in which the values for the Discount in Percentage field exists, use the following value in the query parameter:
{"bank_offers.discount_in_percentage": { "$exists": true }}
Get entries if value of the field, mentioned in the condition, exists.This query is specifically for entries and works on fields that are part of any block within a Modular Block field.
Example: In the Products content type, we have a Modular Group field named Additional Info ("uid":"additional_info") that contains the Deals ("uid":"deals") block. And, within this Block field, we have a field named Deal Name ("uid":"deal_name"). If, for instance, you want to retrieve the entries in which the values for the Stars field exists, use the following value in the query parameter:
{"additional_info.rating.stars": {"$exists": true }}
The only[][] parameter will include the data of only the specified fields for each entry and exclude the data of all other fields. There are two approaches to this parameter. Firstly, we have the only[BASE][] parameter, where 'BASE' is the default value and refers to the top-level fields of the schema. Secondly, we have the only[Reference_field_uid][] parameter, where you need to enter the UID of the reference field in place of "Reference_field_uid".This query will work for entries only.
Example: In the Product content type, if we need to retrieve the data of only the Price in USD parameter of all the entries, you can send the parameter as:
https://cdn.contentstack.io/v3/content_types/author/entries?environment=production&only[BASE][]=price_in_usd
https://cdn.contentstack.io/v3/content_types/author/entries?environment=production&only[BASE][]=price_in_usd&only[BASE][]=color
Get entries in which the data of a specific field is included in the response JSON.This query is specifically for entries and works on fields that are part of the Group field.
Example: In the Products’ content type, we have a Group field named Bank Offers ("uid":"bank_offers"). And, within this Group field, we have a subfield named Discount in Percentage ("uid":"discount_in_percentage"). If, for instance, you want to retrieve only the values of the Discount in Percentage field of all the entries, you can send the parameters as:
https://cdn.contentstack.io/v3/content_types/product/entries?environment=production&only[BASE][]=bank_offers.discount_in_percentage
Get entries in which the data of a specific field is included in the response JSON.This query is specifically for fields that are part of any block within a Modular Block field.
Example: In the Products content type, we have a Modular Group field named Additional Info ("uid":"additional_info") that contains the Rating ("uid":"rating") block. And, within this Rating block, we have a field named Stars ("uid":"stars"). If, for instance, you want to retrieve the values of all the Stars field from all the entries, you can send the parameters as:
https://cdn.contentstack.io/v3/content_types/product/entries?environment=production&only[BASE][]=additional_info.rating.stars
The except[][] parameter will exclude the data of the specified fields for each entry and will include the data of the rest of the fields. There are two approaches to this parameter. Firstly, we have the except[BASE][] parameter, where 'BASE' is the default value and refers to the top-level fields of the schema. Secondly, we have the except[Reference_field_uid][] parameter, where you need to enter the UID of the reference field in place of Reference_field_uid.This query will work for entries only.
Example: In the Product content type, if we need to retrieve the data of entries of all the other fields except the Price in USD parameter, you can send the parameter as:
https://cdn.contentstack.io/v3/content_types/product/entries?environment=production&except[BASE][]=price_in_usd
https://cdn.contentstack.io/v3/content_types/author/entries?environment=production&except[BASE][]=price_in_usd&except[BASE][]=color
Get entries in which the data of a specific field is excluded from the response JSON, but the data of the rest of the fields are included.This query is specifically for entries and works with fields that are part of the Group field.
Example: In the Products content type, we have a Group field named Bank Offers ("uid":"bank_offers"). And, within this Group field, we have a subfield named Discount in Percentage ("uid":"discount_in_percentage"). If, for instance, you want to retrieve all the entries of a content type, but exclude the data for the Discount in Percentage field in the JSON response, you can send the parameters as:
https://cdn.contentstack.io/v3/content_types/product/entries?environment=production&except[BASE][]=bank_offers.discount_in_percentage
Get entries in which the data of a specific field is excluded from the response JSON, but the data of the rest of the fields are included.This query is specifically for entries and works with fields that are part of any block within a Modular Block field.
Example: In the Products content type, we have a Modular Group field named Additional Info ("uid":"additional_info") that contains the Rating ("uid":"rating") block. And, within this Block field, we have a field named Stars ("uid":"stars"). If, for instance, you want to retrieve all the entries of a content type, but exclude the data for the Stars field in the JSON response, you can send the parameters as:
https://cdn.contentstack.io/v3/content_types/product/entries?environment=production&except[BASE][]=additional_info.rating.stars
To retrieve the count of entries, we have two parameters: include_count (retrieves entries' details and their count) and count (retrieves only the count of entries).This query will work for both entries as well as assets.
Example: If you wish to know the total number of entries in the Product content type and also retrieve all the data, you need to run the following API request:
https://cdn.contentstack.io/v3/content_types/product/entries?environment={environment}&include_count=trueTo get only the count, run the following API request:
https://cdn.contentstack.io/v3/content_types/product/entries?environment={environment}&count=trueThe 'Get all entries' API request returns only the first 100 entries of the specified content type. Similarly, the 'Get all assets' request fetches the first 100 assets of a particular stack.
In both requests, first, use the include_count parameter to get the total count of the items (entries/assets). Learn more about the Count parameter.
Since only 100 items are returned at a time in your response (in case of both requests), you can get the rest of the items in batches using the skip parameter in subsequent requests. Learn more about the Skip parameter.
You can paginate the output of a request by using the limit parameter. For example, if you have 200 entries and/or assets and you want to retrieve them all but display only 10 items at a time. Use the limit=10 and skip=10 parameters, to get them all but display only 10 items per page.
The syntax of the pagination request will look like the following:
The table below contains the list of all query parameters used in the Content Delivery APIs. Each query parameter within the table has a corresponding description, the API requests it is used in, and a relevant example. Use it as a cheat sheet or quick reference to search API requests by query parameters.
The Contentstack Postman collection is a set of preconfigured REST API requests that will make it easy for you to get started with the Contentstack APIs and try out our API requests through the popular Postman REST client.
To use the Contentstack Postman collection you will need to have the Postman. You can either download the Desktop app or use Postman for Web.
Note: If you have already installed Postman for your device, go to the Download Latest Postman Collection for Contentstack section.
Postman is available for Windows (x64), Mac (Intel Chip / Apple Chip), and Linux environments.
Once you have installed Postman on your device, click the Run in Postman button to start working with the Content Delivery API endpoints for Contentstack.
Note: The Contentstack Postman collection does not support the now deprecated Postman Chrome extension. Make sure you have installed the latest version of the Postman desktop app.
This opens the Fork collection into your workspace modal from where you can proceed to download/work with the Contentstack Postman collection in the following three ways:
Let’s look at each of the above methods in detail.
This option allows you to just view (and not try out) the API requests of the Postman collection.
Perform the following steps to view the Content Delivery API Postman collection:

A new tab opens up in your browser where you should see the latest collection preloaded in the left navigation.
Note: If you want to try out the API requests, you can either import a copy of the collection or fork the collection.
This option allows you to import a copy of the collection into your workspace.
To import the Content Delivery API collection, perform the following steps:

You will see a copy of the latest Postman collection in the left navigation panel.

This option allows you to fork, or create a copy of the collection, and perform changes to the collection without affecting the original.
To fork the Content Delivery API collection, perform the following steps:


Under Notifications, check Watch original collection to get notified of any changes that are made to the original collection.

We have also hosted our Postman collection on GitHub. You can follow the steps mentioned in the Readme file to download and start using it.
You can also choose to watch the latest Postman collection to get notifications of new releases or updates.
To do so, click on the following Watch button and select Watching.
When you download and install the latest version of the Content Delivery API (CDA) Postman collection, you also download and import the respective environment along with the environment variables.
Once your environment is imported, next you need to set your Contentstack account specific values.
Note: As these environment variables are referenced across multiple API requests, once you set the variables, it becomes a lot more convenient to make repeated use of the Postman collection.
Some of the important variables that you need to set are as follows:
| Environment Variable | Value |
|---|---|
| base_url | cdn.contentstack.io |
| api_key | your_stack_api_key |
| access_token | your_environment-specific_delivery_token |
Note: The Contentstack Postman collection will require a valid environment-specific Delivery token to make API calls. Check out the Authentication section for more details.
If you want to add your own environment variables, you can follow the procedure in the next section.
To add any new environment variables for your Postman collection, perform the following steps:
With every new API request added, we update our environment file. So, to get the latest environment variables, you need to download the collection along with the updated environment file again, compare your existing environment with the latest environment, identify and add the new variables to your existing environment.
Next, let’s see how you can run API Requests from your Contentstack Postman collection using your environment.
With the Contentstack Postman Collection loaded into the Postman app (on the left pane) and the environment created, you can now make API requests to the Contentstack API via Postman.
To make an API request, perform the following steps:
Note: If you want to make changes to your parameters or want to add parameters of your own, you can do it here.
The API call should return with a response under the Body tab in the bottom half of the screen.
Contentstack provides certain queries that you can use to fetch filtered results. You can use queries for Entries and Assets API requests.
You can add queries to extend the functionality of an entry-specific API call. To add a query, you can either append the query parameter directly to the entry URL or append the query parameter along with your conditional query (in JSON format) to the entry URL.
Case 1: Append the query parameter
If you want to return a specific number of entries in your response output, you can use the limit query parameter. For example, if you want to retrieve only the first 2 entries of a content type, pass '2' as the value for the limit parameter.
https://cdn.contentstack.io/v3/content_types/{{content_type_uid}}/entries?limit=2Case 2: Append the conditional query
If you want to retrieve all the entries of a content type in which the value for the Title ("uid":"title") field is “ABC”, you can append the query parameters to the entry URL as follows:
https://cdn.contentstack.io/v3/content_types/{{content_type_uid}}/entries?query={"title": "ABC"}Let’s say you want to retrieve all the entries that have their start date as 8th December 2017. Now, you need to append the query with the start date in the ISO Date format as below:
https://cdn.contentstack.io/v3/content_types/{{content_type_uid}}/entries?query={ "start_date": "2017-12-08T00:00:00.000Z" }You can append multiple queries in a single API Request as follows:
{{entry_URL}}?environment={{environment}}&locale={{locale}}&include_count=true&skip={skip_value}&limit={limit_value}You can use Image Delivery APIs by appending queries to the image URL:
{{image_url}}?query_parameterFor example, to resize the width of an image to 100px, you need to append ?width={100} to the image URL. So, the API request would be:
https://images.contentstack.io/v3/assets/blteae40eb499811073/bltc5064f36b5855343/59e0c41ac0eddd140d5a8e3e/image_name?width=100.You can also use multiple queries in a single API request as follows:
{{image_url}}?width={width_value}&height={height_value}&resize-filter={resize-filter_value}We strongly advise against storing your API keys and tokens in your collection permanently. If you or someone else shares the collection by mistake, other users will be able to export it along with these keys.
We recommend that you provide your Contentstack account-specific API keys and tokens in your environment or directly to the sample requests.
We keep our Postman Collection updated. To get the latest version of our Postman Collection, all you need to do is to download the Postman Collection along with the updated environment again and you are good to go.
You can also choose to watch for the latest Postman Collection updates on our GitHub repository and get notifications of new releases or updates to the repository. The GitHub Readme doc will help you with the steps that you need to follow.
When trying out Contentstack Get Entry or Get All Entries API requests, Contentstack recommends certain optimization measures that will help you achieve fair limits on your API usage.
Here are some important points that you need to consider:
So what do you do if you might hit the limits even after following the above precautionary measures?
In this scenario, you can make use of filtering or pagination. What does this mean? Let’s look at the steps involved:
In order to attain and maintain optimum performance and ensure that infrastructure resources are used in an efficient manner, Contentstack recommends certain best practices.
By following the recommendations discussed in this guide, you can maintain reasonable API usage while making calls or querying for data by minimizing the number of includes in your call.
Optimize your code to eliminate any redundancies or duplicates from the includes, unwanted includes, or references from our code.
We may get faster responses, however, it can result in retrieving stuff in the response that we don't really need. Before making a call, check for queries in the code that will fetch data items that aren’t used in your application, check whether the fetched data is being put back with no changes made to them, and so on. Also, you can avoid making queries unique by putting in a random number or timestamp.
Once you have optimized your code, cache data items that you use more frequently. Your cache management system can be programmed to help you retrieve most frequently used data through the cache instead of the server.
For example, in a user management application where you update various user details such as user groups, titles, and so on. In such a case, you can think of keeping these details on the application side rather than retrieving them through calls every time the user opens the form.
If you possess content pieces that do not change often, they can be cached in your app's cache management system to avoid fetching them every now and then.
For example, if your app is customer facing and there is an FAQ section in your app, you can prefer keeping answers to these FAQs on the application cache rather than fetching it every time where there is a requirement.
Contentstack webhooks can be used to keep track of changes. You can set webhooks when any changes are made to content or code and then react as required.
The webhook notifications allow App to fetch details as desired instead of waiting for the app's API instance to check for job status periodically and then fetch the data. Webhooks can help you in such situations by notifying you as and when the job gets completed.
This reduces the number of includes in the call that may otherwise be high if the checking period has considerable time in between.
Lazy loading, or "On-demand loading," is an online content optimization technique for web apps and websites. It involves loading the most important section of the page first followed by the remaining sections, instead of loading and rendering the complete page in one go. This totally depends on the user requirement.
This approach can be useful in reducing the number of includes involved in making a call and rendering the content to the user. This is not only cost-effective but also resource effective as well.
Referencing is a powerful Contentstack feature that allows you to create references. However, if not needed, we encourage you to avoid fetching unnecessary references in the response.
The number of includes in case of referencing is one thing, but the depth of a single include is also more resource costly than a shallower include. So you should always decide logically when retrieving data in a single call and avoid retrieving them unnecessarily for optimum resource utilization.
When making use of multiple content type references, and fetching the schema of all these content types can be exhausting. This also increases the number of includes in a call.
This case can be handled efficiently by using Modular Blocks. They can be used with other modules to construct a complete webpage. You can create multiple blocks (let's say, B1, B2, B3, and so on with each block with a different schema) within a modular block while creating a content type.
While creating an entry in this content type, you can add data to any of the blocks (B1, B2, B3) and keep other blocks empty. And now when you make a call, you don't have to include the referenced content types in your call. This is another way of minimizing the includes in your call or queries.