Global Fields
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.
NoteIf your Global field contains nested Global fields, they will appear as part of the schema in the API response.
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 ResourceYou can create dynamic and flexible Global Fields by nesting Global fields within a Modular Block, Global, or a Group fields.
Get all global fields
https://api.contentstack.io/v3/global_fieldsThe Get all global fields request returns comprehensive information of all the global fields available in a particular stack in your organization.
- Information about Global fields can be retrieved by all users, regardless of their role or access level.
- If your Global field contains nested Global fields, they will appear as part of the schema in the API response.
To configure the permissions for your application via OAuth, please include the cm.global-fields.management:read scope.
{
"global_fields": [
{
"created_at": "2019-09-06T11:30:02.108Z",
"updated_at": "2019-09-06T11:30:02.108Z",
"title": "Servlet",
"uid": "servlet",
"_version": 1,
"inbuilt_class": false,
"schema": [
{
"display_name": "Name",
"uid": "name",
"data_type": "text",
"multiple": false,
"mandatory": false,
"unique": false,
"non_localizable": false
},
{
"data_type": "text",
"display_name": "Rich text editor",
"uid": "description",
"field_metadata": {
"allow_rich_text": true,
"description": "",
"multiline": false,
"rich_text_type": "advanced",
"options": [],
"version": 3
},
"multiple": false,
"mandatory": false,
"unique": false,
"non_localizable": false
}
],
"last_activity": {},
"maintain_revisions": true,
"description": ""
}
]
}Get a single global field
https://api.contentstack.io/v3/global_fields/{global_field_uid}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.
- Information about Global fields can be retrieved by all users, regardless of their role or access level.
- If your Global field contains nested Global fields, they will appear as part of the schema in the API response.
- To configure the permissions for your application via OAuth, please include the cm.global-fields.management:read scope.
{
"global_field": {
"created_at": "2019-09-06T11:30:02.108Z",
"updated_at": "2019-09-06T11:30:02.108Z",
"title": "Servlet",
"uid": "servlet",
"_version": 1,
"inbuilt_class": false,
"schema": [
{
"display_name": "Name",
"uid": "name",
"data_type": "text",
"multiple": false,
"mandatory": false,
"unique": false,
"non_localizable": false
},
{
"data_type": "text",
"display_name": "Rich text editor",
"uid": "description",
"field_metadata": {
"allow_rich_text": true,
"description": "",
"multiline": false,
"rich_text_type": "advanced",
"options": [],
"version": 3
},
"multiple": false,
"mandatory": false,
"unique": false,
"non_localizable": false
}
],
"last_activity": {},
"maintain_revisions": true,
"description": ""
}
}Create a global field
https://api.contentstack.io/v3/global_fieldsThe Create a global field request allows you to create a new global field in a particular stack of your Contentstack account. You can use this global field in any content type within your stack.
To configure the permissions for your application via OAuth, please include the cm.global-fields.management:write scope.
NoteOnly the stack owner, administrator, and developer can create global fields.
To create a nested global field, follow the schema in the request body:
{
"global_field": {
"title": "Nested Global Field",
"uid": "nested_global_field",
"description": "",
"schema": [
{
"data_type": "text",
"display_name": "Single Line Textbox",
"uid": "single_line",
"field_metadata": {
"description": "",
"default_value": "",
"version": 3
},
"format": "",
"error_messages": {
"format": ""
},
"mandatory": false,
"multiple": false,
"non_localizable": false,
"unique": false,
"indexed": false,
"inbuilt_model": false
},
{
"data_type": "global_field",
"display_name": "Global",
"reference_to": "global_field_1",
"field_metadata": {
"description": ""
},
"uid": "global_field",
"mandatory": false,
"multiple": false,
"non_localizable": false,
"unique": false,
"indexed": false,
"inbuilt_model": false
}
]
}
}
{
"global_field": {
"title": "Nested Global Field",
"uid": "nested_global_field",
"description": "",
"schema": [
{
"data_type": "text",
"display_name": "Single Line Textbox",
"uid": "single_line",
"field_metadata": {
"description": "",
"default_value": "",
"version": 3
},
"format": "",
"error_messages": {
"format": ""
},
"mandatory": false,
"multiple": false,
"non_localizable": false,
"unique": false,
"indexed": false,
"inbuilt_model": false
},
{
"data_type": "global_field",
"display_name": "Global",
"reference_to": "global_field_1",
"field_metadata": {
"description": ""
},
"uid": "global_field",
"mandatory": false,
"multiple": false,
"non_localizable": false,
"unique": false,
"indexed": false,
"inbuilt_model": false
}
]
}
}{
"notice": "Global Field created successfully.",
"global_field": {
"created_at": "2024-08-07T07:39:11.410Z",
"updated_at": "2024-08-07T07:40:02.343Z",
"title": "Nested Global Field",
"uid": "nested_global_field",
"description": "",
"_version": 1,
"inbuilt_class": false,
"schema": [
{
"data_type": "text",
"display_name": "Single Line Textbox",
"uid": "single_line",
"field_metadata": {
"description": "",
"default_value": "",
"version": 3
},
"format": "",
"error_messages": {
"format": ""
},
"mandatory": false,
"multiple": false,
"non_localizable": false,
"unique": false,
"indexed": false,
"inbuilt_model": false
},
{
"data_type": "global_field",
"display_name": "Global",
"reference_to": "global_field_1",
"field_metadata": {
"description": ""
},
"uid": "global_field",
"mandatory": false,
"multiple": false,
"non_localizable": false,
"unique": false,
"indexed": false,
"inbuilt_model": false
}
],
"last_activity": {},
"maintain_revisions": true
}
}Update a global field
https://api.contentstack.io/v3/global_fields/{global_field_uid}The Update a global field request allows you to update the schema of an existing global field.
To configure the permissions for your application via OAuth, please include the cm.global-fields.management:write scope.
When executing the API call, in the 'URL Parameters' section, provide the unique ID of your global field.
{
"global_field": {
"title": "Servlet",
"uid": "servlet",
"schema": [{
"display_name": "Name",
"uid": "name",
"data_type": "text"
}, {
"data_type": "text",
"display_name": "Rich text editor",
"uid": "description",
"field_metadata": {
"allow_rich_text": true,
"description": "",
"multiline": false,
"rich_text_type": "advanced",
"options": [],
"version": 3
},
"multiple": false,
"mandatory": false,
"unique": false
}]
}
}{
"notice": "Global Field updated successfully.",
"global_field": {
"created_at": "2019-09-06T11:30:02.108Z",
"updated_at": "2019-09-06T11:30:02.108Z",
"title": "Servlet",
"uid": "servlet",
"_version": 1,
"inbuilt_class": false,
"schema": [
{
"display_name": "Name",
"uid": "name",
"data_type": "text",
"multiple": false,
"mandatory": false,
"unique": false,
"non_localizable": false
},
{
"data_type": "text",
"display_name": "Rich text editor",
"uid": "description",
"field_metadata": {
"allow_rich_text": true,
"description": "",
"multiline": false,
"rich_text_type": "advanced",
"options": [],
"version": 3
},
"multiple": false,
"mandatory": false,
"unique": false,
"non_localizable": false
}
],
"last_activity": {},
"maintain_revisions": true,
"description": ""
}
}Delete global field
https://api.contentstack.io/v3/global_fields/{global_field_uid}?force=trueThe Delete global field request allows you to delete a specific global field.
To configure the permissions for your application via OAuth, please include the cm.global-fields.management:write scope.
WarningIf your Global field has been referred within a particular content type, then you will need to pass an additional query parameter force:true to delete the Global field.
When executing the API call, in the 'URL Parameters' section, provide the unique ID of your global field.
{
"notice": "Global Field deleted successfully."
}Import a global field
https://api.contentstack.io/v3/global_fields/importThe Import a global field call imports a global field into a stack.
To import, you need to provide/upload a JSON file that contains the schema of the global field that you wish to import.
TipYou can try the call manually in any REST API client, such as Postman, by passing a 'Body' parameter named global_field and selecting the input type as 'File'. Then, select the JSON file of the global field that you wish to import.
{
"notice": "Global Field imported successfully.",
"global_field": {
"created_at": "2019-08-22T05:29:37.701Z",
"updated_at": "2019-08-22T05:29:37.701Z",
"title": "five",
"uid": "five",
"_version": 1,
"inbuilt_class": false,
"schema": [
{
"display_name": "Name",
"uid": "name",
"data_type": "text",
"multiple": false,
"mandatory": false,
"unique": false,
"non_localizable": false
},
{
"display_name": "Add",
"uid": "add",
"data_type": "text",
"multiple": false,
"mandatory": false,
"unique": false,
"non_localizable": false
},
{
"display_name": "std",
"uid": "std",
"data_type": "text",
"multiple": false,
"mandatory": false,
"unique": false,
"non_localizable": false
}
],
"last_activity": {},
"maintain_revisions": true,
"description": ""
}
}Export a global field
https://api.contentstack.io/v3/global_fields/{global_field_uid}/exportThis request is used to export a specific global field and its schema. The data is exported in JSON format. The exported file won’t get downloaded automatically. To download the exported file, a REST API client, such as Postman can be used.
To configure the permissions for your application via OAuth, please include the cm.global-fields.management:write scope.
{
"created_at": "2019-11-26T09:18:18.850Z",
"updated_at": "2019-11-26T09:18:49.861Z",
"title": "Servlet",
"uid": "servlet",
"_version": 1,
"inbuilt_class": false,
"schema": [
{
"display_name": "Name",
"uid": "name",
"data_type": "text",
"multiple": false,
"mandatory": false,
"unique": false,
"non_localizable": false
},
{
"data_type": "text",
"display_name": "Rich text editor",
"uid": "description",
"field_metadata": {
"allow_rich_text": true,
"description": "",
"multiline": false,
"rich_text_type": "advanced",
"options": [],
"version": 3
},
"multiple": false,
"mandatory": false,
"unique": false,
"non_localizable": false
}
],
"last_activity": {},
"maintain_revisions": true,
"description": ""
}