Skip to main content

Attribution API Documentation

Marc Garbella avatar
Written by Marc Garbella
Updated over a week ago

The base URL for the API is https://api.getklar.com/.


Rate Limit

The API enforces a rate limit: 2 requests per 30 seconds.

You can only request the data for up to 31 days at once.


1. Get Access Token

From the frontend, get the Refresh Token under the Store Settings. One Refresh Token is connected to one store and one user.

This endpoint is used to exchange a user's static refresh token for a temporary access token required for API authentication.

Detail

Description

Endpoint

POST /public/auth/token

Description

Provides a short-lived access token for API authentication.

Request

Header

Description

token

The user's static refresh token.

Successful Response: 201 Created

The response body contains the temporary access token and its expiration time in milliseconds.

Important Note: The accessToken is valid for 5 minutes (300,000 milliseconds). The user must request a new one after it expires.

{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresIn": 300000 // Milliseconds
}


2. Get Attribution Report

This endpoint retrieves the attribution report data based on the specified filters.

Detail

Description

Endpoint

GET /public/attribution

Authentication

This endpoint requires a Bearer Token in the Authorization header.

Header

Value Format

Authorization

Bearer <accessToken> (where <accessToken> is the token obtained from the Get Access Token step).

Query Parameters

Parameter

Type

Required

Description

Accepted Values / Format

startDate

string

Yes

The start date for the report.

Format: yyyy-mm-dd. Example: 2025-01-01

endDate

string

Yes

The end date for the report. Must be within 31 days of the startDate.

The endDate is always excluded.

Format: yyyy-mm-dd. Example: 2025-01-31

metric

string

No

The attribution model to use for the calculation.

first_touch, last_touch, data_driven, linear, any_click, any_click_unique, u_shape, time_decay, marketing_mix

window

string

No

The attribution window to consider.

unlimited, 1_day, 7_day, 28_day

date_breakdown

string

No

The date type to group the results by.

order, touch

Successful Response: 200 OK

The response is an array of objects, where each object contains the requested dimensions and metrics.

JSON

[
{
"channelName": "Google Generic Paid Search",
"date": "2025-10-02",
"campaignName": "Sample",
"campaignId": 123,
"adGroupName": "Catch all",
"adGroupId": 123,
"adName": "Sample",
"adId": 123,
"orders": 2.1329447083,
"nc": 1.299611375,
"rc": 0.8333333333,
"netRevenue": 126.8840278483,
"grossRevenue": 136.5776026566,
"cost": 2.2488128275,
"cm1": 82.8780053944,
"cm2": 72.1865404057,
"clv_30": 44.346015638,
"clv_60": 44.346015638,
"clv_90": 44.346015638,
"acm2": 44.346015638,
"ncGrossRevenue": 82.0942693233,
"rcGrossRevenue": 54.4833333333,
"ncNetRevenue": 75.9650247472,
"rcNetRevenue": 50.9190031011
},
{
"channelName": "Organic Social",
"date": "2025-01-15",
"campaignName": "Jan Content Push",
"campaignId": "cmp_67890",
...
}

]

Did this answer your question?