> For the complete documentation index, see [llms.txt](https://docs.struct.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.struct.com/tutorials/guides/how-to-use-struct-pims-api/use-of-global-list-endpoints.md).

# Use of Global list endpoints

How to use global list endpoints in API

### Updating a global list

{% tabs %}
{% tab title="HTTP" %}
**PUT** /v1/GlobalLists/{uid}/values
{% endtab %}

{% tab title="Request body (json)" %}

```
[
  {
    "Uid": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "SortOrder": 0,
    "Value": "string"
  }
]
```

{% endtab %}
{% endtabs %}

When updating a global list there are a large amount of changes that can be made on each respective list. In this case we are updating the values of a global list.

In the following example we will set everything up so that you can get an idea of how to use the API.

Retrieving a global list along with its values.

{% code title="C#" overflow="wrap" %}

```csharp
GlobalList existingGlobalList = _apiClient.GlobalLists.GetGlobalList("Suppliers");
```

{% endcode %}

The `GetGlobalList` method sends an HTTP request to the [/v1/GlobalLists/ByAlias/{alias}](/api-reference/endpoints/global-lists.md#get-v1-globallists-byalias-alias) endpoint. As alias we use "Suppliers" in order to retrieve all the global lists under the alias.&#x20;

Alternatively you can use the [/v1/GlobalLists/{uid}](/api-reference/endpoints/global-lists.md#get-v1-globallists-uid) endpoint instead if you know the uid of the global list you are looking for.&#x20;

After having fetched the global list we can now follow up with also retrieving its values.

{% code title="C#" overflow="wrap" %}

```csharp

Dictionary<string, GlobalListValue<SuppliersGlobalListModel>> globalListValues = _apiClient.GlobalLists.GetGlobalListValues<SuppliersGlobalListModel>(existingGlobalList.Uid).GlobalListValues.ToDictionary(x => x.Value.SupplierId);
```

{% endcode %}

Now we need some values to update the global lists with. In this example we use the model `SuppliersGlobalListModel` to set up the data that we want to update our PIM with.

{% code title="C#" overflow="wrap" %}

```csharp
List<SuppliersGlobalListModel> newData = new List<SuppliersGlobalListModel>
{
    new SuppliersGlobalListModel { SupplierId = "100", Name = "Supplier D (Updated)", Phone = "555-0101", Email = "contact@supplier-D.com" },
    new SuppliersGlobalListModel { SupplierId = "83", Name = "Supplier B (Updated)", Phone = "555-0303", Email = "support@supplier-B.com" },
};
```

{% endcode %}

From here we proceed with updating the global lists, but only if the `SupplierId` from `newData` matches an entry in `globalListValues`.

{% code title="C#" overflow="wrap" %}

```csharp
var globalListValuesToUpdate = new List<GlobalListValue<SuppliersGlobalListModel>>();

foreach (var newSupplierData in newData)
{
    if (globalListValues.TryGetValue(newSupplierData.SupplierId, out var existingGlobalListValue))
    {
        existingGlobalListValue.Value.Name = newSupplierData.Name;
        existingGlobalListValue.Value.Phone = newSupplierData.Phone;
        existingGlobalListValue.Value.Email = newSupplierData.Email;

        globalListValuesToUpdate.Add(existingGlobalListValue);
    }
}
```

{% endcode %}

With them now updated we can proceed to update the values of the global list in the PIM with the changes.

{% code title="C#" overflow="wrap" %}

```csharp
    _apiClient.GlobalLists.UpdateGlobalListValues<SuppliersGlobalListModel>            (existingGlobalList.Uid, globalListValuesToUpdate.ToList());

```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.struct.com/tutorials/guides/how-to-use-struct-pims-api/use-of-global-list-endpoints.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
