Skip to content


  Less than to read


The primary purpose of apiGetMetadata is to retrieve metadata from the API endpoint. Metadata includes information such as data types, maximum string lengths, and other details about the screen’s data structure. It defines the shape and properties of the data used in the screen.

By fetching metadata, apiGetMetadata allows the frontend code to understand the structure and requirements of the data when interacting with the API. This knowledge is essential for constructing API requests properly and handling data in the screen accurately.

The “apiGetMetadata” method plays a crucial role by retrieving metadata from an API endpoint that provides important information about the data structure, data types, and other properties related to the endpoint. The metadata provides characteristics associated with each field, this can include information such as the maximum length of a string field, the range of values for a numeric field, or specific formatting requirements for a date field. Additionally, it may indicate whether certain fields are required or optional.

When to use apiGetMetadata

You should use apiGetMetadata in the following scenarios:

  • Screen initialisation: When initialising a screen, retrieving the metadata is crucial to understanding the structure of the data that the screen will work with.

  • Dynamic screen generation: If your application generates screens dynamically based on API responses, apiGetMetadata becomes essential. It allows you to adjust the screen’s structure, fields, and validation rules dynamically based on the received metadata.

  • API request construction: When constructing API requests to update or create new items, apiGetMetadata is particularly useful. The metadata provides information about the required data fields, ensuring that your requests are properly formatted.

apiGetMetadata Parameters

Parameters Description
endpoint The URL for Sage 200 API endpoint that you require (e.g. v1/departments or v1/customers)
prefix (Optional) Allows you to provide a prefix to separate the data in the Redux store. It can be useful when working with multiple APIs or screens on the same page.
isInDialog (Optional) Determines how initialValues are stored. When set to true (default), initialValues are stored separately for child dialogs, maintaining their own version independently. When set to false, initialValues are merged with the main parent screen. If data is to be displayed on the main form (eg in tab), then isInDialog should be set false, so that data is merged into the parent form’s initialValues; for consistent field validation, form dirtiness.
key (Optional) Specifies the key for the grid or collection in the Redux store. This parameter is typically used when working with collections of data or when binding data to a grid UI component.

apiGetMetadata Example

"apiGetMetadata": {
  "endpoint": "v1/departments",
  "prefix": "myPrefix",
  "isInDialog": false,
  "key": "departments"