openapi: 3.1.0
info:
title: LinkedIn Compliance Events Access Control Use Cases > Sponsored API
description: LinkedIn provides Compliance API Guides for monitoring, archiving, and management of communications for enterprises in regulated industries. The Compliance Events API allows applications to archive all LinkedIn activities from the past 30 days of a regulated, authenticated member.
version: 1.0.0
contact:
name: LinkedIn API Support
url: https://docs.microsoft.com/en-us/linkedin/compliance/
servers:
- url: https://api.linkedin.com
description: LinkedIn Production API Server
security:
- OAuth2Auth:
- r_compliance
tags:
- name: Use Cases > Sponsored
description: 'In order to support collecting leads for sponsored use cases, a partner app needs to build a UX where a user is able to select the sponsored accounts and forms to collect leads for.
###### Step 1: Obtain user authorization to access their leads
###### Step 2: Get the user''s sponsored accounts
###### Step 3: Ask the user to select the sponsored account(s) whose leads they are interested in syncing
###### Step 4: Validate the user''s organization role tied to the chosen sponsored account
###### Step 5: Retrieve forms for the user''s selected sponsored account
###### Step 6: Ask the user to select and map fields to the target destination (e.g. a CRM)
###### Step 7: Allow the user to do a one time pull of all form responses looking back up to 365 days to grab any missed leads
###### Step 8: \[PULL\] Schedule periodic form response pulls to collect leads
###### Step 8: \[PUSH\] Allow the user to subscribe for lead notification webhooks
###### Step 9: \[PUSH\] Fetch full lead data after a webhook notification is received'
paths:
/organizationAcls:
get:
tags:
- Use Cases > Sponsored
summary: LinkedIn 4. Validate the User's Organization Role
description: "View the [Organization Access Control](https://docs.microsoft.com/linkedin/marketing/integrations/community-management/organizations/organization-access-control-by-role?tabs=http#organization-roles) documentation.\n\nTake note of the organization (company page) from the previous request (`referenceInfo.organization.id`). A member must have access to not only the Sponsored Account (step 2) but also have one of the roles mentioned in our [permissions](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/lead-sync/leadsync?tabs=http#permissions) table for the associated company page to successfully sync leads.\n\nIf the user's role is not one of the approved roles for pulling leads, or the ad account does not have a company page associated to it (empty `referenceInfo` object in previous request) you should display a helpful message to the user guiding them on next steps.\n\nBelow are two resources to better understand Page Admin vs Paid Media Admin:\n\n- [Permissions for Lead Gen Forms](https://www.linkedin.com/help/lms/answer/a421620/permissions-for-lead-gen-forms?lang=en)\n \n- [LinkedIn Page Admiin Roles - Overview](https://www.linkedin.com/help/lms/answer/4783)"
parameters:
- name: X-Restli-Protocol-Version
in: header
schema:
type: string
example: 2.0.0
- name: LinkedIn-Version
in: header
schema:
type: string
example: '{{insert_version}}'
- name: q
in: query
schema:
type: string
example: roleAssignee
- name: state
in: query
schema:
type: string
example: APPROVED
responses:
'200':
description: OK
headers:
Content-Type:
schema:
type: string
example: application/json
Date:
schema:
type: string
example: Wed, 03 May 2023 00:02:38 GMT
Server:
schema:
type: string
example: Play
X-RestLi-Protocol-Version:
schema:
type: string
example: 2.0.0
X-Li-Fabric:
schema:
type: string
example: prod-lor1
Transfer-Encoding:
schema:
type: string
example: chunked
Connection:
schema:
type: string
example: keep-alive
X-Li-Source-Fabric:
schema:
type: string
example: prod-lva1
X-Li-Pop:
schema:
type: string
example: prod-lva1-x
X-LI-Proto:
schema:
type: string
example: http/1.1
X-LI-UUID:
schema:
type: string
example: AAX6vsYdZ5H4tUsf+cOOmw==
Set-Cookie:
schema:
type: string
example: lidc="b=OB05:s=O:r=O:a=O:p=O:g=5005:u=1258:x=1:i=1683072158:t=1683155872:v=2:sig=AQGPZ1ePhNBON7apSXcQgZo360QqxGG0"
X-LI-Route-Key:
schema:
type: string
example: '"b=OB05:s=O:r=O:a=O:p=O:g=5005:u=1258:x=1:i=1683072158:t=1683155872:v=2:sig=AQGPZ1ePhNBON7apSXcQgZo360QqxGG0"'
content:
application/json:
schema:
$ref: '#/components/schemas/ValidateTheUsersOrganizationResponse200'
examples:
default:
$ref: '#/components/examples/ValidateTheUsersOrganizationResponse200Example'
operationId: getValidateTheUsersOrganization
x-microcks-operation:
dispatcher: FALLBACK
dispatcherRules: '{}'
delay: 0
/leadForms:
get:
tags:
- Use Cases > Sponsored
summary: LinkedIn 5. Get Forms for the Chosen Sponsored Account
description: 'At this point, the user has picked the sponsored account they are trying to collect leads for and you have validated they have proper access to the ad account and associated company page. This step will retrieve the form(s) associated with the selected sponsored account.
---
**6\. Map Lead Gen Form fields to destination fields**
Using the API response data from the previous step, your application should ask the user to map questions, consents, and hidden fields to the appropriate fields in the destination system (e.g. a CRM). All questions, consents, and hidden fields from the form should be mappable. `predefinedField` fields may be mapped automatically for the user, but all others will require the user to map them manually. Optionally, allow the user to map the ad account id, ad account name, campaign id, campaign name, creative id, creative name, form id, and form name (this additional metadata can be pulled back via the `leadFormResponses` endpoint in the next step). This additional metadata helps your customers with lead attribution.
**Quick tip:** When it comes to mapping the `predefinedField` fields that are auto populated from the member’s profile, it''s important to understand that the localized language of the form could be a language other than English. Due to this, you should use the `predefinedField` field so the user doesn''t have to map the same field in different form languages separately. For custom questions you will need to use the `question` field as there is no predefinedField for custom questions.
| **Field** | **Language Information** |
| --- | --- |
| name | This value will be translated to the localized language of the user who created the form (which could be different than the localized language of the form) |
| predefinedField | ENUM for the pre-populated field |
| question | This value will be translated to the localized form language |'
parameters:
- name: LinkedIn-Version
in: header
schema:
type: string
example: '{{insert_version}}'
- name: X-Restli-Protocol-Version
in: header
schema:
type: string
example: 2.0.0
- name: q
in: query
schema:
type: string
example: owner
- name: owner
in: query
schema:
type: string
example: (sponsoredAccount:urn%3Ali%3AsponsoredAccount%3A{{sponsoredaccount_id}})
- name: count
in: query
schema:
type: integer
example: '10'
- name: start
in: query
schema:
type: integer
example: '0'
responses:
'200':
description: OK
headers:
Content-Type:
schema:
type: string
example: application/json
X-RestLi-Protocol-Version:
schema:
type: string
example: 2.0.0
Date:
schema:
type: string
example: Sat, 02 Sep 2023 16:28:52 GMT
Transfer-Encoding:
schema:
type: string
example: chunked
Connection:
schema:
type: string
example: keep-alive
X-Li-Fabric:
schema:
type: string
example: prod-lor1
X-Li-Pop:
schema:
type: string
example: prod-lor1-x
X-LI-Proto:
schema:
type: string
example: http/1.1
X-LI-UUID:
schema:
type: string
example: AAYEYsXLJrWbIXOYZ3541w==
Set-Cookie:
schema:
type: string
example: lidc="b=OB05:s=O:r=O:a=O:p=O:g=6969:u=1367:x=1:i=1693672132:t=1693676563:v=2:sig=AQHJKR3ozyeM8s9oUsu7Qq-fch5CveYt"
X-LI-Route-Key:
schema:
type: string
example: '"b=OB05:s=O:r=O:a=O:p=O:g=6969:u=1367:x=1:i=1693672132:t=1693676563:v=2:sig=AQHJKR3ozyeM8s9oUsu7Qq-fch5CveYt"'
content:
application/json:
schema:
$ref: '#/components/schemas/GetFormsForTheResponse200'
examples:
default:
$ref: '#/components/examples/GetFormsForTheResponse200Example'
operationId: getGetFormsForThe
x-microcks-operation:
dispatcher: FALLBACK
dispatcherRules: '{}'
delay: 0
/leadFormResponses:
get:
tags:
- Use Cases > Sponsored
summary: LinkedIn 8. Schedule Periodic Form Response (lead) Pulls
description: 'This example pulls back all form responses (leads) for the chosen sponsored account. It also uses [field projection](https://learn.microsoft.com/en-us/linkedin/shared/api-guide/concepts/projections?context=linkedin/marketing/context) to pull back specific fields in the response and the `submittedAtTimeRange` field to pull back leads up to 365 days in the past.
Currently the only sponsored leadType is `SPONSORED`
LinkedIn will store form response (lead) data for up to 365 days. It is a best practice to allow the user to do a one time pull upon integration setup to ensure no leads are missed.
Refer to [Lead Form Responses](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/lead-sync/leadsync?tabs=http#get-lead-sync-form-responses) documentation for more information.'
parameters:
- name: LinkedIn-Version
in: header
schema:
type: string
example: '{{insert_version}}'
- name: X-Restli-Protocol-Version
in: header
schema:
type: string
example: 2.0.0
- name: q
in: query
schema:
type: string
example: owner
- name: owner
in: query
schema:
type: string
example: (sponsoredAccount:urn%3Ali%3AsponsoredAccount%3A{{sponsoredaccount_id}})
- name: leadType
in: query
schema:
type: string
example: (leadType:{{leadtype_sponsored}})
- name: limitedToTestLeads
in: query
schema:
type: boolean
example: 'false'
- name: submittedAtTimeRange
in: query
schema:
type: string
example: (start:{{timerange_start}},end:{{timerange_end}})
- name: fields
in: query
schema:
type: string
example: ownerInfo,associatedEntityInfo,leadMetadataInfo,owner,leadType,versionedLeadGenFormUrn,id,submittedAt,testLead,formResponse,form:(hiddenFields,creationLocale,name,id,content)
- name: count
in: query
schema:
type: integer
example: '10'
- name: start
in: query
schema:
type: integer
example: '0'
responses:
'200':
description: Successful response
content:
application/json: {}
operationId: getSchedulePeriodicFormResponse
x-microcks-operation:
dispatcher: FALLBACK
dispatcherRules: '{}'
delay: 0
/leadNotifications:
post:
tags:
- Use Cases > Sponsored
summary: LinkedIn 8. Subscribe for Lead Notification Webhooks
description: '[Register a lead notification webhook](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/lead-sync/leadsync?tabs=http#lead-notification-subscriptions) to receive notifications for new leads. Lead notifications can also be subscribed at a more granular level - see the linked documentation.
This example registers the webhook url, [https://www.example.com](https://www.example.com/), at the Ad Account level (sponsoredAccount). For any new lead submitted for campaigns that live within this Ad Account, a webhook notification will be sent.
**Listen for lead notifications**
As leads flow into the user''s ad account, LinkedIn will send your webhook endpoint a notification for each lead. The notification body will contain content as laid out in our documentation [here.](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/lead-sync/leadsync?tabs=http#example-payload-for-when-a-member-registers-for-an-event)'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SubscribeForLeadNotificationRequest'
parameters:
- name: LinkedIn-Version
in: header
schema:
type: string
example: '{{insert_version}}'
- name: X-Restli-Protocol-Version
in: header
schema:
type: string
example: 2.0.0
responses:
'200':
description: Successful response
content:
application/json: {}
operationId: postSubscribeForLeadNotification
x-microcks-operation:
dispatcher: FALLBACK
dispatcherRules: '{}'
delay: 0
/leadFormResponses/{lead_id}:
get:
tags:
- Use Cases > Sponsored
summary: LinkedIn 9. Fetch Full Lead Data After a Lead Notification is Received
description: '[Responses can be fetched](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/lead-sync/leadsync?tabs=http#get-lead-sync-form-responses) for a single form response, multiple form responses, or at the form or Ad Account level.
When a lead notification event is received, the form response id exists in the lead notification [content](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/lead-sync/leadsync?tabs=http#example-payload-for-when-a-member-registers-for-an-event).
This example pulls back data for a single form response (lead) by ID and uses field projection to pull back specific fields in the request response.'
parameters:
- name: LinkedIn-Version
in: header
schema:
type: string
example: '{{insert_version}}'
- name: X-Restli-Protocol-Version
in: header
schema:
type: string
example: 2.0.0
- name: null
in: query
schema:
type: string
- name: fields
in: query
schema:
type: string
example: ownerInfo,associatedEntityInfo,leadMetadataInfo,owner,leadType,versionedLeadGenFormUrn,id,submittedAt,testLead,formResponse,form:(hiddenFields,creationLocale,name,id,content)
- name: lead_id
in: path
schema:
type: string
required: true
example: '123456'
responses:
'200':
description: OK
headers:
Content-Type:
schema:
type: string
example: application/json
X-RestLi-Protocol-Version:
schema:
type: string
example: 2.0.0
Date:
schema:
type: string
example: Sun, 03 Sep 2023 00:56:45 GMT
Transfer-Encoding:
schema:
type: string
example: chunked
Connection:
schema:
type: string
example: keep-alive
X-Li-Fabric:
schema:
type: string
example: prod-lor1
X-Li-Pop:
schema:
type: string
example: prod-lor1-x
X-LI-Proto:
schema:
type: string
example: http/1.1
X-LI-UUID:
schema:
type: string
example: AAYEad4i/cczw/xzb6uK4Q==
Set-Cookie:
schema:
type: string
example: lidc="b=OB05:s=O:r=O:a=O:p=O:g=6969:u=1367:x=1:i=1693702605:t=1693784804:v=2:sig=AQF2lXKW3JuyKC8eiTiIfScGy1CoyI0Q"
X-LI-Route-Key:
schema:
type: string
example: '"b=OB05:s=O:r=O:a=O:p=O:g=6969:u=1367:x=1:i=1693702605:t=1693784804:v=2:sig=AQF2lXKW3JuyKC8eiTiIfScGy1CoyI0Q"'
content:
application/json:
schema:
$ref: '#/components/schemas/FetchFullLeadDataResponse200'
examples:
default:
$ref: '#/components/examples/FetchFullLeadDataResponse200Example'
operationId: getFetchFullLeadData
x-microcks-operation:
dispatcher: FALLBACK
dispatcherRules: '{}'
delay: 0
/leadnotifications/<webhook id>:
delete:
tags:
- Use Cases > Sponsored
summary: LinkedIn [PUSH] Delete a Registered Webhook by Id
description: '[Delete a lead notification subsription](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/lead-sync/leadsync?tabs=http#delete-lead-notification-url)
When an integration is deleted, the associated webhooks should also be deleted to ensure that lead notifications are not unnecessarily being sent.'
parameters:
- name: LinkedIn-Version
in: header
schema:
type: string
example: '{{insert_version}}'
- name: X-Restli-Protocol-Version
in: header
schema:
type: string
example: 2.0.0
responses:
'200':
description: Successful response
content:
application/json: {}
operationId: deletePushDeleteARegistered
x-microcks-operation:
dispatcher: FALLBACK
dispatcherRules: '{}'
delay: 0
/adAccounts:
get:
tags:
- Use Cases > Sponsored
summary: LinkedIn 2. Get the User's Sponsored Accounts (ad Accounts)
description: 'View [Search for Accounts](https://docs.microsoft.com/en-us/linkedin/marketing/integrations/ads/account-structure/create-and-manage-accounts?tabs=http#search-for-accounts) documentation for more information.
This API call pulls back Ad Accounts that the member has access to where the status = ACTIVE and test = false (NOT a test Ad Account).
Learn more about Test Ad Accounts [here](https://docs.microsoft.com/en-us/linkedin/marketing/integrations/ads/account-structure/create-and-manage-accounts?tabs=http#working-with-test-ad-accounts).
For testing purposes, if you wish to use this example api to pull back a Test Ad Account, simply remove `test:false` from the search parameter.
---
**3\. Allow the user to select an Ad Account**'
parameters:
- name: X-Restli-Protocol-Version
in: header
schema:
type: string
example: 2.0.0
- name: LinkedIn-Version
in: header
schema:
type: string
example: '{{insert_version}}'
- name: q
in: query
schema:
type: string
example: search
- name: search
in: query
schema:
type: string
example: (status:(values:List(ACTIVE)),test:false)
- name: fields
in: query
schema:
type: string
example: id,name,test,referenceInfo
- name: count
in: query
schema:
type: integer
example: '10'
- name: start
in: query
schema:
type: integer
example: '0'
responses:
'200':
description: OK
headers:
Content-Type:
schema:
type: string
example: application/json
X-RestLi-Protocol-Version:
schema:
type: string
example: 2.0.0
Date:
schema:
type: string
example: Sat, 02 Sep 2023 23:46:44 GMT
Transfer-Encoding:
schema:
type: string
example: chunked
Connection:
schema:
type: string
example: keep-alive
X-Li-Fabric:
schema:
type: string
example: prod-lor1
X-Li-Pop:
schema:
type: string
example: prod-lor1-x
X-LI-Proto:
schema:
type: string
example: http/1.1
X-LI-UUID:
schema:
type: string
example: AAYEaOPCVPCH8cztJX/9lw==
Set-Cookie:
schema:
type: string
example: lidc="b=OB05:s=O:r=O:a=O:p=O:g=6969:u=1367:x=1:i=1693698404:t=1693784804:v=2:sig=AQHu1AiyYtvva0ZoA063AajzXMZkjXiD"
X-LI-Route-Key:
schema:
type: string
example: '"b=OB05:s=O:r=O:a=O:p=O:g=6969:u=1367:x=1:i=1693698404:t=1693784804:v=2:sig=AQHu1AiyYtvva0ZoA063AajzXMZkjXiD"'
content:
application/json:
schema:
$ref: '#/components/schemas/GetTheUsersSponsoredResponse200'
examples:
default:
$ref: '#/components/examples/GetTheUsersSponsoredResponse200Example'
operationId: getGetTheUsersSponsored
x-microcks-operation:
dispatcher: FALLBACK
dispatcherRules: '{}'
delay: 0
components:
schemas:
FetchFullLeadDataResponse200:
type: object
properties:
owner:
type: object
properties:
sponsoredAccount:
type: string
submitter:
type: string
example: example_value
leadType:
type: string
example: example_value
leadMetadata:
type: object
properties:
sponsoredLeadMetadata:
type: object
properties:
campaign:
type: string
versionedLeadGenFormUrn:
type: string
example: urn:li:organization:123456
id:
type: string
example: '123456'
submittedAt:
type: integer
example: 42
testLead:
type: boolean
example: true
associatedEntity:
type: object
properties:
associatedCreative:
type: string
formResponse:
type: object
properties:
consentResponses:
type: array
items:
type: object
properties:
accepted:
type: boolean
consentId:
type: integer
answers:
type: array
items:
type: object
properties:
answerDetails:
type: object
properties:
textQuestionAnswer:
type: object
properties:
answer:
type: string
questionId:
type: integer
SubscribeForLeadNotificationRequest:
type: object
example:
webhook: https://www.example.com
owner:
sponsoredAccount: urn:li:sponsoredAccount:{{sponsoredaccount_id}}
leadType: '{{leadtype_sponsored}}'
ValidateTheUsersOrganizationResponse200:
type: object
properties:
paging:
type: object
properties:
start:
type: integer
count:
type: integer
links:
type: array
items: {}
elements:
type: array
items:
type: object
properties:
roleAssignee:
type: string
state:
type: string
lastModified:
type: object
properties:
actor:
type: string
impersonator:
type: string
time:
type: integer
role:
type: string
created:
type: object
properties:
actor:
type: string
impersonator:
type: string
time:
type: integer
organization:
type: string
GetFormsForTheResponse200:
type: object
properties:
paging:
type: object
properties:
start:
type: integer
count:
type: integer
links:
type: array
items: {}
total:
type: integer
elements:
type: array
items:
type: object
properties:
reviewInfo:
type: object
properties:
rejectionReasons:
type: array
items: {}
lastUpdated:
type: integer
reviewStatus:
type: string
owner:
type: object
properties:
sponsoredAccount:
type: string
hiddenFields:
type: array
items: {}
versionId:
type: integer
created:
type: integer
creationLocale:
type: object
properties:
country:
type: string
language:
type: string
name:
type: string
id:
type: integer
lastModified:
type: integer
state:
type: string
content:
type: object
properties:
questions:
type: array
items:
type: object
properties:
questionId:
type: integer
question:
type: object
properties:
localized:
type: object
properties:
sv_SE:
type: string
responseEditable:
type: boolean
name:
type: string
questionDetails:
type: object
properties:
textQuestionDetails:
type: object
properties:
maxResponseLength:
type: integer
predefinedField:
type: string
responseRequired:
type: boolean
description:
type: object
properties:
localized:
type: object
properties:
sv_SE:
type: string
postSubmissionInfo:
type: object
properties:
message:
type: object
properties:
localized:
type: object
properties:
sv_SE:
type: string
callToAction:
type: object
properties:
callToActionTarget:
type: object
properties:
landingPageUrl:
type: string
callToActionLabel:
type: string
legalInfo:
type: object
properties:
consents:
type: array
items: {}
legalInfoId:
type: integer
privacyPolicyUrl:
type: string
legalDisclaimer:
type: object
properties:
localized:
type: object
properties:
sv_SE:
type: string
headline:
type: object
properties:
localized:
type: object
properties:
sv_SE:
type: string
GetTheUsersSponsoredResponse200:
type: object
properties:
paging:
type: object
properties:
start:
type: integer
count:
type: integer
links:
type: array
items: {}
total:
type: integer
elements:
type: array
items:
type: object
properties:
name:
type: string
id:
type: integer
test:
type: boolean
referenceInfo:
type: object
properties:
organization:
type: object
properties:
name:
type: object
properties:
localized:
type: object
properties:
en_US:
type: string
preferredLocale:
type: objec
# --- truncated at 32 KB (52 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/linkedin/refs/heads/main/openapi/linkedin-use-cases-sponsored-api-openapi.yml