# JSON sources

> Let any tool deliver its data to RackTrace in an open JSON format, also from inside a customer’s network.

URL: https://docs.racktrace.io/integrations/json-sources

Tools other than UniFi can deliver the same information to RackTrace in an open JSON format.

## Push and pull sources

Any tool can deliver the same data in an open JSON format. On the **JSON** tab:

- **New push source**: the tool sends its data to RackTrace. Give it a name and click **Create**. Copy the token straight away; it is shown only once. The tool sends `POST /api/ingest` with `Authorization: Bearer <token>`.
- **New pull source**: RackTrace fetches the data from an HTTPS **URL**, optionally with a **Bearer token**, every **Refresh every (minutes)**.

Each scope in the JSON appears under **Scopes**; link it to a tenant, location and network like a UniFi site. The card **Format “racktrace-discovery” v1** describes the format with an example. Each delivery replaces the earlier data of that scope.

A port can also say how it is set: `label` (its own name), `poe_mode` (`on`, `off`, `passive 24V`), `enabled` (`false` = switched off) and `lag` (e.g. `LAG 49+50`). Tick **keep in sync** at the source and linked devices take these over with every delivery, together with serial, IP, MAC and the VLANs (see [The documentation follows the network](https://docs.racktrace.io/integrations/discovery#docs-sync)).

A delivery can say when the tool observed the network: `observed_at` (an ISO time) for the whole delivery or per scope. RackTrace keeps it next to the time it received the delivery in [Changes seen in the network](https://docs.racktrace.io/integrations/discovery#changes). A time more than 5 minutes ahead or more than 24 hours ago is refused; without it, the time of receipt is used.

Is the tool only reachable inside the customer's network? Use the [RackTrace agent](https://docs.racktrace.io/integrations/json-sources#agent).

## The RackTrace agent for sources inside a network

RackTrace cannot reach addresses inside your network, such as an inventory server or an export on a file server. The agent can: it runs on a computer or server there, fetches the JSON and pushes it to a push source. It only needs outgoing HTTPS, so nothing has to be opened in the firewall.

1. Create a **push source** and copy its token. The token dialog also shows an `agent.json` with the token filled in.
2. In the card **Agent for addresses in your own network**, click **Download the agent** and put `agent.json` next to it. It is one file and needs Node.js 18 or newer.
3. Run `node racktrace-agent.mjs --check` to test the internal address and the token without sending anything.
4. Run it as a service (`node racktrace-agent.mjs`, systemd or Docker), or every 15 minutes with `--once` from cron or Task Scheduler.

The source then shows the agent, its version and its last contact. When the agent cannot reach the internal address, that error is shown with the source.
