Sorting is available for most Ads API collection endpoints (that return a list of objects). Depending on the endpoint, you will find various parameters enabled for sorting. Most fields returned by these parameters (except for IDs and ENUMs) will be sortable.Documentation Index
Fetch the complete documentation index at: https://x-preview-mintlify-weekly-changelog-1778710653.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
| API Collection | Sortable Parameters |
|---|---|
| Accounts | created_at, updated_at, deleted, name |
| Funding Instruments | created_at, updated_at, deleted, funded_amount_local_micro, start_time, end_time |
| Campaigns | created_at, updated_at, deleted, name, start_time, end_time, daily_budget_amount_local_micro, total_budget_amount_local_micro, standard_delivery |
| Line Items | created_at, updated_at, deleted, bid_amount_local_micro |
| Cards | created_at, updated_at, deleted, name |
| Promoted Accounts | created_at, updated_at, deleted, paused |
| Promoted Tweets | created_at, updated_at, deleted, paused |
| App Event Tags | created_at, updated_at, deleted, post_view_attribution_window, post_engagement_attribution_window, assisted_conversion, provider_app_event_name |
Getting Started
In your API request simply appendsort_by=[attribute name]-[asc/desc] where the attribute is a valid attribute that is returned in the JSON of your GET request.
For example, you can use ?name-asc to sort by name alphabetically or ?name-desc to sort in reverse.
Going Deeper
Below is a sample API request to return all line items by thebid_amount_local_micro in descending order:
twurl -H ads-api.x.com "/5/accounts/k9w0oe/line\_items?sort\_by=bid\_amount\_local_micro-desc"