Guide

Datasets REST API

Custom routes under prc-api/v3 for downloads, ATP, and editor stats.

Base path: /wp-json/prc-api/v3/

Auth summary

AccessRoutes
Firebase UID + token headers (public permission callback)get-download, check-atp, accept-atp, log-download
edit_postsdownload-stats
edit_post on datasetaudiences (GET/DELETE), build-audience (POST), audience-jobs (GET)

Firebase headers

HeaderPurpose
X-PRC-User-IdFirebase UID
X-PRC-User-TokenFirebase ID token validated server-side

get-download also applies per-IP rate limiting (HTTP 429 rate_limited).

POST /datasets/get-download

Reference

Request body

Typed options, defaults, and constraints in one scannable reference.
1 field
dataset_id number required
Dataset post ID.

Resolves the file URL after verifying the Firebase token, running extra gates (ATP), incrementing counters, and logging the download. Attachment files go through Protected_Files::grant_for_user().

POST /datasets/check-atp

Returns whether the Firebase user has accepted the ATP agreement.

POST /datasets/accept-atp

Records ATP acceptance on the user’s Firebase record via User_Data.

POST /datasets/log-download

Reference

Request body

Typed options, defaults, and constraints in one scannable reference.
1 field
dataset_id number required
Dataset post ID.

Logs a download without resolving a URL.

GET /datasets/download-stats

Permission: edit_posts

Reference

Query parameters

Typed options, defaults, and constraints in one scannable reference.
1 field
dataset_id number required
Dataset post ID.

Returns { total, log, daily, new_data_uploaded, splits } (24h transient cache).

GET /datasets/audiences

Permission: edit_post on the dataset

Reference

Query parameters

Typed options, defaults, and constraints in one scannable reference.
1 field
dataset_id number required
Dataset post ID.

Returns audience snapshots for the dataset (no email arrays).

POST /datasets/build-audience

Permission: edit_post on the dataset

Starts an async downloader audience job. Returns 202 with the job view. Does not wait for the Firebase scan and does not create a draft transactional email.

GET /datasets/audience-jobs/{job_id}

Permission: edit_post on the source dataset for that job

Poll a ds_ job. Inspectors may also poll Email Builder GET /prc-email-builder/v1/audience-jobs/{job_id}.

DELETE /datasets/audiences

Permission: edit_post on the dataset

Deletes the audience option and _meta companion. Pass verification and/or key.

Was this helpful?