---
title: newrelic_get_linking_metadata
source: https://docs.newrelic.com/docs/apm/agents/php-agent/php-agent-api/newrelicgetlinkingmetadata
---

## Syntax

```php
newrelic_get_linking_metadata()
```

Returns a collection of metadata necessary for linking data to a trace or an entity.

## Requirements

Requires PHP agent [version 9.3 or higher](https://docs.newrelic.com/docs/release-notes/agent-release-notes/php-release-notes).

Must be called inside a [transaction](https://docs.newrelic.com/docs/accounts-partnerships/education/getting-started-new-relic/glossary#transaction).

## Description

This call returns an opaque map of key-value pairs that can be used to correlate this application to other data in the New Relic backend.

## Examples

### Create a linking payload

Obtains the linking data and encodes it as JSON for exporting to tooling:

```php
if (extension_loaded('newrelic')) {
    $linking_md = newrelic_get_linking_metadata();
    $payload = json_encode($linking_md);
}
```
