All FarmBot resources (points, images, sequences, etc..) can be managed via the REST API. The Lua sandbox exposes the api() method to execute HTTP requests to the FarmBot API, providing a more convenient alternative to using http() and auth_token().

The example below shows how a user could delete all images associated with their account. This may be particularly useful after performing many high-throughput operations, such as full garden scans for research purposes.

There is no undo!

Once you clear images from your account, they are gone forever.

url = "/api/images/"
images = api({url = url})
job_name = "Deleting " .. tostring(#images) .. " Images"

set_job(job_name)

for k, image in ipairs(images) do
    set_job(job_name, {
      percent = math.floor((k / #images) * 100)
    })
    debug("Deleting image #" .. image.id)
    api({url = url .. image.id, method = "DELETE"})
    wait(500)
end

complete_job(job_name)