curl --request PATCH \
--url https://api.datalyr.com/v1/analyses/{analysisId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"analysis": {
"title": "<string>",
"body_md": "<string>",
"plans": [
{
"id": "<string>",
"plan": {
"metrics": [
"<string>"
],
"date_range": {
"from": "<string>",
"to": "<string>"
},
"dimensions": [
"<string>"
],
"filters": [
{
"dimension": "<string>",
"value": "<string>"
}
],
"attribution": {
"window_days": 45
},
"order_by": [
{
"field": "<string>"
}
],
"limit": 200,
"cursor": "<string>",
"response_format": "concise"
},
"label": "<string>"
}
],
"report_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"date_range": {
"from": "<string>",
"to": "<string>"
},
"expected_updated_at": "2023-11-07T05:31:56Z"
},
"dry_run": false
}
'import requests
url = "https://api.datalyr.com/v1/analyses/{analysisId}"
payload = {
"analysis": {
"title": "<string>",
"body_md": "<string>",
"plans": [
{
"id": "<string>",
"plan": {
"metrics": ["<string>"],
"date_range": {
"from": "<string>",
"to": "<string>"
},
"dimensions": ["<string>"],
"filters": [
{
"dimension": "<string>",
"value": "<string>"
}
],
"attribution": { "window_days": 45 },
"order_by": [{ "field": "<string>" }],
"limit": 200,
"cursor": "<string>",
"response_format": "concise"
},
"label": "<string>"
}
],
"report_ids": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"],
"date_range": {
"from": "<string>",
"to": "<string>"
},
"expected_updated_at": "2023-11-07T05:31:56Z"
},
"dry_run": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
analysis: {
title: '<string>',
body_md: '<string>',
plans: [
{
id: '<string>',
plan: {
metrics: ['<string>'],
date_range: {from: '<string>', to: '<string>'},
dimensions: ['<string>'],
filters: [{dimension: '<string>', value: '<string>'}],
attribution: {window_days: 45},
order_by: [{field: '<string>'}],
limit: 200,
cursor: '<string>',
response_format: 'concise'
},
label: '<string>'
}
],
report_ids: ['3c90c3cc-0d44-4b50-8888-8dd25736052a'],
date_range: {from: '<string>', to: '<string>'},
expected_updated_at: '2023-11-07T05:31:56Z'
},
dry_run: false
})
};
fetch('https://api.datalyr.com/v1/analyses/{analysisId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.datalyr.com/v1/analyses/{analysisId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'analysis' => [
'title' => '<string>',
'body_md' => '<string>',
'plans' => [
[
'id' => '<string>',
'plan' => [
'metrics' => [
'<string>'
],
'date_range' => [
'from' => '<string>',
'to' => '<string>'
],
'dimensions' => [
'<string>'
],
'filters' => [
[
'dimension' => '<string>',
'value' => '<string>'
]
],
'attribution' => [
'window_days' => 45
],
'order_by' => [
[
'field' => '<string>'
]
],
'limit' => 200,
'cursor' => '<string>',
'response_format' => 'concise'
],
'label' => '<string>'
]
],
'report_ids' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
],
'date_range' => [
'from' => '<string>',
'to' => '<string>'
],
'expected_updated_at' => '2023-11-07T05:31:56Z'
],
'dry_run' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.datalyr.com/v1/analyses/{analysisId}"
payload := strings.NewReader("{\n \"analysis\": {\n \"title\": \"<string>\",\n \"body_md\": \"<string>\",\n \"plans\": [\n {\n \"id\": \"<string>\",\n \"plan\": {\n \"metrics\": [\n \"<string>\"\n ],\n \"date_range\": {\n \"from\": \"<string>\",\n \"to\": \"<string>\"\n },\n \"dimensions\": [\n \"<string>\"\n ],\n \"filters\": [\n {\n \"dimension\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"attribution\": {\n \"window_days\": 45\n },\n \"order_by\": [\n {\n \"field\": \"<string>\"\n }\n ],\n \"limit\": 200,\n \"cursor\": \"<string>\",\n \"response_format\": \"concise\"\n },\n \"label\": \"<string>\"\n }\n ],\n \"report_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"date_range\": {\n \"from\": \"<string>\",\n \"to\": \"<string>\"\n },\n \"expected_updated_at\": \"2023-11-07T05:31:56Z\"\n },\n \"dry_run\": false\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.datalyr.com/v1/analyses/{analysisId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"analysis\": {\n \"title\": \"<string>\",\n \"body_md\": \"<string>\",\n \"plans\": [\n {\n \"id\": \"<string>\",\n \"plan\": {\n \"metrics\": [\n \"<string>\"\n ],\n \"date_range\": {\n \"from\": \"<string>\",\n \"to\": \"<string>\"\n },\n \"dimensions\": [\n \"<string>\"\n ],\n \"filters\": [\n {\n \"dimension\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"attribution\": {\n \"window_days\": 45\n },\n \"order_by\": [\n {\n \"field\": \"<string>\"\n }\n ],\n \"limit\": 200,\n \"cursor\": \"<string>\",\n \"response_format\": \"concise\"\n },\n \"label\": \"<string>\"\n }\n ],\n \"report_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"date_range\": {\n \"from\": \"<string>\",\n \"to\": \"<string>\"\n },\n \"expected_updated_at\": \"2023-11-07T05:31:56Z\"\n },\n \"dry_run\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.datalyr.com/v1/analyses/{analysisId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"analysis\": {\n \"title\": \"<string>\",\n \"body_md\": \"<string>\",\n \"plans\": [\n {\n \"id\": \"<string>\",\n \"plan\": {\n \"metrics\": [\n \"<string>\"\n ],\n \"date_range\": {\n \"from\": \"<string>\",\n \"to\": \"<string>\"\n },\n \"dimensions\": [\n \"<string>\"\n ],\n \"filters\": [\n {\n \"dimension\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"attribution\": {\n \"window_days\": 45\n },\n \"order_by\": [\n {\n \"field\": \"<string>\"\n }\n ],\n \"limit\": 200,\n \"cursor\": \"<string>\",\n \"response_format\": \"concise\"\n },\n \"label\": \"<string>\"\n }\n ],\n \"report_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"date_range\": {\n \"from\": \"<string>\",\n \"to\": \"<string>\"\n },\n \"expected_updated_at\": \"2023-11-07T05:31:56Z\"\n },\n \"dry_run\": false\n}"
response = http.request(request)
puts response.read_body{
"dry_run": true,
"applied": true,
"diff": {
"action": "<string>",
"resource": {
"type": "conversion_rule",
"id": "<string>",
"label": "<string>"
},
"prior_state": {},
"new_state": {},
"changes": [
{
"field": "<string>",
"from": "<unknown>",
"to": "<unknown>"
}
],
"effects": [
{
"type": "postback_target",
"summary": "<string>",
"platform": "<string>",
"ad_account_id": "<string>",
"asset_id": "<string>",
"asset_field": "<string>",
"endpoint_url_masked": "<string>",
"trigger_event": "<string>",
"trigger_event_source": "<string>",
"platform_event": "<string>",
"active": true,
"operation": "put",
"key": "<string>",
"path": "<string>",
"requires_approval": true,
"approver_roles": [
"<string>"
],
"review_surface": "<string>",
"supersedes": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
]
}
]
},
"audit_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"title": "<string>",
"report_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"created_via": "dashboard",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"workspace_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"body_md": "<string>",
"plans": [
{
"id": "<string>",
"plan": {
"metrics": [
"<string>"
],
"date_range": {
"from": "<string>",
"to": "<string>"
},
"dimensions": [
"<string>"
],
"filters": [
{
"dimension": "<string>",
"op": "eq",
"value": "<string>"
}
],
"granularity": "hour",
"compare": "previous_period",
"attribution": {
"model": "last_touch",
"window_days": 45
},
"order_by": [
{
"field": "<string>",
"dir": "asc"
}
],
"limit": 200,
"cursor": "<string>",
"response_format": "concise"
},
"label": "<string>"
}
],
"date_range": {
"from": "<string>",
"to": "<string>"
},
"created_by": {
"type": "user",
"id": "<string>",
"client_id": "<string>"
},
"deleted_at": "2023-11-07T05:31:56Z"
}
}{
"error": "<string>"
}{
"error": "<string>",
"code": "insufficient_scope",
"required_scope": "<string>"
}{
"error": "<string>"
}{
"error": "<string>",
"code": "unknown_report",
"hint": "<string>"
}{
"error": "<string>",
"code": "unknown_report",
"hint": "<string>"
}{
"error": "<string>"
}Update an analysis
Change any subset of an analysis. Needs datalyr:write:reports. Send at least one field. plans and report_ids are full replacements.
Send expected_updated_at from your last read to refuse the write when someone changed the analysis in between: the request then returns 409 with code: stale_analysis.
curl --request PATCH \
--url https://api.datalyr.com/v1/analyses/{analysisId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"analysis": {
"title": "<string>",
"body_md": "<string>",
"plans": [
{
"id": "<string>",
"plan": {
"metrics": [
"<string>"
],
"date_range": {
"from": "<string>",
"to": "<string>"
},
"dimensions": [
"<string>"
],
"filters": [
{
"dimension": "<string>",
"value": "<string>"
}
],
"attribution": {
"window_days": 45
},
"order_by": [
{
"field": "<string>"
}
],
"limit": 200,
"cursor": "<string>",
"response_format": "concise"
},
"label": "<string>"
}
],
"report_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"date_range": {
"from": "<string>",
"to": "<string>"
},
"expected_updated_at": "2023-11-07T05:31:56Z"
},
"dry_run": false
}
'import requests
url = "https://api.datalyr.com/v1/analyses/{analysisId}"
payload = {
"analysis": {
"title": "<string>",
"body_md": "<string>",
"plans": [
{
"id": "<string>",
"plan": {
"metrics": ["<string>"],
"date_range": {
"from": "<string>",
"to": "<string>"
},
"dimensions": ["<string>"],
"filters": [
{
"dimension": "<string>",
"value": "<string>"
}
],
"attribution": { "window_days": 45 },
"order_by": [{ "field": "<string>" }],
"limit": 200,
"cursor": "<string>",
"response_format": "concise"
},
"label": "<string>"
}
],
"report_ids": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"],
"date_range": {
"from": "<string>",
"to": "<string>"
},
"expected_updated_at": "2023-11-07T05:31:56Z"
},
"dry_run": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
analysis: {
title: '<string>',
body_md: '<string>',
plans: [
{
id: '<string>',
plan: {
metrics: ['<string>'],
date_range: {from: '<string>', to: '<string>'},
dimensions: ['<string>'],
filters: [{dimension: '<string>', value: '<string>'}],
attribution: {window_days: 45},
order_by: [{field: '<string>'}],
limit: 200,
cursor: '<string>',
response_format: 'concise'
},
label: '<string>'
}
],
report_ids: ['3c90c3cc-0d44-4b50-8888-8dd25736052a'],
date_range: {from: '<string>', to: '<string>'},
expected_updated_at: '2023-11-07T05:31:56Z'
},
dry_run: false
})
};
fetch('https://api.datalyr.com/v1/analyses/{analysisId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.datalyr.com/v1/analyses/{analysisId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'analysis' => [
'title' => '<string>',
'body_md' => '<string>',
'plans' => [
[
'id' => '<string>',
'plan' => [
'metrics' => [
'<string>'
],
'date_range' => [
'from' => '<string>',
'to' => '<string>'
],
'dimensions' => [
'<string>'
],
'filters' => [
[
'dimension' => '<string>',
'value' => '<string>'
]
],
'attribution' => [
'window_days' => 45
],
'order_by' => [
[
'field' => '<string>'
]
],
'limit' => 200,
'cursor' => '<string>',
'response_format' => 'concise'
],
'label' => '<string>'
]
],
'report_ids' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
],
'date_range' => [
'from' => '<string>',
'to' => '<string>'
],
'expected_updated_at' => '2023-11-07T05:31:56Z'
],
'dry_run' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.datalyr.com/v1/analyses/{analysisId}"
payload := strings.NewReader("{\n \"analysis\": {\n \"title\": \"<string>\",\n \"body_md\": \"<string>\",\n \"plans\": [\n {\n \"id\": \"<string>\",\n \"plan\": {\n \"metrics\": [\n \"<string>\"\n ],\n \"date_range\": {\n \"from\": \"<string>\",\n \"to\": \"<string>\"\n },\n \"dimensions\": [\n \"<string>\"\n ],\n \"filters\": [\n {\n \"dimension\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"attribution\": {\n \"window_days\": 45\n },\n \"order_by\": [\n {\n \"field\": \"<string>\"\n }\n ],\n \"limit\": 200,\n \"cursor\": \"<string>\",\n \"response_format\": \"concise\"\n },\n \"label\": \"<string>\"\n }\n ],\n \"report_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"date_range\": {\n \"from\": \"<string>\",\n \"to\": \"<string>\"\n },\n \"expected_updated_at\": \"2023-11-07T05:31:56Z\"\n },\n \"dry_run\": false\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.datalyr.com/v1/analyses/{analysisId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"analysis\": {\n \"title\": \"<string>\",\n \"body_md\": \"<string>\",\n \"plans\": [\n {\n \"id\": \"<string>\",\n \"plan\": {\n \"metrics\": [\n \"<string>\"\n ],\n \"date_range\": {\n \"from\": \"<string>\",\n \"to\": \"<string>\"\n },\n \"dimensions\": [\n \"<string>\"\n ],\n \"filters\": [\n {\n \"dimension\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"attribution\": {\n \"window_days\": 45\n },\n \"order_by\": [\n {\n \"field\": \"<string>\"\n }\n ],\n \"limit\": 200,\n \"cursor\": \"<string>\",\n \"response_format\": \"concise\"\n },\n \"label\": \"<string>\"\n }\n ],\n \"report_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"date_range\": {\n \"from\": \"<string>\",\n \"to\": \"<string>\"\n },\n \"expected_updated_at\": \"2023-11-07T05:31:56Z\"\n },\n \"dry_run\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.datalyr.com/v1/analyses/{analysisId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"analysis\": {\n \"title\": \"<string>\",\n \"body_md\": \"<string>\",\n \"plans\": [\n {\n \"id\": \"<string>\",\n \"plan\": {\n \"metrics\": [\n \"<string>\"\n ],\n \"date_range\": {\n \"from\": \"<string>\",\n \"to\": \"<string>\"\n },\n \"dimensions\": [\n \"<string>\"\n ],\n \"filters\": [\n {\n \"dimension\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"attribution\": {\n \"window_days\": 45\n },\n \"order_by\": [\n {\n \"field\": \"<string>\"\n }\n ],\n \"limit\": 200,\n \"cursor\": \"<string>\",\n \"response_format\": \"concise\"\n },\n \"label\": \"<string>\"\n }\n ],\n \"report_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"date_range\": {\n \"from\": \"<string>\",\n \"to\": \"<string>\"\n },\n \"expected_updated_at\": \"2023-11-07T05:31:56Z\"\n },\n \"dry_run\": false\n}"
response = http.request(request)
puts response.read_body{
"dry_run": true,
"applied": true,
"diff": {
"action": "<string>",
"resource": {
"type": "conversion_rule",
"id": "<string>",
"label": "<string>"
},
"prior_state": {},
"new_state": {},
"changes": [
{
"field": "<string>",
"from": "<unknown>",
"to": "<unknown>"
}
],
"effects": [
{
"type": "postback_target",
"summary": "<string>",
"platform": "<string>",
"ad_account_id": "<string>",
"asset_id": "<string>",
"asset_field": "<string>",
"endpoint_url_masked": "<string>",
"trigger_event": "<string>",
"trigger_event_source": "<string>",
"platform_event": "<string>",
"active": true,
"operation": "put",
"key": "<string>",
"path": "<string>",
"requires_approval": true,
"approver_roles": [
"<string>"
],
"review_surface": "<string>",
"supersedes": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
]
}
]
},
"audit_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"title": "<string>",
"report_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"created_via": "dashboard",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"workspace_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"body_md": "<string>",
"plans": [
{
"id": "<string>",
"plan": {
"metrics": [
"<string>"
],
"date_range": {
"from": "<string>",
"to": "<string>"
},
"dimensions": [
"<string>"
],
"filters": [
{
"dimension": "<string>",
"op": "eq",
"value": "<string>"
}
],
"granularity": "hour",
"compare": "previous_period",
"attribution": {
"model": "last_touch",
"window_days": 45
},
"order_by": [
{
"field": "<string>",
"dir": "asc"
}
],
"limit": 200,
"cursor": "<string>",
"response_format": "concise"
},
"label": "<string>"
}
],
"date_range": {
"from": "<string>",
"to": "<string>"
},
"created_by": {
"type": "user",
"id": "<string>",
"client_id": "<string>"
},
"deleted_at": "2023-11-07T05:31:56Z"
}
}{
"error": "<string>"
}{
"error": "<string>",
"code": "insufficient_scope",
"required_scope": "<string>"
}{
"error": "<string>"
}{
"error": "<string>",
"code": "unknown_report",
"hint": "<string>"
}{
"error": "<string>",
"code": "unknown_report",
"hint": "<string>"
}{
"error": "<string>"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Response
The write was applied. diff describes what changed, data is the analysis, and audit_id is the handle to undo it.
False on a dry run and on every error.
The change, in full. A dry run returns the change it WOULD make; an applied write returns the change it DID make, in the same shape, so the two can be compared directly.
Show child attributes
Show child attributes
Present on an applied write. The handle POST /audit/{auditId}/undo takes.
Show child attributes
Show child attributes
Was this page helpful?