Save query
client.workers.observability.queries.create(QueryCreateParams { account_id, description, name, parameters } params, RequestOptionsoptions?): QueryCreateResponse { id, adhoc, created, 6 more }
POST/accounts/{account_id}/workers/observability/queries
Persist query for later use.
Security
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
Example:
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Example:
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
User Service Key
Used when interacting with the Origin CA certificates API. View/change your key.
Example:
Accepted Permissions (at least one required)
Save query
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted
apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted
});
const query = await client.workers.observability.queries.create({
account_id: 'account_id',
description: 'Query description',
name: 'x',
parameters: {},
});
console.log(query.id);{
"errors": [
{
"message": "message"
}
],
"messages": [
{
"message": "Successful request"
}
],
"result": {
"id": "id",
"adhoc": true,
"created": "created",
"createdBy": "createdBy",
"description": "Query description",
"name": "x",
"parameters": {
"calculations": [
{
"operator": "uniq",
"alias": "alias",
"key": "key",
"keyType": "string"
}
],
"datasets": [
"string"
],
"filterCombination": "and",
"filters": [
{
"filterCombination": "and",
"filters": [
{}
],
"kind": "group"
}
],
"groupBys": [
{
"type": "string",
"value": "value"
}
],
"havings": [
{
"key": "key",
"operation": "eq",
"value": 0
}
],
"limit": 0,
"needle": {
"value": "string",
"isRegex": true,
"matchCase": true
},
"orderBy": {
"value": "value",
"order": "asc"
}
},
"updated": "updated",
"updatedBy": "updatedBy"
},
"success": true
}Returns Examples
{
"errors": [
{
"message": "message"
}
],
"messages": [
{
"message": "Successful request"
}
],
"result": {
"id": "id",
"adhoc": true,
"created": "created",
"createdBy": "createdBy",
"description": "Query description",
"name": "x",
"parameters": {
"calculations": [
{
"operator": "uniq",
"alias": "alias",
"key": "key",
"keyType": "string"
}
],
"datasets": [
"string"
],
"filterCombination": "and",
"filters": [
{
"filterCombination": "and",
"filters": [
{}
],
"kind": "group"
}
],
"groupBys": [
{
"type": "string",
"value": "value"
}
],
"havings": [
{
"key": "key",
"operation": "eq",
"value": 0
}
],
"limit": 0,
"needle": {
"value": "string",
"isRegex": true,
"matchCase": true
},
"orderBy": {
"value": "value",
"order": "asc"
}
},
"updated": "updated",
"updatedBy": "updatedBy"
},
"success": true
}