---
title: "Client Credentials Flow for Microsoft Graph"
canonical: "https://help.agiloft.com/space/HELP/127434860/Client+Credentials+Flow+for+Microsoft+Graph"
format: markdown
---
This article guides you through the steps required to integrate Agiloft CLM with Exchange Online mailboxes using the Microsoft Graph API with OAuth 2.0 client credentials grant flow. Since most systems benefit from setting up an outbound account and at least one inbound account, the instructions set up both outbound and inbound email.

> Macro (include)

> ℹ️ **Prerequisites**
> ℹ️ 
> ℹ️ - To complete the setup, you need admin access to the Entra admin center with permission to configure new applications. You also need admin access to Exchange Online with permission to configure role-based access control for applications.
> ℹ️ - We recommend you create at least one separate email account exclusively for use with Agiloft CLM.
> ℹ️   - At a minimum, you need one account to use as the default outbound address.
> ℹ️   - If you're setting up inbound email, you need an account to use as the inbound address. You can use the same mailbox for both outbound and inbound email. Many systems create an address like table_name@yourdomain.com, such as contracts@yourdomain.com for the Contracts table, and use this address for both inbound and outbound email.
> ℹ️   - Accounts used for inbound email must use an “inbox” folder. Agiloft can’t be configured to access to other folders.
> ℹ️   - If you plan to set up additional inbound or outbound accounts, you also need email accounts for those addresses. The setup of multiple outbound accounts is rarely implemented in Agiloft CLM. For information on using them, see [Add Optional Outbound Accounts for Tables](https://agiloft-public.atlassian.net/wiki/spaces/HELP/pages/43714505). Instructions for connecting multiple inbound accounts are included in this article.
> ℹ️   - Though you can use the same email address for the default outbound account and one inbound account, you can't use the same address for multiple inbound accounts. To minimize issues, prevent collisions, and ensure incoming messages are routed correctly, each table must have a distinct inbox.

# > Macro (anchor)

Register Agiloft CLM in Entra

Before setting up email in Agiloft CLM, you need to register Agiloft CLM as an app in Entra ID.

> ℹ️ If the options you see in the admin center or your practices for registering applications differ from those described here, refer to Microsoft's [documentation](https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app) on app registration to complete the task.

1. Sign in to the Entra admin center as an administrator with permission to configure new applications.
2. If your account has access to multiple tenants, make sure the appropriate tenant is selected.
3. Go to **Identity > Applications > App registrations** and select New registration.
4. Enter a name for the registration. For example, you might name your registration "Agiloft Graph Email."
5. Select the appropriate option for which accounts can use the application. This choice depends on the IT security policy for your organization.
6. Leave the Redirect URI empty.
7. Click Register. The admin center automatically directs you to the overview page for the Agiloft application.
8. Copy the Application (client) ID and Directory (tenant) ID from the overview page. Store these in a note so you can refer to them later.
9. Next, generate a client secret:
  1. Click Certificates & secrets in the sidebar.
  2. On the Client secrets tab, click New client secret.
  3. Enter a description, select the longest available expiration date, and then click Add. When the secret does expire, you'll need repeat this step to generate a new secret and update your email configuration with the new value. See [Replacing an Expired Client Secret](https://agiloft-public.atlassian.net/wiki/spaces/HELP/pages/43719338/Email+Troubleshooting#replace_secret) for instructions.
  4. Copy the secret value and store it in a note so you can refer to it later. You won't be able to access it after this point.
10. You can also click API Permissions in the sidebar and remove the User.Read permission if it's configured. It is not needed.

Now that Agiloft is registered, you can configure access to the app.

# > Macro (anchor)

Configure the App

Now that the app is registered, the next step is to configure role-based access control (RBAC) to give your email accounts permission to access the new application. To set up RBAC, you use the Exchange Online PowerShell (EXO) module to create a new service principal. Then add a management scope for each email account and assign roles to the scopes.

Follow the steps below to set up RBAC. The EXO commands you run differ depending on whether you use separate email accounts for outbound and inbound email or share one account for both. The commands apply the Mail.Send permission to the outbound account and Mail.ReadWrite to the inbound account, as write permission is required for Agiloft to mark items as read.

1. First, make sure you have the following Entra application and email account details available. You’ll need these values when you run the EXO commands:
  - **Client ID**: The Application (client) ID from your note.
  - **Object ID**: The Object ID for the Enterprise application. This is not the same as the Object ID in the App registration. To get the enterprise Object ID, go to **Identity > Applications > Enterprise applications** in Entra, select the application for Agiloft and view the Overview, then copy the Object ID.
  - **Inbound Email Address**: The email address for the inbound account.
  - **Outbound Email Address**: The email address for the outbound account. You might just have one email address if you use the same account for inbound and outbound email.
2. Next, follow Microsoft's [instructions](https://learn.microsoft.com/en-us/powershell/exchange/exchange-online-powershell-v2?view=exchange-ps#install-the-exo-v2-module) to connect to the EXO module. When you connect, make sure the -UserPrincipalName is an admin user with permission to create service principals, scopes, and roles.
3. Execute one of the following sets of commands, depending on whether you're using one email account for both inbound and outbound email or two separate accounts. In the commands, substitute the CLIENT_ID, OBJECT_ID, and EMAIL_ADDRESS placeholders with the values you obtained in step 1:
  - **To configure one account for both inbound and outbound email, run these commands**:
  - **To configure two email accounts (one for inbound and one for outbound), run these commands: **
4. If you have additional inbound accounts to set up, you can repeat the following lines for each additional account:
5. You can test the new role and scope settings by running any of the following applicable commands:
  For example:

Now that access control is in place, you can set up outbound email in Agiloft.

# > Macro (anchor)

Set Up Outbound Email

Follow the steps below to set up the default outbound account in Agiloft. You need the Application (client) ID, Directory (tenant) ID, and Client secret you copied when registering Agiloft in Entra.

1. In Agiloft, go to **Setup > System > Manage Global Variables.**
2. Go to the Variables with Default Values tab and edit the [Custom SMTP Configuration Properties](https://agiloft-public.atlassian.net/wiki/spaces/HELP/pages/43713942/Global+Variables+List#mail_smtp_custom_options) global variable. To make things easier, maximize the modal window and drag the bottom corner of the Global Variable Value input box to make it bigger.
3. Paste this code into the Global Variable Value input box. Do not save it yet.

> 📝 The code below is for services hosted in Microsoft’s standard commercial cloud (microsoft.com). If your services are hosted in a sovereign cloud, use the code in [Sovereign Cloud Custom SMTP Configuration Properties](#sovereign_smtp_properties) instead.

```plaintext
# main setting and auth
mail.smtp.auth.mechanisms=XOAUTH2
mail.agiloft.smtp.auth_flow=skip
# Extended logging for troubleshooting
mail.agiloft.smtp.trace=false
mail.agiloft.smtp.client.id=CLIENT_ID
mail.agiloft.smtp.tenant.id=TENANT_ID
# DO NOT specify in case the refresh token long live time is undefined!
# mail.agiloft.smtp.refresh-token.llt=
# authorization request
mail.agiloft.smtp.device-auth-request.url=https://login.microsoftonline.com/${mail.agiloft.smtp.tenant.id}/oauth2/v2.0/token
mail.agiloft.smtp.device-auth-request.payload.1=client_id=${mail.agiloft.smtp.client.id}
mail.agiloft.smtp.device-auth-request.payload.2=scope=https://graph.microsoft.com/.default
mail.agiloft.smtp.device-auth-request.payload.3=client_secret=CLIENT_SECRET
mail.agiloft.smtp.device-auth-request.payload.4=grant_type=client_credentials
mail.agiloft.smtp.device-auth-request.response.user_code.name=code
# device access token request
mail.agiloft.smtp.device-token.url=https://login.microsoftonline.com/${mail.agiloft.smtp.tenant.id}/oauth2/v2.0/token
mail.agiloft.smtp.device-token.payload.1=client_id=${mail.agiloft.smtp.client.id}
mail.agiloft.smtp.device-token.payload.2=scope=https://graph.microsoft.com/.default
mail.agiloft.smtp.device-token.payload.3=client_secret=CLIENT_SECRET
mail.agiloft.smtp.device-token.payload.4=grant_type=client_credentials
mail.agiloft.smtp.device-token.response.access_token.name=access_token
mail.agiloft.smtp.device-token.response.expire.name=expires_in
# new token and refresh token
mail.agiloft.smtp.device-token-refresh.url=https://login.microsoftonline.com/${mail.agiloft.smtp.tenant.id}/oauth2/v2.0/token
mail.agiloft.smtp.device-token-refresh.payload.1=client_id=${mail.agiloft.smtp.client.id}
mail.agiloft.smtp.device-token-refresh.payload.2=scope=https://graph.microsoft.com/.default
mail.agiloft.smtp.device-token-refresh.payload.3=client_secret=CLIENT_SECRET
mail.agiloft.smtp.device-token-refresh.payload.4=grant_type=client_credentials
mail.agiloft.smtp.device-token-refresh.response.access_token.name=access_token
mail.agiloft.smtp.device-token-refresh.response.expire.name=expires_in
```

4. Locate the following placeholders and replace them with your credentials. Make sure to replace only the placeholder text. Do not remove the equals sign (=) or any other text on the line.
  - **CLIENT_ID**: In line 6, replace `CLIENT_ID` with your Application (client) ID.
  - **TENANT_ID**: In line 7, replace `TENANT_ID` with your Directory (tenant) ID.
  - **CLIENT_SECRET**: In lines 14, 21, and 29, replace `CLIENT_SECRET` with your client secret value. Make sure you replace all three instances.
5. Click Finish to save your changes.
6. Now go to **Setup > Email and SMS > Configure Email Server**.
7. Set the SMTP server to: GRAPH
8. Leave the connection type and port at their default settings. They're not used by this server configuration.
9. In SMTP login, enter the email address for the outbound account.
10. Do not enter a password.
11. In Default outbound email address, enter the outbound email address again. The system will send all outgoing messages from this address.
12. Select the Reset checkbox at the bottom of the screen, then click Finish.
13. A confirmation message appears. If you see an error instead, read the message carefully to troubleshoot the problem.
14. Click the link to finish the wizard, then click Configure Email Server.
15. Enter an email address to send a test message to, then click Finish.

If the test is successful, the browser displays a success message. If the test fails, the browser displays an error message that describes the issue. Review the configuration and make sure the information is complete and correct.

Now that the default outbound account is set up, continue to the appropriate next step:

- If you're enabling inbound email, proceed to [Set Up Inbound Email](#inbound_setup) below.
- If you're not enabling inbound email, see [Recommended Email Setup](https://agiloft-public.atlassian.net/wiki/spaces/HELP/pages/43719340).

# > Macro (anchor)

Set Up Inbound Email

> Macro (include)

You need the Application (client) ID, Directory (tenant) ID, and Client secret you copied previously.

1. Go to **Setup > Email and SMS > Inbound Email Accounts**. This list includes all existing inbound email accounts for all tables.
2. Edit the demo configuration for Contract. If you already configured Contract and are adding another inbound account, select a different demo configuration to modify or click New to create a new configuration.
3. On the Table tab, if the table isn't already selected because this is a new configuration, select the table that will receive inbound email. If you're editing an existing configuration, the table is already selected.
4. Click Next.
5. On the Server tab, select IMAP and enter: GRAPH
6. Select the SSL/TLS connection checkbox.
7. Confirm that Custom Port is set to 993.
8. Paste the following code into the text input box. If the input box isn't shown, go to the last tab and click Finish. Then reopen this configuration and return to the Server tab, which now displays the input box.

> 📝 The code below is for services hosted in Microsoft’s standard commercial cloud (microsoft.com). If your services are hosted in a sovereign cloud, use the code in [Sovereign Cloud Inbound Server Configuration Properties](#sovereign_server_properties) instead.

```plaintext
# main setting and auth
mail.inbound.auth.mechanisms=XOAUTH2
mail.agiloft.inbound.auth_flow=skip
# Extended logging for troubleshooting
mail.agiloft.inbound.trace=false
mail.agiloft.inbound.client.id=CLIENT_ID
mail.agiloft.inbound.tenant.id=TENANT_ID
# DO NOT specify in case the refresh token long live time is undefined!
# mail.agiloft.inbound.refresh-token.llt=
# authorization request
mail.agiloft.inbound.device-auth-request.url=https://login.microsoftonline.com/${mail.agiloft.inbound.tenant.id}/oauth2/v2.0/token
mail.agiloft.inbound.device-auth-request.payload.1=client_id=${mail.agiloft.inbound.client.id}
mail.agiloft.inbound.device-auth-request.payload.2=scope=https://graph.microsoft.com/.default
mail.agiloft.inbound.device-auth-request.payload.3=client_secret=CLIENT_SECRET
mail.agiloft.inbound.device-auth-request.payload.4=grant_type=client_credentials
mail.agiloft.inbound.device-auth-request.response.user_code.name=code
# device access token request
mail.agiloft.inbound.device-token.url=https://login.microsoftonline.com/${mail.agiloft.inbound.tenant.id}/oauth2/v2.0/token
mail.agiloft.inbound.device-token.payload.1=client_id=${mail.agiloft.inbound.client.id}
mail.agiloft.inbound.device-token.payload.2=scope=https://graph.microsoft.com/.default
mail.agiloft.inbound.device-token.payload.3=client_secret=CLIENT_SECRET
mail.agiloft.inbound.device-token.payload.4=grant_type=client_credentials
mail.agiloft.inbound.device-token.response.access_token.name=access_token
mail.agiloft.inbound.device-token.response.expire.name=expires_in
# new token and refresh token
mail.agiloft.inbound.device-token-refresh.url=https://login.microsoftonline.com/${mail.agiloft.inbound.tenant.id}/oauth2/v2.0/token
mail.agiloft.inbound.device-token-refresh.payload.1=client_id=${mail.agiloft.inbound.client.id}
mail.agiloft.inbound.device-token-refresh.payload.2=scope=https://graph.microsoft.com/.default
mail.agiloft.inbound.device-token-refresh.payload.3=client_secret=CLIENT_SECRET
mail.agiloft.inbound.device-token-refresh.payload.4=grant_type=client_credentials
mail.agiloft.inbound.device-token-refresh.response.access_token.name=access_token
mail.agiloft.inbound.device-token-refresh.response.expire.name=expires_in
```

9. Locate the following placeholders and replace them with your credentials:
  - **CLIENT_ID**: In line 6, replace `CLIENT_ID` with your Application (client) ID.
  - **TENANT_ID**: In line 7, replace `TENANT_ID` with your Directory (tenant) ID.
  - **CLIENT_SECRET**: In lines 14, 21, and 29, replace `CLIENT_SECRET` with your client secret value. Make sure you replace all three instances.
10. Click Next. If the following warning appears, you can safely ignore it:  
`Warning. Status: Communication established with GRAPH:GRAPH.`  
`To sign in, use a web browser to open the page device-auth-request.response.verification_url.name_NOT_DEFINED_OR_NOT_RETURNED and enter the code device-auth-request.response.user_code.name_NOT_DEFINED_OR_NOT_RETURNED to authenticate.`
11. On the Account tab, enter the following:
  1. In the Email and Email Account fields, enter the complete inbound email address.
  2. Leave the Password field empty. If a series of dots has replaced a previously blank password, delete them.
  3. Under Activity, select This account is actively polling for emails. This enables Agiloft to read messages in the mailbox and pull them into the KB. When "Disable this account - do not check for emails" is selected, it means the inbound account still receives messages, but Agiloft won't access them to pull them into the system.
  4. If incoming messages are saved to a folder other than Inbox, enter the folder path where Agiloft should check for incoming emails.
  5. Click Next.
12. Confirm that a message appears stating the account is valid. If you see an error message, retrace your steps and check your work.
13. Go to the last tab and click Finish. The default settings on the rest of the tabs are ideal for most use cases, and we don't recommend that you change them.

For more information on how Agiloft checks inbound email, see [Inbound Email Processing](https://agiloft-public.atlassian.net/wiki/spaces/HELP/pages/43719338/Email+Troubleshooting#check_inbound_email).

If you want to set up an inbound account for another table, repeat the steps above. If you've finished setting up inbound accounts, see [Recommended Email Setup](https://agiloft-public.atlassian.net/wiki/spaces/HELP/pages/43719340).

# > Macro (anchor)

Sovereign Cloud Integrations

Integrating with Microsoft services hosted in a sovereign cloud requires additional customization when configuring the outbound email SMTP properties and inbound server properties. This section provides the code to use in place of the contents supplied in the outbound and inbound email setup instructions above. These templates include additional placeholders that need to be replaced.

## > Macro (anchor)

Sovereign Cloud Custom SMTP Configuration Properties

When setting the [Custom SMTP Configuration Properties](https://agiloft-public.atlassian.net/wiki/spaces/HELP/pages/43713942/Global+Variables+List#mail_smtp_custom_options) global variable, use the following content in place of the code shown in Step 3 in [Set Up Outbound Email](#outbound_setup). Replace each placeholder with the appropriate value for your cloud service. [Placeholder descriptions](#placeholder_descriptions) are provided below. 

```
# main setting and auth
mail.smtp.auth.mechanisms=XOAUTH2
mail.agiloft.smtp.auth_flow=skip
# Extended logging for troubleshooting
mail.agiloft.smtp.trace=false
mail.agiloft.smtp.client.id=CLIENT_ID
mail.agiloft.smtp.tenant.id=TENANT_ID
# DO NOT specify in case the refresh token long live time is undefined!
# mail.agiloft.smtp.refresh-token.llt=
# authorization request
mail.agiloft.smtp.device-auth-request.url=https://ENTRA_DOMAIN/${mail.agiloft.smtp.tenant.id}/oauth2/v2.0/token
mail.agiloft.smtp.device-auth-request.payload.1=client_id=${mail.agiloft.smtp.client.id}
mail.agiloft.smtp.device-auth-request.payload.2=scope=https://GRAPH_DOMAIN/.default
mail.agiloft.smtp.device-auth-request.payload.3=client_secret=CLIENT_SECRET
mail.agiloft.smtp.device-auth-request.payload.4=grant_type=client_credentials
mail.agiloft.smtp.device-auth-request.response.user_code.name=code
# device access token request
mail.agiloft.smtp.device-token.url=https://ENTRA_DOMAIN/${mail.agiloft.smtp.tenant.id}/oauth2/v2.0/token
mail.agiloft.smtp.device-token.payload.1=client_id=${mail.agiloft.smtp.client.id}
mail.agiloft.smtp.device-token.payload.2=scope=https://GRAPH_DOMAIN/.default
mail.agiloft.smtp.device-token.payload.3=client_secret=CLIENT_SECRET
mail.agiloft.smtp.device-token.payload.4=grant_type=client_credentials
mail.agiloft.smtp.device-token.response.access_token.name=access_token
mail.agiloft.smtp.device-token.response.expire.name=expires_in
# new token and refresh token
mail.agiloft.smtp.device-token-refresh.url=https://ENTRA_DOMAIN/${mail.agiloft.smtp.tenant.id}/oauth2/v2.0/token
mail.agiloft.smtp.device-token-refresh.payload.1=client_id=${mail.agiloft.smtp.client.id}
mail.agiloft.smtp.device-token-refresh.payload.2=scope=https://GRAPH_DOMAIN/.default
mail.agiloft.smtp.device-token-refresh.payload.3=client_secret=CLIENT_SECRET
mail.agiloft.smtp.device-token-refresh.payload.4=grant_type=client_credentials
mail.agiloft.smtp.device-token-refresh.response.access_token.name=access_token
mail.agiloft.smtp.device-token-refresh.response.expire.name=expires_in
mail.graph.endpoint=GRAPH_SERVICE_ENDPOINT
```

## > Macro (anchor)

Sovereign Cloud Inbound Server Configuration Properties

When setting inbound email server properties, use the following content in place of the code shown in Step 8 in [Set Up Inbound Email](#inbound_setup). Replace each placeholder with the appropriate value for your cloud service. [Placeholder descriptions](#) are provided below.

```
# main setting and auth
mail.inbound.auth.mechanisms=XOAUTH2
mail.agiloft.inbound.auth_flow=skip
# Extended logging for troubleshooting
mail.agiloft.inbound.trace=false
mail.agiloft.inbound.client.id=CLIENT_ID
mail.agiloft.inbound.tenant.id=TENANT_ID
# DO NOT specify in case the refresh token long live time is undefined!
# mail.agiloft.inbound.refresh-token.llt=
# authorization request
mail.agiloft.inbound.device-auth-request.url=https://ENTRA_DOMAIN/${mail.agiloft.inbound.tenant.id}/oauth2/v2.0/token
mail.agiloft.inbound.device-auth-request.payload.1=client_id=${mail.agiloft.inbound.client.id}
mail.agiloft.inbound.device-auth-request.payload.2=scope=https://GRAPH_DOMAIN/.default
mail.agiloft.inbound.device-auth-request.payload.3=client_secret=CLIENT_SECRET
mail.agiloft.inbound.device-auth-request.payload.4=grant_type=client_credentials
mail.agiloft.inbound.device-auth-request.response.user_code.name=code
# device access token request
mail.agiloft.inbound.device-token.url=https://ENTRA_DOMAIN/${mail.agiloft.inbound.tenant.id}/oauth2/v2.0/token
mail.agiloft.inbound.device-token.payload.1=client_id=${mail.agiloft.inbound.client.id}
mail.agiloft.inbound.device-token.payload.2=scope=https://GRAPH_DOMAIN/.default
mail.agiloft.inbound.device-token.payload.3=client_secret=CLIENT_SECRET
mail.agiloft.inbound.device-token.payload.4=grant_type=client_credentials
mail.agiloft.inbound.device-token.response.access_token.name=access_token
mail.agiloft.inbound.device-token.response.expire.name=expires_in
# new token and refresh token
mail.agiloft.inbound.device-token-refresh.url=https://ENTRA_DOMAIN/${mail.agiloft.inbound.tenant.id}/oauth2/v2.0/token
mail.agiloft.inbound.device-token-refresh.payload.1=client_id=${mail.agiloft.inbound.client.id}
mail.agiloft.inbound.device-token-refresh.payload.2=scope=https://GRAPH_DOMAIN/.default
mail.agiloft.inbound.device-token-refresh.payload.3=client_secret=CLIENT_SECRET
mail.agiloft.inbound.device-token-refresh.payload.4=grant_type=client_credentials
mail.agiloft.inbound.device-token-refresh.response.access_token.name=access_token
mail.agiloft.inbound.device-token-refresh.response.expire.name=expires_in
mail.graph.endpoint=GRAPH_SERVICE_ENDPOINT
```

## > Macro (anchor)

Placeholder Descriptions

This section describes the placeholders to replace in the code. Make sure to replace only the placeholder text. Do not remove the equals sign (=) or any other surrounding text.

**CLIENT_ID**  
In line 6, replace `CLIENT_ID` with your Application (client) ID.

**TENANT_ID**  
In line 7, replace `TENANT_ID` with your Directory (tenant) ID.

**CLIENT_SECRET**  
In lines 14, 21, and 29, replace `CLIENT_SECRET` with your client secret value.

**ENTRA_DOMAIN**  
In lines 11, 18, and 26, replace `ENTRA_DOMAIN` with the [Entra authorization endpoint](https://learn.microsoft.com/en-us/entra/identity-platform/authentication-national-cloud#microsoft-entra-authentication-endpoints) domain for your cloud deployment. The table below lists the values for each cloud. 

| **Cloud** | **Entra Domain** |
| --- | --- |
| Microsoft Entra ID for US Government | login.microsoftonline.us |
| Microsoft Entra China operated by 21Vianet | login.partner.microsoftonline.cn |

**GRAPH_DOMAIN**  
In lines 13, 20, and 28, replace `GRAPH_DOMAIN` with the Graph service domain for your cloud deployment. The table below lists the values for each cloud.

| **Cloud** | **Graph Domain** |
| --- | --- |
| Microsoft Graph for US Government L4 (GCC High) | graph.microsoft.us |
| Microsoft Graph for US Government L5 (DOD) | dod-graph.microsoft.us |
| Microsoft Graph China operated by 21Vianet | microsoftgraph.chinacloudapi.cn |

**GRAPH_SERVICE_ENDPOINT**  
In line 33, replace `GRAPH_SERVICE_ENDPOINT` with the service root endpoint for your [Microsoft Graph national cloud deployment](https://learn.microsoft.com/en-us/graph/deployments). The table below lists the endpoints for each cloud.

| **Cloud** | **Graph Endpoint** |
| --- | --- |
| Microsoft Graph for US Government L4 (GCC High) | https://graph.microsoft.us/v1.0 |
| Microsoft Graph for US Government L5 (DOD) | https://dod-graph.microsoft.us/v1.0 |
| Microsoft Graph China operated by 21Vianet | https://microsoftgraph.chinacloudapi.cn/v1.0 |

#### Related articles

> Macro (contentbylabel)