{"openapi":"3.0.0","paths":{"/":{"get":{"operationId":"AppController_root","parameters":[],"responses":{"200":{"description":""}}}},"/events":{"post":{"operationId":"EventsController_createEvents","summary":"Create one or more events. Requires public API key in Bearer token.","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EventsDTO"}}}},"responses":{"201":{"description":"The events have been successfully created."}},"tags":["events"],"security":[{"bearer":[]}]},"get":{"operationId":"EventsController_getEvents","summary":"Get events based on a query. Requires private API key in Bearer token.","parameters":[{"name":"event","required":false,"in":"query","description":"The event name to filter by.","schema":{"example":"Created Account","type":"string"}},{"name":"uuid","required":false,"in":"query","description":"The UUID to filter by.","schema":{"example":"123e4567-e89b-12d3-a456-426614174000","type":"string"}},{"name":"userId","required":false,"in":"query","description":"The user ID to filter by.","schema":{"example":"user-123","type":"string"}},{"name":"groupId","required":false,"in":"query","description":"The group ID to filter by.","schema":{"example":"group-456","type":"string"}},{"name":"anonymousId","required":false,"in":"query","description":"The anonymous ID to filter by.","schema":{"example":"anon-789","type":"string"}},{"name":"instanceId","required":false,"in":"query","description":"The instance ID to filter by.","schema":{"example":"instance-101112","type":"string"}},{"name":"startDate","required":false,"in":"query","description":"The start date to filter by.","schema":{"example":"2022-01-01T00:00:00Z","type":"string"}},{"name":"endDate","required":false,"in":"query","description":"The end date to filter by.","schema":{"example":"2022-12-31T23:59:59Z","type":"string"}},{"name":"limit","required":false,"in":"query","description":"The limit of records to return.","schema":{"example":100,"type":"number"}},{"name":"offset","required":false,"in":"query","description":"The offset of records to return.","schema":{"example":0,"type":"number"}},{"name":"orderByField","required":false,"in":"query","description":"The field to order by.","schema":{"example":"timestamp","type":"string"}},{"name":"orderByDirection","required":false,"in":"query","description":"The direction to order by.","schema":{"example":"ASC","enum":["ASC","DESC"],"type":"string"}}],"responses":{"200":{"description":"The events have been successfully retrieved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedEventResponse"}}}}},"tags":["events"],"security":[{"bearer":[]}]}},"/queries":{"post":{"operationId":"QueriesController_executeQueries","summary":"Execute queries via SQL. Requires private API key in Bearer token.","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/QueriesDTO"}}}},"responses":{"200":{"description":"The queries have been successfully executed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedQueryResponse"}}}}}}},"/workspaces":{"post":{"operationId":"WorkspacesController_create","summary":"Create a workspace","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateWorkspaceDto"}}}},"responses":{"200":{"description":"The workspace has been successfully created. Requires private API key in Bearer token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Workspace"}}}}}}},"/workspaces/{workspaceId}":{"delete":{"operationId":"WorkspacesController_delete","parameters":[{"name":"workspaceId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}}},"put":{"operationId":"WorkspacesController_update","summary":"Update a workspace","parameters":[{"name":"workspaceId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateWorkspaceDto"}}}},"responses":{"200":{"description":"The workspace has been successfully updated. Requires private API key in Bearer token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Workspace"}}}}}},"get":{"operationId":"WorkspacesController_getById","summary":"Get a workspace by ID","parameters":[{"name":"workspaceId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"The workspace has been successfully retrieved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Workspace"}}}}}}},"/webhooks":{"get":{"operationId":"WebhooksController_getWebhooks","summary":"Get all webhooks","parameters":[],"responses":{"200":{"description":"The webhooks have been successfully retrieved. Requires private API key in Bearer token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedWebhookResponse"}}}}},"security":[{"bearer":[]}]},"post":{"operationId":"WebhooksController_createWebhook","summary":"Create a webhook","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookDTO"}}}},"responses":{"200":{"description":"The webhook has been successfully created. Requires private API key in Bearer token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Webhook"}}}}},"security":[{"bearer":[]}]}},"/webhooks/{uuid}":{"delete":{"operationId":"WebhooksController_deleteWebhook","summary":"Delete a webhook","parameters":[{"name":"uuid","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"The webhook has been successfully deleted. Requires private API key in Bearer token."}},"security":[{"bearer":[]}]}}},"info":{"title":"trench API","description":"","version":"1.0","contact":{}},"tags":[],"servers":[],"components":{"schemas":{"EventDTO":{"type":"object","properties":{"anonymousId":{"type":"string","description":"The anonymous ID of the user. See [anonymousId](https://segment.com/docs/connections/spec/common/#anonymousid).","example":"guest-1234567890"},"event":{"type":"string","description":"The event name. Used only with `type: \"track\"`.","example":"UserSignedUp"},"timestamp":{"type":"string","description":"The timestamp of the event. Autogenerated if not provided.","example":"2021-01-01T00:00:00Z"},"type":{"type":"string","description":"The type of the event. Possible values: `page`, `track`, `identify`, `group`.","example":"track"},"userId":{"type":"string","description":"The ID of the user.","example":"user-1234567890"},"groupId":{"type":"string","description":"The ID of the group.","example":"group-1234567890"},"properties":{"type":"object","description":"The properties of the event. Only used with `type: \"track\"`.","example":{"page":"/home","referrer":"https://www.google.com"}},"traits":{"type":"object","description":"The traits of the user or group.","example":{"email":"john.doe@example.com","name":"John Doe"}},"instanceId":{"type":"string","description":"Optional instance ID. Instance IDs are used to partition events by source. It is typically used for isolating data for the same customer. For instance, if you have a SaaS product, you may want to segment events by customer. In this case, you can set the instance ID to the customer's organizaiton ID.","example":"customer-1234567890"}}},"EventsDTO":{"type":"object","properties":{"events":{"description":"The events to insert.","type":"array","items":{"$ref":"#/components/schemas/EventDTO"}}},"required":["events"]},"Event":{"type":"object","properties":{"anonymousId":{"type":"string","description":"The anonymous ID of the user. See [anonymousId](https://segment.com/docs/connections/spec/common/#anonymousid).","example":"guest-1234567890"},"uuid":{"type":"string","description":"The UUID of the event.","example":"123e4567-e89b-12d3-a456-426614174000"},"type":{"type":"string","description":"The type of the event.","example":"track"},"event":{"type":"string","description":"The event name.","example":"User SignedUp"},"userId":{"type":"string","description":"The user ID.","example":"user-123"},"groupId":{"type":"string","description":"The group ID.","example":"group-456"},"properties":{"type":"object","description":"The properties of the event. Only used with `type: \"track\"`.","example":{"page":"/home","referrer":"https://www.google.com"}},"timestamp":{"format":"date-time","type":"string","description":"The timestamp of the event.","example":"2021-01-01T00:00:00Z"},"instanceId":{"type":"string","description":"Optional instance ID. Instance IDs are used to partition events by source. It is typically used for isolating data for the same customer. For instance, if you have a SaaS product, you may want to segment events by customer. In this case, you can set the instance ID to the customer's organizaiton ID.","example":"customer-1234567890"}},"required":["uuid","type","timestamp"]},"PaginatedEventResponse":{"type":"object","properties":{"limit":{"type":"number","description":"The limit of the pagination.","nullable":true},"offset":{"type":"number","description":"The offset of the pagination.","nullable":true},"total":{"type":"number","description":"The total number of results. If `null`, the total is unknown.","nullable":true},"results":{"description":"The events found based on the query.","example":[{"uuid":"123","type":"track","event":"user_signed_up","userId":"user-123","groupId":"group-456","anonymousId":"anon-789","instanceId":"instance-101112","properties":{"key":"value"}}],"type":"array","items":{"$ref":"#/components/schemas/Event"}}},"required":["limit","offset","total","results"]},"QueriesDTO":{"type":"object","properties":{"queries":{"description":"The queries to execute.","example":["SELECT COUNT(*) FROM events WHERE event = \"UserSignedUp\""],"type":"array","items":{"type":"string"}}},"required":["queries"]},"PaginatedQueryResponse":{"type":"object","properties":{"limit":{"type":"number","description":"The limit of the pagination.","nullable":true},"offset":{"type":"number","description":"The offset of the pagination.","nullable":true},"total":{"type":"number","description":"The total number of results. If `null`, the total is unknown.","nullable":true},"results":{"description":"The results of the queries, returned in the same order as the queries.","example":[{"results":[{"count":3485241}]}],"type":"array","items":{"type":"object"}}},"required":["limit","offset","total","results"]},"CreateWorkspaceDto":{"type":"object","properties":{"name":{"type":"string","description":"The name of the workspace to be created.","example":"New Workspace"},"databaseName":{"type":"string","description":"The name of the database associated with the workspace.","example":"workspace_db"},"isDefault":{"type":"boolean","description":"Indicates if the new workspace should be set as default. Defaults to `false`.","example":false},"properties":{"type":"object","description":"The properties of the workspace.","example":"{}"}},"required":["name"]},"Workspace":{"type":"object","properties":{"workspaceId":{"type":"string","description":"The unique identifier of the workspace.","example":"workspace-1234"},"name":{"type":"string","description":"The name of the workspace.","example":"Development Workspace"},"isDefault":{"type":"boolean","description":"Indicates if this is the default workspace.","example":true},"databaseName":{"type":"string","description":"The name of the database associated with the workspace.","example":"default"},"createdAt":{"format":"date-time","type":"string","description":"The date and time when the workspace was created.","example":"2023-01-01T00:00:00.000Z"},"properties":{"type":"object","description":"The properties of the workspace.","example":"{}"}},"required":["workspaceId","name","isDefault","databaseName","createdAt"]},"Webhook":{"type":"object","properties":{"uuid":{"type":"string","description":"The UUID of the webhook. Automatically generated.","example":"123e4567-e89b-12d3-a456-426614174000"},"url":{"type":"string","description":"The URL that the webhook will send events to.","example":"https://your-webhook-url.com"},"enableBatching":{"type":"boolean","description":"Whether to enable batching for the webhook.","example":true},"createdAt":{"format":"date-time","type":"string","description":"The date and time the webhook was created.","example":"2021-01-01T00:00:00.000Z"},"eventTypes":{"description":"The event types that the webhook will send. Use `*` to match all event types.","example":["page","track","identify","group"],"type":"array","items":{"type":"string"}},"eventNames":{"description":"The event names that the webhook will send. Use `*` to match all event names.","example":["UserSignedUp","UserLoggedIn"],"type":"array","items":{"type":"string"}},"flatten":{"type":"boolean","description":"Whether to flatten the event data. This is useful for downstream systems that don't support nested data structures.","example":true}},"required":["uuid","url","enableBatching","createdAt","eventTypes","eventNames","flatten"]},"PaginatedWebhookResponse":{"type":"object","properties":{"limit":{"type":"number","description":"The limit of the pagination.","nullable":true},"offset":{"type":"number","description":"The offset of the pagination.","nullable":true},"total":{"type":"number","description":"The total number of results. If `null`, the total is unknown.","nullable":true},"results":{"type":"array","items":{"$ref":"#/components/schemas/Webhook"}}},"required":["limit","offset","total","results"]},"WebhookDTO":{"type":"object","properties":{"url":{"type":"string","description":"The URL that the webhook will send events to.","example":"https://your-webhook-url.com"},"enableBatching":{"type":"boolean","description":"Whether to enable batching for the webhook. Defaults to `false`.","example":true},"eventTypes":{"description":"The event types that the webhook will send. Defaults to `[\"*\"] (all event types)`.","example":["page","track","identify","group"],"type":"array","items":{"type":"string"}},"eventNames":{"description":"The event names that the webhook will send. Defaults to `[\"*\"] (all event names)`.","example":["UserSignedUp","UserLoggedIn"],"type":"array","items":{"type":"string"}},"flatten":{"type":"boolean","description":"Whether to flatten the event data. This is useful for downstream systems that don't support nested data structures. Defaults to `false`.","example":true}},"required":["url"]}}}}