---
updatedAt: 2025-11-11T01:47:22.000Z
agentTools:
  projectIndex: https://docs.formant.io/llms.txt
---

# Automated provisioning

While the Formant administrative panel can be used to manually provision and configure devices, a scaling fleet will benefit from automating this process.

Administrator users and service accounts can use `fctl` to automatically create devices and retrieve new provisioning tokens. The automated provisioning workflow can be used to create new devices, or to re-provision existing devices.

> 📘 Installing fctl
>
> This section requires `fctl`. To install it, see [Installing and credentialing fctl](https://docs.formant.io/reference/fctl).

# Recommended usage

* Generating a provisioning token to insert during build-time of a new OS image
* With a provisioning service that uses Formant administrator service account credentials to generate new provisioning tokens for devices in your fleet

# Automated provisioning workflow

> 🚧 Agent re-provisioning may take up to 5 minutes to propagate
>
> When re-provisioning a device, it may take several minutes for the new device credentials to propagate through Formant's servers. At first, the newly re-provisioned agent's requests to Formant servers will fail authentication and will output WARN logs.
>
> After 1-5 minutes, the agent will automatically restart and begin functioning as normal after propagation completes.

## 1. Verify `fctl` has administrator credentials

`fctl` must be credentialed with administrator user or service account credentials to use this automated provisioning workflow.

## 2. Create or re-provision the device

The following command will create new devices, or re-provision existing devices, and output a valid provisioning token.

```shell
fctl create device <device_name> --force --output json | jq -r .provisioningToken
```

The output of the above command will contain a valid provisioning token for the device. e.g.

```
$ fctl create device test.001 --force --output json | jq -r .provisioningToken
f57b7a2e0cc932dcd74ecb13145b865e
```

This provisioning token will last 72 hours before expiring.

## 3. Set the provisioning token environment variable

Set the `FORMANT_PROVISIONING_TOKEN` environment variable to the output of the above script.

For instance,

```shell
FORMANT_PROVISIONING_TOKEN=$(fctl create device test.002 --force --output json | jq -r .provisioningToken)
echo $FORMANT_PROVISIONING_TOKEN
```

## 4. Run the agent installation script

Now, run the native or docker installation with the `FORMANT_PROVISIONING_TOKEN` environment variable set.

#### Native installation

`bash <(wget -qO - https://app.formant.io/install-agent.sh) $FORMANT_PROVISIONING_TOKEN`

#### Docker installation

`bash <(wget -qO - https://app.formant.io/install-agent-docker.sh) $FORMANT_PROVISIONING_TOKEN`

# Configuring devices automatically

After using the automated provisioning workflow, you may want to automatically configure devices. See [Using fctl to configure devices](https://docs.formant.io/reference/using-fctl-to-configure-devices).