Cloud Data Exporter API
Version 1.0.6
Cloud Data Exporter API
Schedule recurring exports of your raw event data (installs, app opens, purchases, ad revenue and more) into an S3 bucket you own, as hive-partitioned Parquet. Tenjin writes the files with its own AWS role, in a session named for your organization that your bucket policy lets in, and records every run so you can follow deliveries. Nothing is set up in your AWS account but that bucket policy.
Authentication
Every request carries a dashboard access token: Authorization: Bearer <token>. Tokens are
generated at dashboard.tenjin.com/dashboard/access_tokens and are bound to one organization; the
API operates on that organization.
Setting up an export
- Get the bucket policy.
GET /v1/bucket_policy?bucket=…&prefix=…&name=…returnssession_arn, Tenjin's session for your organization, andbucket_policy, the document to add, naming the bucket, prefix and config name you passed. - Add it to your bucket. In the S3 console, open the bucket's Permissions → Bucket policy
→ Edit. Paste the document as it is into a bucket with no policy. If the bucket already has
one, keep it and add the two statements, the objects with a
Sid, to itsStatementlist. The statements cover your prefix, so one pair serves every config under it. A config with no prefix gets statements for its own folder instead, and each such config needs its own pair. Both pairs carry the same two Sids, so append the config name to the second pair's Sids. - Test it.
POST /v1/configs/test_bucket_permissionswithbucket,region,nameand, if you use one,prefix. A200means Tenjin's session can write there. A422names the action your bucket refused and quotes S3's reason, for exampleBucket permission check failed: s3:ListBucket was refused (User: <session_arn> is not authorized to perform: s3:ListBucket on resource: "arn:aws:s3:::<bucket>" because no resource-based policy allows the s3:ListBucket action). Nothing is stored. - Create the config.
POST /v1/configswith thenameanddestination_config(bucket,regionand an optionalprefix). There is nothing else to choose: a config exports every event of your organization, every hour, with no app or ad network filter. Tenjin runs the step 3 check again before saving: a refusal is a422and creates nothing, and a503means Tenjin could not complete the check, so retry shortly. An organization can have at most two Parquet configs, and a third is a422. Runs start at quarter past the hour UTC, once the hour's rows have settled. A run is capped at an hour, so an hour's files are there within two hours of the hour's end unless the run failed. The first run delivers the hour just ended, and Tenjin also starts a run for each of the 24 hours before it.
Following a run
A config produces one events run per hour window, 24 a day. A window that failed and ran
again has a run for each attempt: a later completed run with the same window_start means the
hour was delivered.
GET /v1/runs?config_id={id} lists them newest window first, paginated through
page and per_page, with Link, Total and Per-Page response headers. window_start
and window_end say which slice of your data a run covers.
A run moves through four states:
status |
Meaning |
|---|---|
pending |
Recorded, not started yet |
processing |
Export in flight |
completed |
The window was delivered to your bucket |
failed |
Did not deliver |
When a run is failed, fault says whose problem it is, so you never have to guess whether
to act:
customermeans something in your AWS setup stopped the delivery, andfailure_reasoncarries AWS's own message, for exampleNoSuchBucket: The specified bucket does not exist. Fix the cause: Tenjin retries a failed window for 24 hours, and later windows deliver normally.tenjinmeans the failure was ours and there is nothing for you to fix.failure_reasonis deliberately empty: it would describe our internals, not your setup. Quotedagster_run_idif you raise it with support.
GET /v1/runs?config_id={id}&status=failed&kind=all is therefore the one call worth scheduling
if you want to be told about problems. Without kind=all it lists the failed events runs only
and misses a report table your bucket refused.
What lands in your bucket
Each window delivers ZSTD-compressed Parquet files into hive-partitioned folders under the
config's v2/events/ folder:
s3://<bucket>/[<prefix>/]<config name>/v2/events/
attribution_source=<source>/dt=<YYYY-MM-DD>/h=<HH>/<source>_<YYYY-MM-DD>_<HH>_events.parquet
The folder names are partition columns, which Athena and DuckDB read like any other column:
| Column | Values | Meaning |
|---|---|---|
attribution_source |
tenjin |
Your first-party event data |
meta_mmp |
Partner (Meta MMP) attribution data | |
dt |
YYYY-MM-DD |
The UTC date of the row's created_at |
h |
00 to 23 |
The UTC hour of the row's created_at |
The files themselves carry no attribution_source, dt or h column. All three come from
the folder names, so a loader that reads the files without their paths loses them.
Each hour folder holds one file per source and an empty object named _SUCCESS, which Tenjin
writes once the hour's file is in place. An hour with no rows for a source holds only
_SUCCESS. When Tenjin delivers an hour again, the new file overwrites the old one at the same
key, and an hour delivered again with no rows left loses its earlier file. Read a folder once
it holds _SUCCESS: a folder without it is not finished.
The config name is a folder, so renaming a config, or changing its prefix or bucket, moves where its next runs write. Files already delivered stay where they are.
Beside events/, the ten report tables arrive as sibling folders under the same v2/: five
entity tables (apps/, campaigns/, publisher_apps/, ad_networks/, creatives/), one
file each and rewritten whole, and five dated tables (daily_events/, cohort_events/,
pre_cohort_events/, daily_country_stats/, daily_ad_revenues/), one file per day, in a
dt= folder, or an edt= folder for cohort_events/.
The setup guide describes each table and its schedule. Every dated folder and every entity
folder holds a _SUCCESS as well. On a dated table it says the last run that covered the day
finished it, not that the day is final: today's file is rewritten every hour.
The tables are written by jobs of their own, and their runs are runs too: a dated tables run
every hour and an entity tables run every two hours. A tables run is listed once it has
finished, so it is never pending or processing. A backfill, and the monthly recheck of
spend and ad revenue back to 2024-01-01, are not listed. A run's
kind says which it is: events, dated_tables or entity_tables. GET /v1/runs lists
the events runs unless you ask for more: ?kind=dated_tables or ?kind=entity_tables lists
one kind, and ?kind=all lists every kind together. ?table=daily_ad_revenues lists the
runs that carry that one table, and table takes any of the ten folder names above,
without the slash. It also lists the failed runs of that table's kind: a run that failed
before it reached the table has no entry for it. A request with table needs no kind. A
kind sent beside it must be a valid one and is not used. A tables run carries tables,
one entry for each table with its outcome:
outcome |
Meaning |
|---|---|
delivered |
The run wrote or removed files of the table |
unchanged |
Nothing in the table had changed since the last run |
deferred |
Some dates were left to the next run |
refused |
Your bucket refused the table; detail carries its message |
A tables run whose bucket refused a table is failed. Its fault is customer, unless
the run also failed on our side, and then it is tenjin. For a dated
tables run, window_start is the first day it covers. window_end is when it finished, or the end
of the last day it covers when it finished after that day.
An entity tables run rewrites each table whole, so its window is the run itself.
The events files carry ids, not names, and the names are in the entity tables. Join
apps on app_id and ad_networks on ad_network_id. Join campaigns on
coalesce(source_campaign_id, campaign_id): campaign_id is filled on impressions and
clicks, and an install or a later event carries its campaign in source_campaign_id. For a
creative's name take coalesce(creatives.name, creative_name) over a left join on
creative_id, which most rows leave empty while they carry creative_name.
Changing or stopping an export
- Pause or resume with
PATCH /v1/configs/{id}andenabled; rename the config or change its destination the same way. APATCHchanges only the fields it sends, and insidedestination_configonly the keys it sends. An emptyprefixremoves the prefix. A change to thename, or to thebucket,prefixorregionindestination_config, runs the bucket permission check again against the new values. A pause or a resume does not run it. - Before you change the bucket or the prefix, or rename a config that has no prefix, get
GET /v1/bucket_policyfor the new values and add its statements. Otherwise thePATCHis a422. Then repoint whatever reads the old folder: a table's location, a crawler or a glob. DELETE /v1/configs/{id}stops the schedule. The files already delivered stay in your bucket until you delete them. The config's past runs are kept but no longer listed.- Removing the statements from your bucket policy also stops delivery, because every write is then refused.
Errors
Errors are RFC 9457 problem documents: type, title, status, and detail when there is more
to say. Each also carries error, which repeats title. A missing or malformed token is a
403; a revoked token, or a user role without access to the Cloud Data Exporter, is a 401; an OAuth access token past its expiry is a 498 with the
invalid-token type, so exchange a new one; a config or run outside your organization is a 404; a
payload that fails validation, or a bucket permission check your bucket refused, is a 422; and
a 503 on a bucket permission check means retry. The Cloud Data Exporter is enabled per
organization: if every endpoint but this document answers 403 Forbidden, contact
support@tenjin.com.
Authentication
Generate an access token on the Access Tokens page of the Tenjin dashboard and send it as Authorization: Bearer <access token>. API access tokens explains them.
Operations
Bucket policy
- Get the bucket policy
GET /v1/bucket_policy
Cloud Data Exporter Configs
- List configs
GET /v1/configs - Create a config
POST /v1/configs - Get a config
GET /v1/configs/{id} - Update a config
PATCH /v1/configs/{id} - Delete a config
DELETE /v1/configs/{id} - Test bucket permissions
POST /v1/configs/test_bucket_permissions