openapi: 3.2.0 info: title: Twilio - Insights Twilio Insights Async API description: 'The Twilio Insights v3 API provides semantic query access to Conversations analytics data. Resources include synchronous Query, Metadata, and asynchronous QueryJobs for long-running queries.' termsOfService: https://www.twilio.com/legal/tos contact: name: Twilio Support url: https://support.twilio.com email: support@twilio.com license: name: Apache 2.0 url: https://www.apache.org/licenses/LICENSE-2.0.html version: 1.1.0 x-twilio: apiStandards: v1.0 servers: - url: https://insights.twilio.com security: - basic_apikey_or_accountsid: [] tags: - name: TwilioInsightsAsync description: Twilio Insights asynchronous QueryJobs resource (long-running query operations). paths: /v3/InsightsDomains/Conversations/QueryJobs: servers: - url: https://insights.twilio.com post: summary: Submit an asynchronous query description: 'Submit a long-running semantic query against the Conversations domain. Returns 202 Accepted with an operationId and a Location header pointing to the QueryJobs status endpoint for polling.' tags: - TwilioInsightsAsync operationId: CreateQueryJob parameters: - in: header name: Idempotency-Key required: false description: 'A client-generated UUIDv7 key that ensures idempotent behavior. Submitting the same key with an identical request returns the same operation without re-execution. Scoped to Account + Region. Retained for 24 hours. ' schema: type: string format: uuid example: 01890a5d-aa0f-7c80-b8e6-0242ac140004 requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/InsightsQueryRequest' responses: '202': description: Async query accepted headers: Location: description: URI to poll for operation status. schema: type: string format: uri example: https://insights.twilio.com/v3/InsightsDomains/Conversations/QueryJobs/proc_job_01h9d8r0vte3hz8tykdj329t7r Retry-After: description: Seconds before the client should first poll. schema: type: integer example: 5 content: application/json: schema: $ref: '#/components/schemas/QueryJobSubmitResponse' example: operationId: proc_job_01h9d8r0vte3hz8tykdj329t7r status: PENDING statusUrl: https://insights.twilio.com/v3/InsightsDomains/Conversations/QueryJobs/proc_job_01h9d8r0vte3hz8tykdj329t7r createdAt: '2026-05-25T14:30:00Z' 400: description: Bad request content: application/json: schema: type: object properties: code: description: Twilio-specific error code type: integer format: int32 message: description: A human readable error message type: string httpStatusCode: description: HTTP response status code type: integer format: int32 userError: description: Whether the error is a user error (true) or a system error (false) type: boolean params: description: A map of parameters related to the error, for example, a `params.twilioErrorCodeUrl` might hold a URL or link to additional information type: object additionalProperties: type: string required: - code - message - httpStatusCode 422: description: Unprocessable content (idempotency key payload mismatch) content: application/json: schema: type: object properties: code: description: Twilio-specific error code type: integer format: int32 message: description: A human readable error message type: string httpStatusCode: description: HTTP response status code type: integer format: int32 userError: description: Whether the error is a user error (true) or a system error (false) type: boolean params: description: A map of parameters related to the error, for example, a `params.twilioErrorCodeUrl` might hold a URL or link to additional information type: object additionalProperties: type: string required: - code - message - httpStatusCode 429: description: Too Many requests (rate limit exceeded for request originating from public API) headers: X-RateLimit-Limit: description: Maximum number of requests allowed in the time window schema: type: integer example: 5 X-RateLimit-Remaining: description: Number of requests remaining in the current time window schema: type: integer example: 0 X-RateLimit-Reset: description: Time in seconds until the rate limit resets schema: type: integer example: 45 X-Rate-Limit-Limit: $ref: '#/components/headers/X-Rate-Limit-Limit' X-Rate-Limit-Remaining: $ref: '#/components/headers/X-Rate-Limit-Remaining' X-Rate-Limit-Config: $ref: '#/components/headers/X-Rate-Limit-Config' content: application/json: schema: type: object properties: code: description: Twilio-specific error code type: integer format: int32 message: description: A human readable error message type: string httpStatusCode: description: HTTP response status code type: integer format: int32 userError: description: Whether the error is a user error (true) or a system error (false) type: boolean params: description: A map of parameters related to the error, for example, a `params.twilioErrorCodeUrl` might hold a URL or link to additional information type: object additionalProperties: type: string required: - code - message - httpStatusCode 500: description: Internal server error content: application/json: schema: type: object properties: code: description: Twilio-specific error code type: integer format: int32 message: description: A human readable error message type: string httpStatusCode: description: HTTP response status code type: integer format: int32 userError: description: Whether the error is a user error (true) or a system error (false) type: boolean params: description: A map of parameters related to the error, for example, a `params.twilioErrorCodeUrl` might hold a URL or link to additional information type: object additionalProperties: type: string required: - code - message - httpStatusCode security: - basic_apikey_or_accountsid: [] get: summary: Retrieve a list of asynchronous queries description: 'Returns a paginated list of asynchronous query operations for the authenticated account. Optionally filter by status.' tags: - TwilioInsightsAsync operationId: ListQueryJobs parameters: - name: pageSize in: query description: The maximum number of resources to return required: false schema: type: integer minimum: 1 maximum: 1000 default: 50 - name: pageToken in: query description: Token for pagination required: false schema: type: string - name: status in: query description: The operation status to filter results by. required: false schema: $ref: '#/components/schemas/LongRunningOperationStatus' responses: '200': description: Paginated list of async query operations content: application/json: schema: $ref: '#/components/schemas/QueryJobListResponse' example: items: - operationId: proc_job_01h9d8r0vte3hz8tykdj329t7r status: RUNNING createdAt: '2026-05-25T14:30:00Z' statusUrl: https://insights.twilio.com/v3/InsightsDomains/Conversations/QueryJobs/proc_job_01h9d8r0vte3hz8tykdj329t7r resultId: proc_job_01h9d8r0vte3hz8tykdj329t7r meta: key: items pageSize: 1 400: description: Bad request content: application/json: schema: type: object properties: code: description: Twilio-specific error code type: integer format: int32 message: description: A human readable error message type: string httpStatusCode: description: HTTP response status code type: integer format: int32 userError: description: Whether the error is a user error (true) or a system error (false) type: boolean params: description: A map of parameters related to the error, for example, a `params.twilioErrorCodeUrl` might hold a URL or link to additional information type: object additionalProperties: type: string required: - code - message - httpStatusCode 429: description: Too Many requests (rate limit exceeded for request originating from public API) headers: X-RateLimit-Limit: description: Maximum number of requests allowed in the time window schema: type: integer example: 5 X-RateLimit-Remaining: description: Number of requests remaining in the current time window schema: type: integer example: 0 X-RateLimit-Reset: description: Time in seconds until the rate limit resets schema: type: integer example: 45 X-Rate-Limit-Limit: $ref: '#/components/headers/X-Rate-Limit-Limit' X-Rate-Limit-Remaining: $ref: '#/components/headers/X-Rate-Limit-Remaining' X-Rate-Limit-Config: $ref: '#/components/headers/X-Rate-Limit-Config' content: application/json: schema: type: object properties: code: description: Twilio-specific error code type: integer format: int32 message: description: A human readable error message type: string httpStatusCode: description: HTTP response status code type: integer format: int32 userError: description: Whether the error is a user error (true) or a system error (false) type: boolean params: description: A map of parameters related to the error, for example, a `params.twilioErrorCodeUrl` might hold a URL or link to additional information type: object additionalProperties: type: string required: - code - message - httpStatusCode 500: description: Internal server error content: application/json: schema: type: object properties: code: description: Twilio-specific error code type: integer format: int32 message: description: A human readable error message type: string httpStatusCode: description: HTTP response status code type: integer format: int32 userError: description: Whether the error is a user error (true) or a system error (false) type: boolean params: description: A map of parameters related to the error, for example, a `params.twilioErrorCodeUrl` might hold a URL or link to additional information type: object additionalProperties: type: string required: - code - message - httpStatusCode security: - basic_apikey_or_accountsid: [] /v3/InsightsDomains/Conversations/QueryJobs/{operationId}: servers: - url: https://insights.twilio.com get: summary: Retrieve asynchronous query status and results description: 'Poll the operation status. When status is COMPLETED, the response includes query results inline. When FAILED, the response includes error details conforming to the OperationError schema.' tags: - TwilioInsightsAsync operationId: FetchQueryJobStatus parameters: - name: operationId in: path required: true description: The unique identifier for the asynchronous query operation, in TTID format. schema: type: string format: Proc_JobTtid example: proc_job_01h9d8r0vte3hz8tykdj329t7r responses: '200': description: Operation status (may include results if COMPLETED) headers: Retry-After: description: Seconds before the client should poll again (present while PENDING/RUNNING). schema: type: integer example: 10 content: application/json: schema: $ref: '#/components/schemas/QueryJobStatusResponse' examples: running: summary: Operation still running value: operationId: proc_job_01h9d8r0vte3hz8tykdj329t7r status: RUNNING createdAt: '2026-05-25T14:30:00Z' statusUrl: https://insights.twilio.com/v3/InsightsDomains/Conversations/QueryJobs/proc_job_01h9d8r0vte3hz8tykdj329t7r completed: summary: Operation completed value: operationId: proc_job_01h9d8r0vte3hz8tykdj329t7r status: COMPLETED createdAt: '2026-05-25T14:30:00Z' completedAt: '2026-05-25T14:32:17Z' statusUrl: https://insights.twilio.com/v3/InsightsDomains/Conversations/QueryJobs/proc_job_01h9d8r0vte3hz8tykdj329t7r resultRetentionPeriod: P7D failed: summary: Operation failed value: operationId: proc_job_01h9d8r0vte3hz8tykdj329t7r status: FAILED createdAt: '2026-05-25T14:30:00Z' completedAt: '2026-05-25T14:30:12Z' statusUrl: https://insights.twilio.com/v3/InsightsDomains/Conversations/QueryJobs/proc_job_01h9d8r0vte3hz8tykdj329t7r error: code: 50001 message: Query execution timeout exceeded httpStatusCode: 504 detail: ClickHouse query exceeded the 120s execution limit for this account. 404: description: Resource not found content: application/json: schema: type: object properties: code: description: Twilio-specific error code type: integer format: int32 message: description: A human readable error message type: string httpStatusCode: description: HTTP response status code type: integer format: int32 userError: description: Whether the error is a user error (true) or a system error (false) type: boolean params: description: A map of parameters related to the error, for example, a `params.twilioErrorCodeUrl` might hold a URL or link to additional information type: object additionalProperties: type: string required: - code - message - httpStatusCode 429: description: Too Many requests (rate limit exceeded for request originating from public API) headers: X-RateLimit-Limit: description: Maximum number of requests allowed in the time window schema: type: integer example: 5 X-RateLimit-Remaining: description: Number of requests remaining in the current time window schema: type: integer example: 0 X-RateLimit-Reset: description: Time in seconds until the rate limit resets schema: type: integer example: 45 X-Rate-Limit-Limit: $ref: '#/components/headers/X-Rate-Limit-Limit' X-Rate-Limit-Remaining: $ref: '#/components/headers/X-Rate-Limit-Remaining' X-Rate-Limit-Config: $ref: '#/components/headers/X-Rate-Limit-Config' content: application/json: schema: type: object properties: code: description: Twilio-specific error code type: integer format: int32 message: description: A human readable error message type: string httpStatusCode: description: HTTP response status code type: integer format: int32 userError: description: Whether the error is a user error (true) or a system error (false) type: boolean params: description: A map of parameters related to the error, for example, a `params.twilioErrorCodeUrl` might hold a URL or link to additional information type: object additionalProperties: type: string required: - code - message - httpStatusCode 500: description: Internal server error content: application/json: schema: type: object properties: code: description: Twilio-specific error code type: integer format: int32 message: description: A human readable error message type: string httpStatusCode: description: HTTP response status code type: integer format: int32 userError: description: Whether the error is a user error (true) or a system error (false) type: boolean params: description: A map of parameters related to the error, for example, a `params.twilioErrorCodeUrl` might hold a URL or link to additional information type: object additionalProperties: type: string required: - code - message - httpStatusCode security: - basic_apikey_or_accountsid: [] /v3/InsightsDomains/Conversations/QueryJobs/{operationId}/Results: servers: - url: https://insights.twilio.com get: summary: Retrieve asynchronous query results description: 'Retrieve paginated results for a completed asynchronous query operation. The resultUrl in the status response points to this endpoint. Returns 404 if the operation is not yet COMPLETED or has expired.' tags: - TwilioInsightsAsync operationId: FetchQueryJobResults parameters: - name: operationId in: path required: true description: The unique identifier for the asynchronous query operation, in TTID format. schema: type: string format: Proc_JobTtid example: proc_job_01h9d8r0vte3hz8tykdj329t7r - name: pageSize in: query description: The maximum number of resources to return required: false schema: type: integer minimum: 1 maximum: 1000 default: 50 - name: pageToken in: query description: Token for pagination required: false schema: type: string responses: '200': description: Query results content: application/json: schema: $ref: '#/components/schemas/InsightsQueryResponse' example: domain: Conversations items: - Id: conv1 Languages: - en Channels: - voice OperatorResult.Value: positive - Id: conv2 Languages: - en - es Channels: - chat OperatorResult.Value: negative meta: key: items pageSize: 2 nextToken: eyJwYWdlIjoyLCJxdWVyeSI6ImJvb2tzIn0= 404: description: Resource not found content: application/json: schema: type: object properties: code: description: Twilio-specific error code type: integer format: int32 message: description: A human readable error message type: string httpStatusCode: description: HTTP response status code type: integer format: int32 userError: description: Whether the error is a user error (true) or a system error (false) type: boolean params: description: A map of parameters related to the error, for example, a `params.twilioErrorCodeUrl` might hold a URL or link to additional information type: object additionalProperties: type: string required: - code - message - httpStatusCode 429: description: Too Many requests (rate limit exceeded for request originating from public API) headers: X-RateLimit-Limit: description: Maximum number of requests allowed in the time window schema: type: integer example: 5 X-RateLimit-Remaining: description: Number of requests remaining in the current time window schema: type: integer example: 0 X-RateLimit-Reset: description: Time in seconds until the rate limit resets schema: type: integer example: 45 X-Rate-Limit-Limit: $ref: '#/components/headers/X-Rate-Limit-Limit' X-Rate-Limit-Remaining: $ref: '#/components/headers/X-Rate-Limit-Remaining' X-Rate-Limit-Config: $ref: '#/components/headers/X-Rate-Limit-Config' content: application/json: schema: type: object properties: code: description: Twilio-specific error code type: integer format: int32 message: description: A human readable error message type: string httpStatusCode: description: HTTP response status code type: integer format: int32 userError: description: Whether the error is a user error (true) or a system error (false) type: boolean params: description: A map of parameters related to the error, for example, a `params.twilioErrorCodeUrl` might hold a URL or link to additional information type: object additionalProperties: type: string required: - code - message - httpStatusCode 500: description: Internal server error content: application/json: schema: type: object properties: code: description: Twilio-specific error code type: integer format: int32 message: description: A human readable error message type: string httpStatusCode: description: HTTP response status code type: integer format: int32 userError: description: Whether the error is a user error (true) or a system error (false) type: boolean params: description: A map of parameters related to the error, for example, a `params.twilioErrorCodeUrl` might hold a URL or link to additional information type: object additionalProperties: type: string required: - code - message - httpStatusCode security: - basic_apikey_or_accountsid: [] components: schemas: QueryJobSubmitResponse: description: 'The initial 202 response for an async query submission. Conforms to LongRunningOperation202Response from Twilio API Standards. ' type: object additionalProperties: true required: - operationId - status - statusUrl - createdAt properties: operationId: type: string format: Proc_JobTtid description: The unique identifier for the asynchronous query operation, in TTID format. example: proc_job_01h9d8r0vte3hz8tykdj329t7r status: $ref: '#/components/schemas/LongRunningOperationStatus' statusUrl: type: string format: uri description: The URI to poll for operation status. example: https://insights.twilio.com/v3/InsightsDomains/Conversations/QueryJobs/proc_job_01h9d8r0vte3hz8tykdj329t7r createdAt: type: string format: date-time description: The time when the operation was accepted, in RFC 3339 UTC format. example: '2026-05-25T14:30:00Z' InsightsQueryResponse: type: object properties: domain: type: string example: Insights description: Indicates the business domain the query was executed against items: type: array description: Array of result objects containing the query results. Each object contains properties matching the requested measures and dimensions. items: type: object description: Query result object with dynamic properties based on requested measures and dimensions. additionalProperties: description: Dynamic property values based on requested measures and dimensions. example: - Id: conv1 Languages: - en Channels: - voice OperatorResult.Value: positive - Id: conv2 Languages: - en - es Channels: - chat OperatorResult.Value: negative meta: $ref: '#/components/schemas/PaginationMeta' OperationError: description: The error details for a failed operation, embedded inside a 200 OK operation envelope. type: object required: - code - message - httpStatusCode properties: code: description: Twilio-specific error code type: integer format: int32 example: 50001 message: description: A human readable error message type: string example: Query execution timeout exceeded httpStatusCode: description: HTTP status code that would have been returned for a synchronous failure type: integer format: int32 example: 504 detail: description: Additional context about the failure type: - string - 'null' example: ClickHouse query exceeded the 120s execution limit. QueryDefinition: type: object description: Structured query definition that specifies what data to retrieve and how to filter, group, and order it properties: measures: type: array description: Array of measures to retrieve, representing quantitative values or metrics to be calculated items: type: string example: - OperatorResult.Count dimensions: type: array description: Array of dimensions to retrieve, representing categorical attributes for grouping and organizing data items: type: string example: - DateCreated - OperatorResults filters: type: array description: Nested filter conditions. Always use `op` and `expressions`. items: type: object required: - expressions properties: op: type: string enum: - AND - OR - EQ - NE - GT - LT - IN example: AND expressions: type: array items: type: object required: - op - field properties: op: type: string enum: - AND - OR - EQ - NE - GT - LT - IN example: IN field: type: string example: OperatorResult.Value values: type: array items: type: string example: - positive - negative orderBy: type: array description: Specifications for sorting the query results by specific fields in ascending or descending order items: type: object properties: field: type: string description: Dimension or measure to order by example: OperatorResults.CreatedDate direction: type: string description: Sort order direction, ascending or descending enum: - ASC - DESC example: DESC InsightsQueryRequest: type: object required: - query properties: domain: type: string example: Conversations description: The business domain to execute the query against query: $ref: '#/components/schemas/QueryDefinition' QueryJobListResponse: description: A paginated list of async query operations for the account. type: object required: - items - meta properties: items: type: array items: $ref: '#/components/schemas/QueryJobStatusResponse' meta: $ref: '#/components/schemas/PaginationMeta' QueryJobStatusResponse: description: 'The status response for an async query operation. Conforms to LongRunningOperationStatusResponse from Twilio API Standards. ' type: object additionalProperties: true required: - operationId - status - createdAt properties: operationId: type: string format: Proc_JobTtid description: The unique identifier for the asynchronous query operation, in TTID format. example: proc_job_01h9d8r0vte3hz8tykdj329t7r status: $ref: '#/components/schemas/LongRunningOperationStatus' statusUrl: type: string format: uri example: https://insights.twilio.com/v3/InsightsDomains/Conversations/QueryJobs/proc_job_01h9d8r0vte3hz8tykdj329t7r createdAt: type: string format: date-time example: '2026-05-25T14:30:00Z' completedAt: type: - string - 'null' format: date-time description: The time when the operation reached a terminal state (CANCELLED, COMPLETED, or FAILED), in RFC 3339 UTC format. Null while the operation is still PENDING or RUNNING. example: '2026-05-25T14:32:17Z' error: description: The error details, present only when status is FAILED. allOf: - $ref: '#/components/schemas/OperationError' resultUrl: type: - string - 'null' format: uri description: 'The URL to retrieve query results, present only when status is COMPLETED. Supports pagination via the pageSize and pageToken query parameters. ' example: https://insights.twilio.com/v3/InsightsDomains/Conversations/QueryJobs/proc_job_01h9d8r0vte3hz8tykdj329t7r/Results resultId: type: - string - 'null' description: 'The identifier of the results resource, present only when status is COMPLETED. Equal to operationId, since results are keyed by the operation ID. ' example: proc_job_01h9d8r0vte3hz8tykdj329t7r resultRetentionPeriod: type: - string - 'null' format: duration description: The duration for how long results are retained, in ISO 8601 format. example: P7D PaginationMeta: type: object description: 'The pagination metadata containing navigation tokens and result information. By convention, this schema should be added to the response payload''s ''meta'' attribute. ' required: - key - pageSize properties: key: type: string description: 'The key of the list property contains the actual data items. This enables programmatic iteration over paginated results. ' example: items pageSize: type: integer description: 'The actual number of items returned in this response. May be less than the requested pageSize for the last page. ' example: 20 previousToken: type: - string - 'null' description: 'Token to fetch the previous page of results. Only included if there is a previous page, otherwise omitted. ' example: eyJwYWdlIjowLCJxdWVyeSI6ImJvb2tzIn0= nextToken: type: - string - 'null' description: 'Token to fetch the next page of results. Only included if there is a next page, otherwise omitted. ' example: eyJwYWdlIjoyLCJxdWVyeSI6ImJvb2tzIn0= LongRunningOperationStatus: description: The valid status values for long-running operations. type: string enum: - PENDING - RUNNING - CANCELLED - COMPLETED - FAILED headers: X-Rate-Limit-Remaining: schema: type: string X-Rate-Limit-Limit: schema: type: string X-Rate-Limit-Config: schema: type: string securitySchemes: basic_apikey_or_accountsid: scheme: basic type: http description: This API uses [basic authentication](https://www.twilio.com/docs/glossary/what-is-basic-authentication). Use an [API key](https://www.twilio.com/docs/iam/api-keys) as the username and the API key secret as the password. You can also use your account SID and auth token, but limit their use to local testing.