---
title: Resolving macros using the API
related:
  - https://docs.kentico.com/k9/macro-expressions/extending-the-macro-engine.md
  - https://docs.kentico.com/k9/macro-expressions/macro-syntax.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

If you need to process macro expressions inside text values in your custom code, use the **MacroResolver.Resolve** method. Specify the string where you want to resolve macros as the method's input parameter.

For example:

```csharp

using CMS.MacroEngine;

...

// Resolves macros in the specified string using a new instance of the global resolver
string resolvedTextGlobal = MacroResolver.Resolve("The current user is: {% CurrentUser.UserName %}");


```

> **Info:** The method evaluates the macros using a new instance of the global resolver and automatically ensures thread-safe processing.
>
> Macro resolvers are system components that provide the processing of macros. The resolvers are organized in a hierarchy that allows child resolvers to inherit all macro options from the parent. The global resolver is the parent of all other resolvers in the system.

### Resolving localization macros

If you only need to resolve [localization macros](https://docs.kentico.com/k9/multilingual-websites/setting-up-a-multilingual-user-interface/localizing-text-fields.md) in text, call the **ResHelper.LocalizeString** static method.

```csharp

using CMS.Helpers;

...

// Resolves localization macros in text
string localizedResult = ResHelper.LocalizeString("{$general.actiondenied$}");

```
