{"openapi":"3.0.3","info":{"title":"Stactics API","version":"1.0.0","description":"External ingest API for sending product analytics events to Stactics."},"servers":[{"url":"http://localhost:3000"}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}}},"paths":{"/v1/events":{"post":{"summary":"Submit event","description":"Submit one analytics event for the project attached to the ingest key.","operationId":"post_v1_events","tags":["Events"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"Analytics event payload. Use predefined event types such as signup, login, purchase, screen_viewed, feature_used, crash, error, notification_sent, and health_check. Purchase and subscription revenue events should include amount_cents and currency.","required":["event_type"],"properties":{"event_type":{"type":"string","enum":["signup","login","active","purchase","subscription_started","subscription_cancelled","trial_started","trial_converted","crash","error","app_opened","screen_viewed","feature_used","notification_sent","notification_opened","health_check"],"example":"signup","description":"Predefined event type or a project-defined custom event key."},"user_id":{"type":"string","example":"user_123"},"external_user_id":{"type":"string","example":"user_123"},"account_id":{"type":"string","example":"team_123"},"external_account_id":{"type":"string","example":"team_123"},"email":{"type":"string","example":"founder@example.com"},"username":{"type":"string","example":"founder"},"display_name":{"type":"string","example":"Sam Founder"},"device_id":{"type":"string","example":"install_abc"},"build_version":{"type":"string","example":"1.4.2"},"platform":{"type":"string","example":"ios"},"environment_id":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000000"},"project_environment_id":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000000"},"amount_cents":{"type":"integer","format":"int64","minimum":0,"example":1299,"description":"Non-negative integer amount in minor units. Required with currency for purchase, subscription_started, and trial_converted revenue reporting."},"currency":{"type":"string","minLength":3,"maxLength":3,"example":"AUD","description":"Three-letter ISO currency code. Required when amount_cents is present."},"occurred_at":{"type":"string","format":"date-time"},"metadata":{"type":"object","description":"Event-specific details such as plan, screen, feature, error, transaction_id, source, or check.","example":{"plan":"free","screen":"Dashboard","transaction_id":"txn_123"}}}}}}},"responses":{"201":{"description":"Accepted","content":{"application/json":{"schema":{"type":"object","properties":{"accepted":{"type":"boolean"},"accepted_count":{"type":"integer"}}},"example":{"accepted":true,"accepted_count":1}}}},"401":{"description":"Missing, invalid, or discarded project API key"},"402":{"description":"Monthly event limit reached"},"422":{"description":"Invalid event payload"}}}},"/v1/events/batch":{"post":{"summary":"Submit event batch","description":"Submit multiple analytics events atomically. If any event is invalid, none are persisted.","operationId":"post_v1_events_batch","tags":["Events"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["events"],"properties":{"events":{"type":"array","items":{"type":"object","description":"Analytics event payload. Use predefined event types such as signup, login, purchase, screen_viewed, feature_used, crash, error, notification_sent, and health_check. Purchase and subscription revenue events should include amount_cents and currency.","required":["event_type"],"properties":{"event_type":{"type":"string","enum":["signup","login","active","purchase","subscription_started","subscription_cancelled","trial_started","trial_converted","crash","error","app_opened","screen_viewed","feature_used","notification_sent","notification_opened","health_check"],"example":"signup","description":"Predefined event type or a project-defined custom event key."},"user_id":{"type":"string","example":"user_123"},"external_user_id":{"type":"string","example":"user_123"},"account_id":{"type":"string","example":"team_123"},"external_account_id":{"type":"string","example":"team_123"},"email":{"type":"string","example":"founder@example.com"},"username":{"type":"string","example":"founder"},"display_name":{"type":"string","example":"Sam Founder"},"device_id":{"type":"string","example":"install_abc"},"build_version":{"type":"string","example":"1.4.2"},"platform":{"type":"string","example":"ios"},"environment_id":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000000"},"project_environment_id":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000000"},"amount_cents":{"type":"integer","format":"int64","minimum":0,"example":1299,"description":"Non-negative integer amount in minor units. Required with currency for purchase, subscription_started, and trial_converted revenue reporting."},"currency":{"type":"string","minLength":3,"maxLength":3,"example":"AUD","description":"Three-letter ISO currency code. Required when amount_cents is present."},"occurred_at":{"type":"string","format":"date-time"},"metadata":{"type":"object","description":"Event-specific details such as plan, screen, feature, error, transaction_id, source, or check.","example":{"plan":"free","screen":"Dashboard","transaction_id":"txn_123"}}}}}}}}}},"responses":{"201":{"description":"Accepted","content":{"application/json":{"schema":{"type":"object","properties":{"accepted":{"type":"boolean"},"accepted_count":{"type":"integer"}}},"example":{"accepted":true,"accepted_count":2}}}},"401":{"description":"Missing, invalid, or discarded project API key"},"402":{"description":"Monthly event limit reached"},"422":{"description":"Invalid event payload"}}}}}}