The create function creates a new emission record in Greenlit.
See record fields for more information on the fields both required and returned.
Required fields for each record are: map_record, record_date, record_value, record_identifier.
If you include an iid in a record for creation, then it will change that record's create to an update.
Example JSON request for this function:
{
"action": "create", // 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": {
"map_record": 58, // * REQUIRED
"record_date": 1693215973, // * REQUIRED
"record_value": 304, // * REQUIRED
"record_value_multiplier": 0, // optional
"record_identifier": "A unique string", // * REQUIRED
"department": 6, // optional, defaults to 1 = production
"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": "A unique string",
"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": "create",
"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
}
}
}