API Function: update

The update function updates an emission record in Greenlit that has been created by your App.

See record fields for more information on the fields both required and returned.

Required fields for each record are: iid, map_record, record_date, record_value, record_identifier.

iid is the record ID in the database, and ensures the correct record is updated.

Example JSON request for this function:

{
    "action": "update", // string
    "user": "api@greenlit.org.nz", // email string
    "production": "YmU9U5evebUbUjagydejU3Ehuna2a2", // string
    "key": "50d95141da41a5e502ada5c7da7de33d" // string
    "records": {}, // empty
    "data": { // array of records, see record fields for details
        "0": {
            "iid": 576, // * REQUIRED
            "map_record": 58, // * REQUIRED
            "record_date": 1693215973, // * REQUIRED
            "record_value": 304, // * REQUIRED
            "record_value_multiplier": 0, // optional
            "record_identifier": "An updated record", // * REQUIRED
            "department": 6, // optional
            "tracking": 0  // optional
        }
    }
}

Example JSON response for this function:

{
    "status": "success", // or partial, or error
    "error": "", // string message
    "data": [ // array of records that are created
        {
            "iid": "576",
            "production_id": "191",
            "created_on": "1693215973",
            "created_by": "71",
            "emission_factor": "505",
            "map_used": "2",
            "map_record": "58",
            "record_dom": "0",
            "record_date": "1693215973",
            "record_milestone": "0",
            "record_value": "304",
            "record_value_multiplier": null,
            "record_actual": "1",
            "record_aggregate": "0",
            "record_identifier": "An updated record",
            "record_offset": "0",
            "record_offset_cost": null,
            "tool_locked": "",
            "tool_record": "0",
            "tool_updated": "0",
            "api_app": "1",
            "api_updated": "1693215973",
            "dropped": "0",
            "department": "6",
            "tracking": "0",
            "country": "169"
        }
        // ... more records
    ],
    "actions": [ // specific success or error details about each record.
        {
            "iid": "576",
            "action": "update",
            "status": "success",
            "error": "" // string
        }
    ],
    "lookups": {
        "tracking": {
            "2": "A tracker",
            // ... trackers associated with production
        },
        "department": {
            "1": "Production",
            // ... all departments
        },
        "map_record": {
            "58": {
                "iid": "58",
                "category": "9",
                "level_2": "Hotel",
                "level_3": "Vietnam",
                "level_4": "",
                "factor": "401",
                "co2e": "0.224697",
                "co2": "0.220883",
                "ch4": "0.000295203",
                "n2o": "0.00351882",
                "unit": "rooms",
                "unit_multiplier": "nights",
                "scope": "3"
            },
            // ... map records associated with records
        },
        "category": {
            "9": "Accommodation",
            // ... categories associated with records
        }
    }
}

No luck what you're looking for?

Let us know details about your question. We'll get back to you!