Create a sharable link to a query result
Shared queries store the results of a previously run query, allowing you to share the results with others.
Security
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
X-Auth-Email: user@example.comThe previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYYUser Service Key
Used when interacting with the Origin CA certificates API. View/change your key.
X-Auth-User-Service-Key: v1.0-144c9defac04969c7bfad8ef-631a41d003a32d25fe878081ef365c49503f7fada600da935e2851a1c7326084b85cbf6429c4b859de8475731dc92a9c329631e6d59e6c73da7b198497172b4cefe071d90d0f5d2719Accepted Permissions (at least one required)
Workers Observability WriteParametersExpand Collapse
params ObservabilitySharedQueryNewParams
Body param: Identifier for the query. When parameters are omitted, this ID is used to load a previously saved query’s parameters. When providing parameters inline, pass any identifier (e.g. an ad-hoc ID).
Timeframe param.Field[ObservabilitySharedQueryNewParamsTimeframe]Body param: Timeframe for the query using Unix timestamps in milliseconds. Narrower timeframes produce faster responses and more specific results.
Body param: Timeframe for the query using Unix timestamps in milliseconds. Narrower timeframes produce faster responses and more specific results.
Body param: When true, includes a comparison dataset from the previous time period of equal length.
Body param: When true, executes the query without persisting the results. Useful for validation or previewing.
Body param: Number of time-series buckets. Only used when view is ‘calculations’. Omit to let the system auto-detect an appropriate granularity.
Body param: When true, omits time-series data from the response and returns only aggregated values. Reduces response size when series are not needed.
Body param: Maximum number of events to return when view is ‘events’. Also controls the number of group-by rows when view is ‘calculations’.
Body param: Cursor for pagination in event, trace, and invocation views. Pass the $metadata.id of the last returned item to fetch the next page.
Body param: Numeric offset for paginating grouped/pattern results (top-N lists). Use together with limit. Not used by cursor-based pagination.
Body param: Pagination direction: ‘next’ for forward, ‘prev’ for backward.
Body param: Query parameters defining what data to retrieve — filters, calculations, group-bys, and ordering. In practice this should always be provided for ad-hoc queries. Only omit when executing a previously saved query by queryId. Use the keys and values endpoints to discover available fields before building filters.
Body param: Query parameters defining what data to retrieve — filters, calculations, group-bys, and ordering. In practice this should always be provided for ad-hoc queries. Only omit when executing a previously saved query by queryId. Use the keys and values endpoints to discover available fields before building filters.
Calculations []ObservabilitySharedQueryNewParamsParametersCalculationOptionalAggregation calculations to compute (e.g. count, avg, p99). Each calculation produces aggregate values and optional time-series data.
Aggregation calculations to compute (e.g. count, avg, p99). Each calculation produces aggregate values and optional time-series data.
Operator ObservabilitySharedQueryNewParamsParametersCalculationsOperatorAggregation operator to apply. Examples: count, avg, sum, min, max, median, p90, p95, p99, uniq, stddev, variance.
Aggregation operator to apply. Examples: count, avg, sum, min, max, median, p90, p95, p99, uniq, stddev, variance.
Custom label for this calculation in the results. Useful for distinguishing multiple calculations.
Field name to calculate over. Must exist in the data — verify with the keys endpoint. Omit for operators that don’t require a key (e.g. count).
KeyType ObservabilitySharedQueryNewParamsParametersCalculationsKeyTypeOptionalData type of the key. Required when key is provided to ensure correct aggregation.
Data type of the key. Required when key is provided to ensure correct aggregation.
FilterCombination ObservabilitySharedQueryNewParamsParametersFilterCombinationOptionalLogical operator for combining top-level filters: ‘and’ (all must match) or ‘or’ (any must match). Defaults to ‘and’.
Logical operator for combining top-level filters: ‘and’ (all must match) or ‘or’ (any must match). Defaults to ‘and’.
Filters []ObservabilitySharedQueryNewParamsParametersFilterOptionalFilters to narrow query results. Use the keys and values endpoints to discover available fields before building filters. Supports nested groups via kind: ‘group’. Maximum nesting depth is 4.
Filters to narrow query results. Use the keys and values endpoints to discover available fields before building filters. Supports nested groups via kind: ‘group’. Maximum nesting depth is 4.
type ObservabilitySharedQueryNewParamsParametersFiltersObject struct{…}
FilterCombination ObservabilitySharedQueryNewParamsParametersFiltersObjectFilterCombination
Filters []ObservabilitySharedQueryNewParamsParametersFiltersObjectFilter
type ObservabilitySharedQueryNewParamsParametersFiltersObjectFiltersObject struct{…}
FilterCombination ObservabilitySharedQueryNewParamsParametersFiltersObjectFiltersObjectFilterCombination
type ObservabilitySharedQueryNewParamsParametersFiltersObjectFiltersWorkersObservabilityFilterLeaf struct{…}A filter condition applied to query results. Use the keys and values endpoints to discover available fields and their values before constructing filters.
A filter condition applied to query results. Use the keys and values endpoints to discover available fields and their values before constructing filters.
Filter field name. Use verified keys from previous query results or the keys endpoint. Common keys include $metadata.service, $metadata.origin, $metadata.trigger, $metadata.message, and $metadata.error.
Operation ObservabilitySharedQueryNewParamsParametersFiltersObjectFiltersWorkersObservabilityFilterLeafOperationComparison operator. String operators: includes, not_includes, starts_with, ends_with, regex. Existence: exists, is_null. Set membership: in, not_in (comma-separated values). Numeric: eq, neq, gt, gte, lt, lte.
Comparison operator. String operators: includes, not_includes, starts_with, ends_with, regex. Existence: exists, is_null. Set membership: in, not_in (comma-separated values). Numeric: eq, neq, gt, gte, lt, lte.
Type ObservabilitySharedQueryNewParamsParametersFiltersObjectFiltersWorkersObservabilityFilterLeafTypeData type of the filter field. Must match the actual type of the key being filtered.
Data type of the filter field. Must match the actual type of the key being filtered.
Discriminator for leaf filter nodes. Always ‘filter’ when present; may be omitted.
Value ObservabilitySharedQueryNewParamsParametersFiltersObjectFiltersWorkersObservabilityFilterLeafValueUnionOptionalComparison value. Must match actual values in your data — verify with the values endpoint. Ensure the value type (string/number/boolean) matches the field type. String comparisons are case-sensitive. Regex uses RE2 syntax (no lookaheads/lookbehinds).
Comparison value. Must match actual values in your data — verify with the values endpoint. Ensure the value type (string/number/boolean) matches the field type. String comparisons are case-sensitive. Regex uses RE2 syntax (no lookaheads/lookbehinds).
type ObservabilitySharedQueryNewParamsParametersFiltersWorkersObservabilityFilterLeaf struct{…}A filter condition applied to query results. Use the keys and values endpoints to discover available fields and their values before constructing filters.
A filter condition applied to query results. Use the keys and values endpoints to discover available fields and their values before constructing filters.
Filter field name. Use verified keys from previous query results or the keys endpoint. Common keys include $metadata.service, $metadata.origin, $metadata.trigger, $metadata.message, and $metadata.error.
Operation ObservabilitySharedQueryNewParamsParametersFiltersWorkersObservabilityFilterLeafOperationComparison operator. String operators: includes, not_includes, starts_with, ends_with, regex. Existence: exists, is_null. Set membership: in, not_in (comma-separated values). Numeric: eq, neq, gt, gte, lt, lte.
Comparison operator. String operators: includes, not_includes, starts_with, ends_with, regex. Existence: exists, is_null. Set membership: in, not_in (comma-separated values). Numeric: eq, neq, gt, gte, lt, lte.
Type ObservabilitySharedQueryNewParamsParametersFiltersWorkersObservabilityFilterLeafTypeData type of the filter field. Must match the actual type of the key being filtered.
Data type of the filter field. Must match the actual type of the key being filtered.
Discriminator for leaf filter nodes. Always ‘filter’ when present; may be omitted.
Value ObservabilitySharedQueryNewParamsParametersFiltersWorkersObservabilityFilterLeafValueUnionOptionalComparison value. Must match actual values in your data — verify with the values endpoint. Ensure the value type (string/number/boolean) matches the field type. String comparisons are case-sensitive. Regex uses RE2 syntax (no lookaheads/lookbehinds).
Comparison value. Must match actual values in your data — verify with the values endpoint. Ensure the value type (string/number/boolean) matches the field type. String comparisons are case-sensitive. Regex uses RE2 syntax (no lookaheads/lookbehinds).
GroupBys []ObservabilitySharedQueryNewParamsParametersGroupByOptionalFields to group calculation results by. Only applicable when the query view is ‘calculations’. Produces per-group aggregate values.
Fields to group calculation results by. Only applicable when the query view is ‘calculations’. Produces per-group aggregate values.
Type ObservabilitySharedQueryNewParamsParametersGroupBysTypeData type of the group-by field.
Data type of the group-by field.
Havings []ObservabilitySharedQueryNewParamsParametersHavingOptionalPost-aggregation filters applied to calculation results. Use to filter groups after aggregation (e.g. only groups where count > 100).
Post-aggregation filters applied to calculation results. Use to filter groups after aggregation (e.g. only groups where count > 100).
Operation ObservabilitySharedQueryNewParamsParametersHavingsOperationNumeric comparison operator: eq, neq, gt, gte, lt, lte.
Numeric comparison operator: eq, neq, gt, gte, lt, lte.
Maximum number of group-by rows to return in calculation results. A value of 10 is a sensible default for most use cases.
Needle ObservabilitySharedQueryNewParamsParametersNeedleOptionalFull-text search expression applied across all event fields. Matches events containing the specified text.
Full-text search expression applied across all event fields. Matches events containing the specified text.
OrderBy ObservabilitySharedQueryNewParamsParametersOrderByOptionalOrdering for grouped calculation results. Only effective when a group-by is present.
Ordering for grouped calculation results. Only effective when a group-by is present.
Body param: Controls the shape of the response. ‘events’: individual log lines matching the query. ‘calculations’: aggregated metrics (count, avg, p99, etc.) with optional group-by breakdowns and time-series. ‘invocations’: events grouped by request ID. ‘traces’: distributed trace summaries. ‘agents’: Durable Object agent summaries.
Body param: Controls the shape of the response. ‘events’: individual log lines matching the query. ‘calculations’: aggregated metrics (count, avg, p99, etc.) with optional group-by breakdowns and time-series. ‘invocations’: events grouped by request ID. ‘traces’: distributed trace summaries. ‘agents’: Durable Object agent summaries.
Create a sharable link to a query result
package main
import (
"context"
"fmt"
"github.com/stainless-sdks/cloudflare-go"
"github.com/stainless-sdks/cloudflare-go/option"
"github.com/stainless-sdks/cloudflare-go/workers"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
option.WithAPIEmail("user@example.com"),
)
sharedQuery, err := client.Workers.Observability.SharedQueries.New(context.TODO(), workers.ObservabilitySharedQueryNewParams{
AccountID: cloudflare.F("account_id"),
QueryID: cloudflare.F("queryId"),
Timeframe: cloudflare.F(workers.ObservabilitySharedQueryNewParamsTimeframe{
From: cloudflare.F(0.000000),
To: cloudflare.F(0.000000),
}),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", sharedQuery.ID)
}
{
"errors": [
{
"message": "message"
}
],
"messages": [
{
"message": "Successful request"
}
],
"result": {
"id": "id"
},
"success": true
}Returns Examples
{
"errors": [
{
"message": "message"
}
],
"messages": [
{
"message": "Successful request"
}
],
"result": {
"id": "id"
},
"success": true
}