API Reference
This is the full technical reference. For an overview of Lead Gen Ads, form structure, and the create → attach → export workflow, see the
Lead Generation Overview.
The Leads API requires the Campaign user permission. Lead exports are restricted to account administrators.
Content-Type to application/json.
Lead Forms
POST accounts/:account_id/lead_forms
Create a lead form associated with the current account. Resource URLhttps://ads-api.x.com/12/accounts/:account_id/lead_forms
The identifier for the leveraged account. Appears within the resource’s path and is generally a required parameter for all Advertiser API requests. The specified account must be associated with the authenticated user.
Non-empty array of fields the lead fills in. See fields entries. Keys must be unique within the form. At least one field must be required (
optional is false or omitted).Privacy policy of the advertiser collecting the leads. See privacy_policy.
Introduction card shown before the form fields. See introduction.
Final page shown after the form is submitted. See final_page.
POST https://ads-api.x.com/12/accounts/18ce54d4x5t/lead_forms
Example response
Nested objects
introduction
final_page
Shown to the lead after a successful submission. The optional CTA button links the lead onward (for example, to the advertiser’s site).
* Required only when
cta_button itself is present.
fields entries
Field keys
Contact fields
User information
privacy_policy
PUT accounts/:account_id/lead_forms/:lead_form_id
Update a lead form associated with the current account. Takes the same parameters as create; every one of them is optional. Omitted parameters keep their current value. Object parameters (introduction, final_page, privacy_policy) and the fields array are replaced wholesale when provided — there is no partial update within a nested object, and no way to unset one once set. A provided fields array must not be empty, and a provided final_page is validated the same way as on create.
Archived (deleted) lead forms are immutable and return a not-found error.
Resource URL
https://ads-api.x.com/12/accounts/:account_id/lead_forms/:lead_form_id
The identifier for the leveraged account. Appears within the resource’s path and is generally a required parameter for all Advertiser API requests. The specified account must be associated with the authenticated user.
Replaces the form’s fields wholesale. Must not be empty. See fields entries.
Replaces the privacy policy wholesale. See privacy_policy.
Replaces the introduction wholesale. See introduction.
Replaces the final page wholesale. See final_page.
PUT https://ads-api.x.com/12/accounts/18ce54d4x5t/lead_forms/3f2b8c1a-8f4e-4a0b-9df2-0123456789ab
GET accounts/:account_id/lead_forms
List the account’s lead forms, newest first. Resource URLhttps://ads-api.x.com/12/accounts/:account_id/lead_forms
The identifier for the leveraged account. Appears within the resource’s path and is generally a required parameter for all Advertiser API requests. The specified account must be associated with the authenticated user.
Opaque pagination cursor from a previous response. Pass
next_cursor back as cursor to fetch the next page; it is null on the last page. See Pagination.GET https://ads-api.x.com/12/accounts/18ce54d4x5t/lead_forms?count=2
Example Response
Example response
GET accounts/:account_id/lead_forms/:lead_form_id
Retrieve a single lead form associated with the current account. Resource URLhttps://ads-api.x.com/12/accounts/:account_id/lead_forms/:lead_form_id
The identifier for the leveraged account. Appears within the resource’s path and is generally a required parameter for all Advertiser API requests. The specified account must be associated with the authenticated user.
Pass
true to retrieve an archived form. Archived forms return not-found when this is false.GET https://ads-api.x.com/12/accounts/18ce54d4x5t/lead_forms/3f2b8c1a-8f4e-4a0b-9df2-0123456789ab
Example Response
Example response
DELETE accounts/:account_id/lead_forms/:lead_form_id
Soft-delete (archive) a lead form. Archived forms stop accepting submissions and can no longer be updated. Resource URLhttps://ads-api.x.com/12/accounts/:account_id/lead_forms/:lead_form_id
The identifier for the leveraged account. Appears within the resource’s path and is generally a required parameter for all Advertiser API requests. The specified account must be associated with the authenticated user.
DELETE https://ads-api.x.com/12/accounts/18ce54d4x5t/lead_forms/3f2b8c1a-8f4e-4a0b-9df2-0123456789ab
Example Response
Example response
Attach a lead form to a card
Use POST accounts/:account_id/cards to create a post card that opens a lead form. Set the destination type toLEAD_FORM and pass the form id.
The LEAD_FORM destination can be used anywhere a destination is accepted, including DETAILS and BUTTON components and buttons in a BUTTON_GROUP component. Invalid lead form ids are rejected with one error per invalid id.
Example Request
POST https://ads-api.x.com/12/accounts/18ce54d4x5t/cards
card_uri and attaching the card to a Post.
Export leads
Leads collected by a form are exported through the ad-export job lifecycle: create an export job, poll its status, download the result, and optionally cancel it. A leads export is an export create withentity_type set to leads.
Leads exports are restricted to account administrators, since exported leads contain personal information.
POST accounts/:account_id/ad-export/api/v1/exports
Create a leads export job. The form must exist, belong to the account, and not be archived; otherwise the request fails with a 404. Resource URLhttps://ads-api.x.com/12/accounts/:account_id/ad-export/api/v1/exports
The identifier for the leveraged account. Appears within the resource’s path and is generally a required parameter for all Advertiser API requests. The specified account must be associated with the authenticated user.
Id of the lead form whose leads to export. The form must exist, belong to the account, and not be archived.
End of the export window as a Unix timestamp in seconds. Exclusive: the window is
[start_epoch, end_epoch), so leads submitted exactly at end_epoch are not included.POST https://ads-api.x.com/12/accounts/18ce54d4x5t/ad-export/api/v1/exports
id. Use that id to poll status, download the file, or cancel the job.
GET accounts/:account_id/ad-export/api/v1/exports/:export_id
Return the job status. Once the job completes, the response includes adownload_url.
Resource URL
https://ads-api.x.com/12/accounts/:account_id/ad-export/api/v1/exports/:export_id
GET accounts/:account_id/ad-export/api/v1/exports/:export_id/download
Download the exported file. Resource URLhttps://ads-api.x.com/12/accounts/:account_id/ad-export/api/v1/exports/:export_id/download
DELETE accounts/:account_id/ad-export/api/v1/exports/:export_id
Cancel the export job. Resource URLhttps://ads-api.x.com/12/accounts/:account_id/ad-export/api/v1/exports/:export_id