Documentation Index
Fetch the complete documentation index at: https://dev.1st.app/llms.txt
Use this file to discover all available pages before exploring further.
The 90-second version: open the AI prompt below, paste into
Claude/ChatGPT, paste the resulting code into Apps Script, set the API key
in PropertiesService, and run.
AI prompt
Read https://docs.1st.app/llms-full.txt.
Write a Google Apps Script that pulls last night's CO2 + temperature +
humidity readings for every sensor in my team and writes them to a sheet
called "Nightly readings". Columns: timestamp, room, co2_ppm, temp_c,
humidity_pct. Walk cursor pagination. Read ST_API_KEY from
PropertiesService (the key scopes the team — no team_id needed).
Schedule it to run daily at 6 AM via ScriptApp.newTrigger.
Handle each error `code` with Logger.log so I can debug.
What the AI produces (approximate template)
The output looks something like this — your AI will tune to your exact needs:
const API_BASE = "https://api.1st.app/v1";
function syncNightly() {
const props = PropertiesService.getScriptProperties();
const apiKey = props.getProperty("ST_API_KEY");
const now = new Date();
const start = new Date(now);
start.setDate(start.getDate() - 1);
start.setHours(0, 0, 0, 0);
const end = new Date(start);
end.setDate(end.getDate() + 1);
const sensors = apiGet(`/sensors`, apiKey).data;
const sheet = SpreadsheetApp.getActive().getSheetByName("Nightly readings");
sheet.clearContents();
sheet.appendRow(["timestamp", "room", "co2_ppm", "temp_c", "humidity_pct"]);
for (const sensor of sensors) {
const path = `/sensors/${sensor.sensor_id}/readings`;
const params = `?from=${start.toISOString()}&to=${end.toISOString()}`;
let cursor = null;
do {
const page = apiGet(path + params + (cursor ? `&cursor=${encodeURIComponent(cursor)}` : ""), apiKey);
page.data.forEach((r) => {
sheet.appendRow([r.bucket_at, sensor.display_name, r.co2_ppm, r.temp_c, r.humidity_pct]);
});
cursor = page.next_cursor;
} while (cursor);
}
}
function apiGet(path, apiKey) {
const resp = UrlFetchApp.fetch(API_BASE + path, {
headers: { Authorization: `Bearer ${apiKey}` },
muteHttpExceptions: true,
});
const body = JSON.parse(resp.getContentText());
if (resp.getResponseCode() >= 400) {
Logger.log(`API error: ${body.error.code} — ${body.error.message}`);
throw new Error(body.error.code);
}
return body;
}
Finish wiring it up
Set credentials
In the Apps Script editor:
- Project settings → Script properties.
- Add
ST_API_KEY with your 1st_sk_... value.
Wire up the trigger
In the Apps Script editor:
- Click Triggers (clock icon).
- Add Trigger → choose
syncNightly, time-driven, day timer,
6am–7am.
Done
Your sheet refreshes every morning. Open it tomorrow at 7am and the
“Nightly readings” tab will be populated with last night’s data.