APIPull maps data from preselected Machines through a schema and exposes it to external systems through GET requests. Use [API Pull Query](pull-query) to select Machines with search conditions for each request.

## Create a definition

1. As an owner, open [Integrations](https://now.obniz.com/integrations), add an Integration, and select `APIPull`.
2. Select Machines and enter a display prefix. Selecting multiple Machines creates a definition and retrieval URL for each one.
3. Configure the [schema](integration#schema-settings), timestamp, and identification settings. Check the mapping with `Transform Data`, then save.
4. Open the created definition from the list and check its generated endpoint.

Enable `Fetch Latest Only` under `Advanced Settings` to retrieve current States. When disabled, the source is State history since the previous retrieval. This is not an API for retrieving an entire arbitrary historical period.

## Retrieve from an external system

Create an [API key](../settings/apikeys) with Read permission for `integrations`, and request the displayed URL from your server.

```http
GET /api/1/integrations/<Integration ID>/data
Authorization: Bearer <Account API Token>
```

The result depends on the schema and configuration. Keep the API token on your server. Regular APIPull consumes quota for each valid retrieval, so choose an appropriate polling interval.

For 401, check authentication; for 403, check that the definition is enabled; for 404, check its ID and Account; for 402, check quota. If output is empty, check the Machine States and schema.
