CropPath for developers

All guides

Device and gateway onboarding

Available

Register a gateway and its devices, their keys and certificates, and get them approved so that their records count.

  1. Register the gateway with POST /v1/gateways (gateway_id, site, optionally facility) and each device with POST /v1/devices (device_id, profile, site, facility). An id must be unused by every company's devices and gateways. This needs a company admin's credential: an API token of role tenant_admin, or an API client with the device_admin scope.
  2. Create a P-256 key pair on each device or gateway (in a secure element in production) and register the public key with POST /v1/keys (kid, owner_type, owner_id and public_key_pem: one PUBLIC KEY PEM block). The private key never leaves the device.
  3. To send over MQTT, the device makes a certificate signing request (CSR) from that key with its id as the common name; CropPath's certificate authority signs it. No API route issues certificates: ask CropPath for the first one.
  4. Wait for CropPath's approval. A new device, gateway or key is pending until a CropPath admin approves it in the approval queue. Until then its messages are accepted and stored but count as Self-declared (device_not_approved). A key added later to an approved device or gateway stays pending until it is approved. The approval field of GET /v1/devices, GET /v1/gateways and GET /v1/keys shows the state.

MQTT with the Python SDK

The Python SDK (0.3.0) connects over MQTT with the device certificate. Download the Python SDK package from this portal's Downloads page (/developers/downloads), where it is listed under SDK packages with its SHA-256, as the Python SDK guide shows. On the first connection, a command the backend sends before the broker granted the command subscription is dropped, so wait for both before you trigger one:

transport.connect()                    # or agent.run_forever() on another thread
transport.wait_connected(20)           # True once the broker accepted the connection (CONNACK)
transport.wait_subscribed(20)          # True once the broker granted the command subscription (SUBACK)

Both return False on timeout. wait_subscribed raises TransportError when the broker refused the subscription, and after a reconnect it waits for the new grant.

In the API reference