{"openapi":"3.1.0","info":{"title":"Altertable Product Analytics API","description":"API for tracking product events and identifying users","license":{"name":"MIT","url":"https://opensource.org/licenses/MIT"},"version":"0.1.0"},"paths":{"/alias":{"post":{"tags":["Product Events"],"operationId":"alias","parameters":[{"name":"sync","in":"query","description":"When true, wait for the task to complete before returning","required":false,"schema":{"type":"boolean"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AliasRequest"}}},"required":true},"responses":{"200":{"description":"Alias a user or batch of users","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AliasResponse"},"example":{"error_code":null,"ok":true,"task_id":"01a20ff1-677a-7830-925b-e755ce876b55"}}}}},"security":[{"api_key":[]}]}},"/identify":{"post":{"tags":["Product Events"],"operationId":"identify","parameters":[{"name":"sync","in":"query","description":"When true, wait for the task to complete before returning","required":false,"schema":{"type":"boolean"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdentifyRequest"}}},"required":true},"responses":{"200":{"description":"Identify a user or batch of users","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdentifyResponse"},"example":{"error_code":null,"ok":true,"task_id":"01a20ff1-677a-7830-925b-e7409d9d53cc"}}}},"400":{"description":"Invalid request"},"401":{"description":"Invalid or missing API key"}},"security":[{"api_key":[]},{"api_key_bearer":[]}]}},"/track":{"post":{"tags":["Product Events"],"operationId":"track","parameters":[{"name":"sync","in":"query","description":"When true, wait for the task to complete before returning","required":false,"schema":{"type":"boolean"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrackRequest"}}},"required":true},"responses":{"200":{"description":"Track a raw event or batch of events","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrackResponse"},"example":{"error_code":null,"ok":true,"task_id":"01a20ff1-677a-7830-925b-e7375bb32cfa"}}}},"400":{"description":"Invalid request"},"401":{"description":"Invalid or missing API key"}},"security":[{"api_key":[]},{"api_key_bearer":[]}]}}},"components":{"schemas":{"AliasErrorCode":{"type":"string","enum":["environment-not-found","product-analytics-not-enabled"]},"AliasPayload":{"type":"object","description":"Payload to alias one distinct_id with a new_user_id.\nThis merges the identity of distinct_id into new_user_id.","required":["distinct_id","new_user_id"],"properties":{"distinct_id":{"type":"string","description":"The previous distinct_id (source of the merge)"},"environment":{"type":["string","null"],"description":"Environment name (e.g., \"production\", \"staging\")"},"new_user_id":{"type":"string","description":"The new user ID to merge into (target of the merge)"}}},"AliasRequest":{"oneOf":[{"$ref":"#/components/schemas/AliasPayload"},{"type":"array","items":{"$ref":"#/components/schemas/AliasPayload"}}],"description":"Wrapper for accepting either a single AliasPayload or an array of AliasPayloads"},"AliasResponse":{"type":"object","required":["ok"],"properties":{"error_code":{"oneOf":[{"$ref":"#/components/schemas/AliasErrorCode","description":"Error code if the alias was not successfully created"},{"type":"null"}]},"ok":{"type":"boolean","description":"Indicates whether the alias was successfully created"},"task_id":{"type":["string","null"],"format":"uuid","description":"Task ID that can be used to track the processing status of this batch via GET /tasks/{task_id}"}}},"EventMode":{"type":"string","description":"Collection policy for a product analytics event.","enum":["product","audience"]},"FlexibleTimestamp":{"oneOf":[{"type":"integer","format":"int64","description":"Unix timestamp in milliseconds"},{"type":"string","format":"date-time","description":"ISO8601 datetime string"}],"description":"Timestamp that accepts either Unix timestamp in milliseconds (u64) or ISO8601 string"},"IdentifyErrorCode":{"type":"string","enum":["environment-not-found","product-analytics-not-enabled","trait-name-too-long"]},"IdentifyPayload":{"type":"object","description":"Request to identify a user and associate anonymous IDs with user traits","required":["distinct_id"],"properties":{"anonymous_id":{"type":["string","null"],"description":"Anonymous identifier to associate with the user","example":"anon_123abc"},"distinct_id":{"type":"string","description":"Unique user identifier","example":"user_789ghi"},"environment":{"type":["string","null"],"description":"Environment name (e.g., \"production\", \"staging\")"},"timestamp":{"oneOf":[{"$ref":"#/components/schemas/FlexibleTimestamp","description":"Identify timestamp (Unix milliseconds or ISO 8601 format). If provided, traits are only\nupdated if this timestamp is after the currently set timestamp"},{"type":"null"}]},"traits":{"type":["object","null"],"description":"User traits/attributes to store (e.g., email, name, plan). These are shallow merged with existing traits","additionalProperties":{},"propertyNames":{"type":"string"},"example":{"email":"user@example.com","name":"John Doe","plan":"premium"}}}},"IdentifyRequest":{"oneOf":[{"$ref":"#/components/schemas/IdentifyPayload"},{"type":"array","items":{"$ref":"#/components/schemas/IdentifyPayload"}}],"description":"Wrapper for accepting either a single IdentifyPayload or an array of IdentifyPayloads"},"IdentifyResponse":{"type":"object","description":"Response from identifying a user","required":["ok"],"properties":{"error_code":{"oneOf":[{"$ref":"#/components/schemas/IdentifyErrorCode","description":"Error code if the user was not successfully identified"},{"type":"null"}]},"ok":{"type":"boolean","description":"Indicates whether the user was successfully identified"},"task_id":{"type":["string","null"],"format":"uuid","description":"Task ID that can be used to track the processing status of this batch via GET /tasks/{task_id}"}}},"TrackErrorCode":{"type":"string","enum":["environment-not-found","product-analytics-not-enabled","invalid-headers","audience-identity-not-allowed","unknown-built-in-property","event-name-too-long","property-name-too-long"]},"TrackPayload":{"type":"object","description":"Request to track a product event","required":["event","properties"],"properties":{"anonymous_id":{"type":["string","null"],"description":"Anonymous identifier (used for tracking before user identification)"},"device_id":{"type":["string","null"],"description":"Device ID to associate with the event (e.g., \"device_123\")"},"distinct_id":{"type":["string","null"],"description":"Distinct ID to associate with the event (e.g., \"user_123\")","example":"user_123"},"environment":{"type":["string","null"],"description":"Environment name (e.g., \"production\", \"staging\")","example":"production"},"event":{"type":"string","description":"Name of the event being tracked (e.g., \"Click Search Button\", \"Submit Form\")"},"mode":{"$ref":"#/components/schemas/EventMode","description":"Collection policy. Defaults to product; audience events cannot supply identity fields."},"properties":{"type":"object","description":"Custom event properties.","additionalProperties":{},"propertyNames":{"type":"string"},"example":{"context":"search","price":100}},"session_id":{"type":["string","null"],"description":"Session identifier to group events within a single session"},"timestamp":{"oneOf":[{"$ref":"#/components/schemas/FlexibleTimestamp","description":"Event timestamp (Unix milliseconds or ISO 8601 format). Defaults to current time if not provided"},{"type":"null"}]}}},"TrackRequest":{"oneOf":[{"$ref":"#/components/schemas/TrackPayload"},{"type":"array","items":{"$ref":"#/components/schemas/TrackPayload"}}],"description":"Wrapper for accepting either a single TrackPayload or an array of TrackPayloads"},"TrackResponse":{"type":"object","description":"Response from tracking an event","required":["ok"],"properties":{"error_code":{"oneOf":[{"$ref":"#/components/schemas/TrackErrorCode","description":"Error code if the event was not successfully tracked"},{"type":"null"}]},"ok":{"type":"boolean","description":"Indicates whether the event was successfully enqueued for processing"},"task_id":{"type":["string","null"],"format":"uuid","description":"Task ID that can be used to track the processing status of this batch via GET /tasks/{task_id}"}}}},"securitySchemes":{"api_key":{"type":"apiKey","in":"header","name":"X-API-Key","description":"Your public API key. You can also send the same value as `Authorization: Bearer <api_key>` or as the `apiKey` query parameter."},"api_key_bearer":{"type":"http","scheme":"bearer","bearerFormat":"API key","description":"Same public API key as for `X-API-Key`, sent in the `Authorization` header as `Bearer <api_key>`."}}},"tags":[{"name":"Product Analytics","description":"Product event tracking and user identification endpoints"}]}