Ledger

Since 6.1.0:

Ledger provides device to cloud and cloud to device data synchronization. See Ledger for an introduction to Ledger.

You will typically request a ledger using Particle.ledger() like this:

Ledger sensors;

void setup() {
    sensors = Particle.ledger("sensors");
}

The Particle.ledger function is asynchronous and the data will not be available until the device comes online and has synchronized with the cloud.

The type of ledger (device-to-cloud or cloud-to-device), as well as the ledger scope (organization, product, or device) is determined when the ledger is created on the cloud side, so it is not specified when you request the ledger. You must first create a ledger definition in the cloud; you cannot create a new ledger definition using the device-side API.

The first time a device comes online specifying a device to cloud ledger, a new ledger instance will be created for the device, however.

You will typically store the Ledger object you receive from Particle.ledger() as a global variable so you can access it again later easily.

Ledger names consist only of lowercase alphanumeric and dash, up to 32 characters, and are unique across all scopes.