Beta guide
Using Baselog with an API key
This guide is for accounts that can use API keys. Work with Baselog products, exclusions, alert rules and metric summaries over HTTP from your scripts or servers. This is a beta, so routes and limits may change.
1. Get started
- Create a key in Settings > API keys (Beta). Pick a name, target products, scopes and expiry. Selecting all scopes includes deletion and future permissions allowed for your account.
- The full key is shown once, right after you create it. Put it in a secret store or environment variable. If you lose it, create a new one.
- The API address is
https://adventurous-badger-961.convex.site/api/v1.
First request - read the key's target products.
read -rs BASELOG_API_KEY && export BASELOG_API_KEY # paste the key, press Enter - not shown or kept in shell history
curl -s -H "Authorization: Bearer $BASELOG_API_KEY" "https://adventurous-badger-961.convex.site/api/v1/products"2. Keys and authentication
- Send
Authorization: Bearer <key>on every request. Avoid debug output that prints headers, such ascurl -vorset -x- it exposes the key. - Store the key as an opaque string (up to 255 characters). Don't parse it - the format may change.
- Each key has target products. Other products return 403. A key with
products:createcan start with no targets, and products it creates also become targets. A key can target up to 50 individually selected products. All products covers every current and future product you own. - Keys expire after 90 days by default, 365 at most. There's no renewal - create a new key.
- Accounts whose trial or subscription has ended can only pick read scopes, and writes with existing keys return
READ_ONLY. They work again after you resubscribe. - Revoke keys you no longer use in Settings. Requests fail with 401 right after. You can have up to 10 active keys.
3. Scopes
A key can hold several scopes. The key screen starts with read scopes only. Add only what you need.
| Scope | What it allows |
|---|---|
products:read | List and read products |
products:create | Create a product |
products:write | Change product settings (name, platforms, route templates, events, activation, primary KPI) |
exclusions:read · create · delete | Read, add and remove visitors or users excluded from counts |
alerts:read · create · write · delete | Read, create, change and delete alert rules |
metrics:read | Read metric summaries |
4. Routes
| Method and path | Scope | Notes |
|---|---|---|
GET /products | products:read | Filter with ?platform=web|ios|android |
GET /products/<id> | products:read | |
POST /products | products:create | { name, slug, platforms } |
PATCH /products/<id> | products:write | Only the fields you send change |
GET · POST /products/<id>/exclusions | exclusions:read · create | { profileId } - 100 per product |
DELETE /products/<id>/exclusions/<exclusionId> | exclusions:delete | |
GET · POST /products/<id>/alerts | alerts:read · create | Created turned off. 20 per product |
GET · PATCH · DELETE /products/<id>/alerts/<alertId> | alerts:read · write · delete | An enabled rule only accepts { "enabled": false } |
GET /products/<id>/metrics | metrics:read | ?range=7|30|90 (default 30) applies to untrusted.breakdown only |
GET /metrics/weekly | metrics:read | Compare two completed weeks for products covered by the key with ?week=YYYY-Www&cursor=… |
- Turning alerts on, deleting a product, changing the site address or allowed origins, and issuing collection keys stay in the app. An enabled alert sends email when its condition is met, so a person turns it on.
- Metric summaries read stored default results (
overview,timeseries,untrusted.breakdown). If you getpending: true, a result is missing or being recalculated - read it again a little later.
Weekly metric comparison
GET https://adventurous-badger-961.convex.site/api/v1/metrics/weekly?week=2026-W47Omit week to read the last completed ISO week in Asia/Seoul. Both previous and current start on Monday and end before the next Monday. The API returns 400 for unfinished weeks or when retention cannot cover both weeks.
An all-target key reads up to 50 products per page. When cursor is present, pass it with the response's week on the next request, even if items is empty. URL-encode the cursor before adding it to the query string, for example with encodeURIComponent(cursor). A key limited to specific products returns a single page.
Unique visitors, unique users, and activated users are daily averages (daily_average). Signups and first payments are sums of daily counts for each week (daily_sum). The API calculates delta as current - previous.
If a value is null, check its status. pending and stale indicate that a refresh is needed. not_collected means the product does not collect the metric. insufficient_history means the product has no first recorded event or collection started after midnight in Asia/Seoul on the first day of the comparison period. The API returns null for previous, current, and delta because the available history cannot cover both full weeks.
First payment is the earliest payment observed for a profile in 400 days. Earlier payments may predate collection, fall outside retention, or have yet to arrive. Both weeks must fall within the 32 days before the snapshot date. Outside that window, only first payment is unavailable.
Metric, change verdict, alert explanation, and analysis suggestion drafts
An operator key needs metrics:read and the draft scope for the same product. The routes below start at /products/<id>/agent-drafts.
| Request | Draft scope | Input |
|---|---|---|
| GET list | agentDrafts:read | Required status=draft|edited|accepted|discarded. Up to 20 newest drafts. Pass cursor for the next page. |
GET /<draftId> | agentDrafts:read | Read the body at item.untrusted.payload.body. |
| POST | agentDrafts:create | { week, body, evidenceId, agentName } · { kind, verdict, body, evidenceId, agentName } · { kind, body, evidenceId, agentName } |
PATCH /<draftId> | agentDrafts:write | { revision, body }. Only the key that created the draft can edit it. |
Request a draft when the result for the same product and week is ready and its evidenceId is a string. While first_paid is pending, the overall status can be ready with a null evidenceId. Fetch the same week again after the metrics refresh. The body can contain up to 2,000 characters. Distinguish observations from possible causes and leave out customer identifiers.
For change verdict evidence, call GET /products/<id>/annotations/<annotationId>/compare?days=7. Use a window of 7, 14, or 28 days. The response includes evidenceId for operator keys with metrics:read, annotations:read, and agentDrafts:read. The ID is a string when the comparison is ready and has at least one numeric metric.
For the same product, send kind: change_impact_verdict and verdict: effective | no_effect | hold. Listing, reading, and writing these drafts also requires the product's annotations:read scope. Use metrics with available comparison values as evidence. Keep customer emails, names, profiles, support messages, and individual event payloads out of drafts.
For alert explanation evidence, call GET /products/<id>/alert-events with agentDrafts:read, metrics:read, and alerts:read for the same product. It returns firing times and observations for up to 20 alerts from the last 14 days. Submit possible causes as kind: alert_explanation with the firing record’s evidenceId. Reading or writing these drafts also requires alerts:read.
For analysis suggestion evidence, call GET /products/<id>/analysis-inputs?type=funnel|alert_rule. Use agentDrafts:read, metrics:read, and either products:read for funnels or alerts:read for alert rules. Listing, reading, and writing suggestions also requires the read scope for that type. When the response is ready, review the allowed settings and metrics for up to seven completed days. A not_collected metric has no observed values within its full history. history_unknown means the collection history could not be verified.
For the same product, send kind: analysis_suggestion, type, body, evidenceId, and agentName. Funnels require steps and windowDays. Alert rules require alertKind and fields for that kind. Use metric, op, and value for threshold or change, hours for nodata, and events for instant. After acceptance, an operator reviews and saves the values in the existing form.
For a 409 with reason STALE, read the current revision. For LOCKED or CLOSED, stop editing. If the message is evidence_pending, wait for a refresh. For evidence_changed or evidence_expired, fetch the relevant weekly metrics, change comparison, alert firing record, or analysis inputs again. Accepting, discarding and deleting drafts requires a signed-in session.
5. Write rules
- POST, PATCH and DELETE require
Idempotency-Key(16-64 characters: letters, digits,-,_). Make a new value per request and reuse it when you retry the same request. - Retrying the same request with the same key doesn't write twice - it returns
{ id, replayed: true }. The same request means the same key, method, address (including query) and body. A different request with the same key returns 409. This holds for 30 days. - With
X-Dry-Run: true, the server checks scopes, limits and values, then returns{ dryRun: true }. Data and write records stay unchanged and the daily limit isn't used, but per-minute limits and the key's last-used time still count. NoIdempotency-Keyis needed. - Bodies are JSON (up to 32KB). Unknown fields are rejected with 400.
curl -s -X POST "https://adventurous-badger-961.convex.site/api/v1/products/<id>/alerts" \
-H "Authorization: Bearer $BASELOG_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-H "X-Dry-Run: true" \
-d '{"kind":"threshold","metric":"signups","op":"below","value":1}'6. Responses and errors
- Lists return
{ items: [...] }, single reads{ item: {...} }, deletes{ item: { _id, deleted: true } }. Metric summaries come as one object. - Write responses are
{ item: {...} }, and which fields they carry depends on the resource and the key's scopes. Read the resource again with GET to confirm. - Time fields are epoch milliseconds.
- Values inside
untrusted(product names, site addresses, route templates, free-text dimensions such as referrers) may have been written by someone else. Don't render them as HTML or run them as commands.
| Status | code | Meaning and next step |
|---|---|---|
| 400 | INVALID_INPUT | A value or header is wrong. message may name the field |
| 401 | UNAUTHORIZED | The key is missing, wrong, expired or revoked |
| 403 | SCOPE · FORBIDDEN · READ_ONLY | SCOPE: missing scope. FORBIDDEN: outside the key's targets, or the API isn't open to this account right now. READ_ONLY: the trial or subscription ended, so writes are blocked |
| 404 | NOT_FOUND | The resource doesn't exist or this key can't see it |
| 409 | CONFLICT | Already exists or idempotency key conflict. Read again before deciding |
| 413 | TOO_LARGE | The body is over 32KB |
| 429 | RATE_LIMITED · DAILY_LIMIT | Over a limit. Retry after Retry-After seconds |
| 500 | INTERNAL | Server error. For a write, retrying once with the same Idempotency-Key won't duplicate it |
| 503 | SERVICE_UNAVAILABLE | The API is closed for now. Don't retry automatically - follow Retry-After |
7. Rate limits
| Per | Reads | Writes | Deletes |
|---|---|---|---|
| Key, per minute | 60 | 30 | 10 |
| Account total, per minute | 120 | 60 | 20 |
- Successful writes and deletes that leave a write record are capped at 1,000 per account per 24 hours. Dry runs and replayed requests don't count.
- There is also a daily limit for the whole service, so
DAILY_LIMITcan rarely arrive before your account limit. DAILY_LIMITand 503 don't clear with a retry a minute later. RespectRetry-After.
8. What we keep
- We don't store the key itself, only an irreversible hash (SHA-256). The app shows the prefix and the last 4 characters.
- For each successful write or delete, we keep the time, method, route template, resource ID, changed field names and result code for 30 days. The record doesn't include the values or request bodies you send. Reads aren't added to this record.
- A key's last-used time is updated at most once an hour.
- See the API key section of the Privacy Policy for details.
9. About the beta
- Routes, fields and limits may change. We update this page first.
- If something goes wrong, we may limit the API to our own team (403
FORBIDDEN) or close it (503) for a while. The app keeps working. - Tell us through support if something blocks you or you need a route.