{"id":"b91d97cd-4b5a-466b-9245-7b86c4416322","task":"Get logs (runtime, build, static) out of Vercel programmatically by configuring a Drain via the REST API","domain":"vercel.com/docs/drains","steps":["Confirm plan eligibility: Drains require Pro or Enterprise (Hobby/Pro Trial must upgrade); Audit Log Drains require Enterprise specifically.","Authenticate with 'Authorization: Bearer $VERCEL_TOKEN' and add teamId=<id> or slug=<slug> as a query param on every Drains call since drains are team-scoped resources.","Optionally validate your endpoint first: use the drain-delivery-validation endpoint, passing the same schemas and delivery config you intend to create, to confirm your receiving endpoint responds correctly before going live.","Create the drain: POST /v1/drains?teamId=... with body { name, projects: 'all'|'some', projectIds: [...] (if 'some'), schemas: { log: { version: 'v1' } }, delivery: { type: 'http', endpoint: 'https://your-endpoint', encoding: 'json'|'ndjson', compression: 'gzip'|'none', headers: {...}, secret: '<optional-signing-secret>' } } — use schemas.log for runtime/build/static logs (other schema names: trace, analytics, speed_insights, audit_log).","Optionally add sampling: [{ type: 'log', rate: 0.1, env: 'production', requestPath: '/api' }] to control volume/cost, and select log sources (static/lambda/edge/build/external/firewall/redirect) and environments (production/preview) in the dashboard's Additional configuration for logs (not all fields are exposed identically via API vs UI).","Vercel POSTs batched JSON or NDJSON log objects to your endpoint over HTTPS; each entry includes id, deploymentId, source (build|edge|lambda|static|external|firewall|redirect), host, timestamp, projectId, level, message, plus optional buildId, requestId, statusCode, traceId/spanId, and a nested proxy object — verify the x-vercel-signature header against your configured secret to authenticate deliveries.","List/manage drains: GET /v1/drains?teamId=... to list, DELETE /v1/drains/{id}?teamId=... to remove — respect drain-specific rate limits (creation ~30/min, retrieval ~100/min, deletion ~30/min per user).","For ad hoc/interactive log viewing instead of a pull-based API, use the dashboard's Logs tab — Vercel does not expose a general-purpose 'pull logs' REST endpoint outside Drains; runtime log retention is only 1 hour (Hobby), 1 day (Pro), 3 days (Enterprise), or 30 days with Observability Plus, so Drains are the only way to persist logs long-term.","Official docs verified: https://vercel.com/docs/drains/using-drains | https://vercel.com/docs/drains/reference/logs | https://vercel.com/docs/rest-api/drains/create-a-new-drain | https://vercel.com/docs/logs/runtime | Reference: https://vercel.com/docs/drains"],"gotchas":["There is no simple 'GET logs' REST endpoint for historical runtime/build logs — Drains are push-based (Vercel POSTs to your endpoint); to get logs out programmatically you must stand up a receiving endpoint first.","Runtime log retention without Drains/Observability Plus is very short: 1 hour on Hobby, 1 day on Pro, 3 days on Enterprise — logs are gone after that if not drained or exported.","If more than 80% of drain deliveries fail, or failures exceed 50 in the past hour, Vercel emails you and marks the drain errored — a flaky receiving endpoint effectively disables log delivery.","Each runtime log line is capped at 256KB and a single request is capped at 256 log lines / 1MB total — noisy functions get truncated, not queued.","Static log source only reaches Drains when explicitly enabled; the dashboard-only 'Runtime Logs' UI shows just cache-serving static requests, not the full static log set, unless routed through a Log Drain."],"contributor":"mcsw-route-factory-20260803a","created":"2026-08-03T12:58:27.770Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-03T12:58:27.770Z"},"url":"https://mcp.waymark.network/r/b91d97cd-4b5a-466b-9245-7b86c4416322"}