Get or create metric

POST {{baseUrl}}/api/-/pulse/metrics:getOrCreate

Returns the details of a metric in a definition if it exists, or creates a new metric if it does not. Also returns true if a new metric was created, or false if it already existed.

Version: Available in API 3.21 (Tableau Cloud December 2023) and later. Not available for Tableau Server. Versioning Overview

Permissions: Any user can create a metric in a definition as long as the user has read or connect access to the data source used in the definition. Permissions Overview

License: No additional license required.

Access Scope: tableau:insight_metrics:create
Access Scopes Overview: Cloud

Request Body

{"definition_id"=>"<string>", "specification"=>{"filters"=>[{"field"=>"<string>", "operator"=>"OPERATOR_NOT_EQUAL", "categorical_values"=>[{"string_value"=>"<string>", "bool_value"=>"<boolean>", "null_value"=>"<string>"}, {"string_value"=>"<string>", "bool_value"=>"<boolean>", "null_value"=>"<string>"}]}, {"field"=>"<string>", "operator"=>"OPERATOR_EQUAL", "categorical_values"=>[{"string_value"=>"<string>", "bool_value"=>"<boolean>", "null_value"=>"<string>"}, {"string_value"=>"<string>", "bool_value"=>"<boolean>", "null_value"=>"<string>"}]}], "measurement_period"=>{"granularity"=>"GRANULARITY_BY_DAY", "range"=>"RANGE_LAST_COMPLETE"}, "comparison"=>{"comparison"=>"TIME_COMPARISON_PREVIOUS_PERIOD"}}}

HEADERS

KeyDatatypeRequiredDescription
X-Tableau-AuthstringThe Tableau authentication header. The value is a credentials token from a Tableau server's response to an authentication request.
The Content-Type and Accept headers should be the mediatype of the request and response except in cases where you want to explicitly allow other versions of the resource.
Content-Typestring
Acceptstring

RESPONSES

status: Created

{&quot;metric&quot;:{&quot;id&quot;:&quot;\u003cstring\u003e&quot;,&quot;specification&quot;:{&quot;filters&quot;:[{&quot;field&quot;:&quot;\u003cstring\u003e&quot;,&quot;operator&quot;:&quot;OPERATOR_UNSPECIFIED&quot;,&quot;categorical_values&quot;:[{&quot;string_value&quot;:&quot;\u003cstring\u003e&quot;,&quot;bool_value&quot;:&quot;\u003cboolean\u003e&quot;,&quot;null_value&quot;:&quot;\u003cstring\u003e&quot;},{&quot;string_value&quot;:&quot;\u003cstring\u003e&quot;,&quot;bool_value&quot;:&quot;\u003cboolean\u003e&quot;,&quot;null_value&quot;:&quot;\u003cstring\u003e&quot;}]},{&quot;field&quot;:&quot;\u003cstring\u003e&quot;,&quot;operator&quot;:&quot;OPERATOR_UNSPECIFIED&quot;,&quot;categorical_values&quot;:[{&quot;string_value&quot;:&quot;\u003cstring\u003e&quot;,&quot;bool_value&quot;:&quot;\u003cboolean\u003e&quot;,&quot;null_value&quot;:&quot;\u003cstring\u003e&quot;},{&quot;string_value&quot;:&quot;\u003cstring\u003e&quot;,&quot;bool_value&quot;:&quot;\u003cboolean\u003e&quot;,&quot;null_value&quot;:&quot;\u003cstring\u003e&quot;}]}],&quot;measurement_period&quot;:{&quot;granularity&quot;:&quot;GRANULARITY_BY_MONTH&quot;,&quot;range&quot;:&quot;RANGE_UNSPECIFIED&quot;},&quot;comparison&quot;:{&quot;comparison&quot;:&quot;TIME_COMPARISON_PREVIOUS_PERIOD&quot;}},&quot;definition_id&quot;:&quot;\u003cstring\u003e&quot;,&quot;is_default&quot;:&quot;\u003cboolean\u003e&quot;,&quot;schema_version&quot;:&quot;\u003cstring\u003e&quot;},&quot;is_metric_created&quot;:&quot;\u003cboolean\u003e&quot;}