Skip to contentSkip to navigationSkip to topbar
On this page

Flex Insights API General Usage


(warning)

Public beta

Flex Insights (also known as Historical Reporting) is currently available as a public beta release and the information contained in the Flex Insights documentation is subject to change. This means that some features are not yet implemented and others may be changed before the product is declared as generally available. Public beta products are not covered by a Twilio SLA.

Any reference to "Historical Reporting," "Flex Insights API," "Flex Insights Historical Reporting," or "Flex Insights Historical Reporting API" in the Flex Insights documentation refers to Flex Insights.


Prerequisites

prerequisites page anchor

Before you start exporting data, you will need to have:


The procedure requires 2 API calls.

The first authenticates and returns an SST (Super Secured Token) using your login and password. Once the SST is available, a TT (Temporary Token) must be requested. The TT has to be included in any subsequent API calls.

(warning)

Warning

In order to obtain the password for direct login, please contact the Flex Insights Support Team(link takes you to an external page).

Flex Insights - API AuthenticationLink to code sample: Flex Insights - API Authentication
1
curl -X POST https://analytics.ytica.com/gdc/account/login \
2
-H 'Accept: application/json' \
3
-H 'Content-Type: application/json' \
4
-d '{
5
"postUserLogin":{
6
"login":"{email_address}",
7
"password":"{password}",
8
"remember": 0,
9
"verify_level": 2
10
}
11
}'

Output

1
{
2
"userLogin":{
3
"profile":"/gdc/account/profile/{profile_id}",
4
"state":"/gdc/account/login/{profile_id}",
5
"token":"{super_secured_token}"
6
}
7
}

SuperSecure Tokens (SST) have a default lifetime of two weeks.

(warning)

Warning

If you received a status code of 429, this means that you made too many invalid login requests. Check your credentials, and look for the Retry-After HTTP header in the response: this specifies the period (in seconds) after which you can attempt to log in again.


Retrieving the Temporary Token

retrieving-the-temporary-token page anchor

You must have a valid Temporary Token (TT) for all subsequent calls to the API. To get a valid TT, use the following API:

1
curl -X GET https://analytics.ytica.com/gdc/account/token \
2
-H 'Accept: application/json' \
3
-H 'Content-Type: application/json' \
4
-H 'X-GDC-AuthSST: {super_secured_token}'

Output

1
{
2
"userToken":{
3
"token":"{temporary_token}}"
4
}
5
}

If you are using a REST client which supports cookies, on the initial login request you can set "verify_level": 0 and use the returned cookie called GDCAuthTT (which contains the Temporary Token) directly in subsequent API calls. This way, you don't need to adjust the Header manually.

Temporary Token (TT) is valid for 10 minutes. Once the Temporary Token expires, you have to call the Token API to refresh it.


For any subsequent API calls, ensure that the TT is always passed in the headers as a cookie with the name GDCAuthTT

Flex Insights - Usage Example

flex-insights---usage-example page anchor
1
curl -X GET https://analytics.ytica.com/gdc/{any_api} \
2
-H 'Accept: application/json' \
3
-H 'Content-Type: application/json' \
4
-b '{temporary_token}}; path=/gdc; secure; HttpOnly'

After successful authentication you can Export Data from Flex Insights via API.


After you performed all necessary operations, you should log out to invalidate the SST. For this, you need to know your profile ID which can be found in the API Authentication response. Note the {profile_id} is only the last part (the alphanumeric string) of the userLogin "profile" object: /gdc/account/profile/{profile_id}.

1
curl --location --request DELETE 'https://analytics.ytica.com/gdc/account/login/{profile_id}' \
2
--header 'Accept: application/json' \
3
--header 'Content-Type: application/json' \
4
--header 'X-GDC-AuthSST: {super_secured_token}' \
5
--header 'Cookie: GDCAuthTT=XXXXX-XXXXX-XXXXX'

Output

204 No Content

If you no longer require access to the portal, you can delete your own profile from the Flex Insights Analytics Portal(link takes you to an external page). After that, you will no longer be able to access the Analytics Portal and the Insights API with your direct credentials, and your user account will be removed from all workspaces. To get started, retrieve your profile_id from the profile link in the user login JSON response during authentication:

"profile":"/gdc/account/profile/{profile_id}"

Run the following command to perform the deletion:

1
curl --location --request DELETE 'https://analytics.ytica.com/gdc/account/profile/{profile_id}' \
2
--header 'Accept: application/json' \
3
--header 'Content-Type: application/json' \
4
--header 'X-GDC-AuthSST: {super_secured_token}' \
5
--header 'Cookie: GDCAuthTT=XXXXX-XXXXX-XXXXX'

Output

204 No Content
(warning)

Warning

Deleting a profile is only allowed for the currently logged in user. If you need to delete another user's profile, please contact Twilio Support.

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.