Guides
Quickstart
Activate the sandbox, get a token, create a group, campaign, form and creative, pass review, receive a lead on the webhook and read the report.
This guide takes a few minutes: you activate the simulator, get a token without going through the consent page, publish a lead generation campaign with a creative, play the reviewer, receive a lead on the webhook and query adAnalytics.
Prerequisites
- A Mimicr organization and a write API key (
mk_…), created in the organization settings, "Chaves de API" tab. - curl, or any HTTP client, and Node 18+ if you want the CLI.
- An
httpsURL that accepts POST, for the webhook of step 7 (a request inspection service works).
1. Activate the LinkedIn Ads sandbox
In the console, open the organization at https://app.mimicr.dev, go to LinkedIn Ads and activate it. Or through the control API:
curl --request POST \ --url https://api.mimicr.dev/v1/linkedin-ads/activate \ --header 'Authorization: Bearer mk_...'
The sandbox starts with a developer app (its own client id and client secret, products Advertising, Lead Sync and Conversions), the organization "Mimicr Demo Ltda" (mimicr-demo) and two ad accounts: "Conta Principal" (BRL, full delivery and reporting) and "Conta de Teste" (USD, test: true). Each account has its "Default Campaign Group". Members are personas: admin (Ana Admin, ACCOUNT_BILLING_ADMIN on both accounts and ADMINISTRATOR of the organization), campaign_manager, creative_manager, viewer and no_accounts. If it is already active, the call answers 409 linkedin_ads_already_active.
2. Read the credentials
curl --url https://api.mimicr.dev/v1/linkedin-ads \ --header 'Authorization: Bearer mk_...'
{
"active": true,
"host": "https://linkedin-ads.mimicr.dev",
"oauth_base_url": "https://linkedin-ads.mimicr.dev",
"api_base_url": "https://linkedin-ads.mimicr.dev",
"latest_version": "202610",
"app": {
"name": "My Org Ads",
"client_id": "9vem0tlt63qrfg",
"client_secret": "<client_secret>",
"redirect_uris": [],
"products": ["ADVERTISING", "LEAD_SYNC", "CONVERSIONS"],
"scopes": ["r_basicprofile", "r_ads", "rw_ads", "r_ads_reporting", "rw_conversions", "r_marketing_leadgen_automation", "r_organization_admin", "w_organization_social"]
},
"organization": { "urn": "urn:li:organization:48720492", "name": "Mimicr Demo Ltda", "vanityName": "mimicr-demo" },
"members": [
{ "id": "yLp4Ms3J8-", "person": "urn:li:person:yLp4Ms3J8-", "persona": "admin", "name": "Ana Admin", "org_role": "ADMINISTRATOR" }
],
"ad_accounts": [
{ "id": "521119150", "urn": "urn:li:sponsoredAccount:521119150", "name": "Conta Principal", "currency": "BRL", "status": "ACTIVE", "test": false },
{ "id": "521134988", "urn": "urn:li:sponsoredAccount:521134988", "name": "Conta de Teste", "currency": "USD", "status": "ACTIVE", "test": true }
]
}The response is trimmed (it also has versions, toggles, chaos, quotas and the clock) and the ids are examples; use your sandbox's. With the CLI: npx mimicr login mk_... once, then npx mimicr status linkedin-ads.
3. Get a token
In the real integration the member goes through the authorization page and your server exchanges the code at /oauth/v2/accessToken (see Authentication). To test quickly, Mimicr issues the tokens of the admin persona with every scope of the app:
curl --request POST \ --url https://api.mimicr.dev/v1/linkedin-ads/token \ --header 'Authorization: Bearer mk_...'
{
"access_token": "<token>",
"expires_in": 5184000,
"refresh_token": "<refresh_token>",
"refresh_token_expires_in": 31536000,
"scope": "r_basicprofile r_ads rw_ads r_ads_reporting rw_conversions r_marketing_leadgen_automation r_organization_admin w_organization_social",
"member": "yLp4Ms3J8-",
"person": "urn:li:person:yLp4Ms3J8-"
}The access token lasts 60 days and the refresh token 365. Every /rest call carries three headers: the token, the version and the Rest.li protocol.
4. Make the first call
B=https://linkedin-ads.mimicr.dev/rest
H=(--header 'Authorization: Bearer <token>' --header 'LinkedIn-Version: 202610' --header 'X-Restli-Protocol-Version: 2.0.0')
curl -s "$B/adAccountUsers?q=authenticatedUser" "${H[@]}"{
"elements": [
{ "account": "urn:li:sponsoredAccount:521119150", "user": "urn:li:person:yLp4Ms3J8-", "role": "ACCOUNT_BILLING_ADMIN", "version": { "versionTag": "1" } },
{ "account": "urn:li:sponsoredAccount:521134988", "user": "urn:li:person:yLp4Ms3J8-", "role": "ACCOUNT_BILLING_ADMIN", "version": { "versionTag": "1" } }
],
"paging": { "start": 0, "count": 10, "links": [], "total": 2 }
}Without LinkedIn-Version the answer is 400 VERSION_MISSING; see Versions and Rest.li 2.0.
5. Create a group, campaign, form and creative
Use the Conta Principal (521119150). Creates answer 201 with the id in the x-restli-id header and an empty body, hence the -i:
ACC=521119150
curl -si "$B/adAccounts/$ACC/adCampaignGroups" "${H[@]}" -H 'Content-Type: application/json' -d '{
"account": "urn:li:sponsoredAccount:521119150", "name": "Leads Q4",
"runSchedule": { "start": 1793949746951 }, "status": "ACTIVE" }'
# x-restli-id: 690078541
curl -si "$B/adAccounts/$ACC/adCampaigns" "${H[@]}" -H 'Content-Type: application/json' -d '{
"account": "urn:li:sponsoredAccount:521119150",
"campaignGroup": "urn:li:sponsoredCampaignGroup:690078541",
"name": "Gás para empresas", "type": "SPONSORED_UPDATES", "objectiveType": "LEAD_GENERATION",
"costType": "CPM", "optimizationTargetType": "MAX_LEAD",
"unitCost": { "amount": "45.00", "currencyCode": "BRL" },
"dailyBudget": { "amount": "150.00", "currencyCode": "BRL" },
"locale": { "country": "BR", "language": "pt" },
"targetingCriteria": { "include": { "and": [
{ "or": { "urn:li:adTargetingFacet:locations": ["urn:li:geo:106057199"] } },
{ "or": { "urn:li:adTargetingFacet:interfaceLocales": ["urn:li:locale:pt_BR"] } } ] } },
"offsiteDeliveryEnabled": false, "politicalIntent": "NOT_POLITICAL", "status": "DRAFT" }'
# x-restli-id: 347365458runSchedule.start is epoch milliseconds and can't be more than 5 minutes in the past: use the current time. Money values are strings in major units ("150.00"), never cents. Now the lead form, published, and the creative with a dark post created in the same call:
curl -si "$B/leadForms" "${H[@]}" -H 'Content-Type: application/json' -d '{
"owner": { "sponsoredAccount": "urn:li:sponsoredAccount:521119150" },
"name": "Orçamento de gás", "creationLocale": { "country": "BR", "language": "pt" },
"content": {
"headline": { "localized": { "pt_BR": "Peça um orçamento" } },
"questions": [
{ "name": "first_name", "question": { "localized": { "pt_BR": "Nome" } }, "predefinedField": "FIRST_NAME", "questionDetails": { "textQuestionDetails": { "maxResponseLength": 300 } } },
{ "name": "email", "question": { "localized": { "pt_BR": "E-mail" } }, "predefinedField": "EMAIL", "questionDetails": { "textQuestionDetails": { "maxResponseLength": 300 } } } ],
"legalInfo": { "privacyPolicyUrl": "https://example.com.br/privacidade" } },
"state": "PUBLISHED" }'
# x-restli-id: 6700000002689218625
curl -s "$B/adAccounts/$ACC/creatives?action=createInline" "${H[@]}" -H 'Content-Type: application/json' -d '{
"creative": {
"campaign": "urn:li:sponsoredCampaign:347365458", "intendedStatus": "ACTIVE", "name": "Orçamento grátis",
"leadgenCallToAction": { "destination": "urn:li:leadGenForm:6700000002689218625", "label": "SIGN_UP" },
"inlineContent": { "post": {
"author": "urn:li:organization:48720492", "commentary": "Gás com entrega em 24 h para a sua empresa",
"visibility": "PUBLIC", "lifecycleState": "PUBLISHED",
"content": { "article": { "source": "https://example.com.br/b2b", "title": "Gás B2B" } } } } } }'
# "id": "urn:li:sponsoredCreative:166531097", "review": {"status": "PENDING"},
# "servingHoldReasons": ["UNDER_REVIEW", "FORM_HOLD", "CAMPAIGN_STOPPED"]Every field is detailed in Groups and campaigns and Creatives and review.
6. Pass review and activate
The creative and the form are reviewed on their own 10 sandbox minutes later. To skip the wait, play the reviewer, then activate the campaign:
npx mimicr action linkedin-ads form.approve form=6700000002689218625
npx mimicr action linkedin-ads creative.approve creative=urn:li:sponsoredCreative:166531097
curl -si "$B/adAccounts/$ACC/adCampaigns/347365458" "${H[@]}" \
-H 'X-RestLi-Method: PARTIAL_UPDATE' -H 'Content-Type: application/json' \
-d '{ "patch": { "$set": { "status": "ACTIVE" } } }'
# HTTP/1.1 204Now the creative shows review.status: APPROVED and isServing: true, and the campaign shows servingStatuses: ["RUNNABLE"]. The creative URN goes encoded in the path: creatives/urn%3Ali%3AsponsoredCreative%3A166531097.
7. Receive a lead on the webhook
LinkedIn only creates the subscription if your URL answers the HMAC challenge (see Lead Sync and webhook). For this test, turn that requirement off and subscribe to the account's leads:
npx mimicr put /v1/linkedin-ads/homolog requireWebhookValidation=false
curl -si "$B/leadNotifications" "${H[@]}" -H 'Content-Type: application/json' -d '{
"webhook": "https://your-service.example.com/li/leads?secret=abc",
"owner": { "sponsoredAccount": "urn:li:sponsoredAccount:521119150" },
"leadType": "SPONSORED" }'
# x-restli-id: 718690Now a member fills the ad's form, and you wait for the delivery:
npx mimicr action linkedin-ads lead.submit creative=urn:li:sponsoredCreative:166531097 npx mimicr wait linkedin-ads delivery action=CREATED status=delivered
The POST arrives with X-LI-Signature and a LEAD_ACTION body with the lead URN. Read the lead with GET /rest/leadFormResponses/{id} and check the signature with Verify the signature.
8. Read the report
Delivery happens hour by hour on the sandbox clock. To get numbers now, generate one hour of traffic and query:
npx mimicr action linkedin-ads traffic.deliver campaign=347365458
curl -s "$B/adAnalytics?q=analytics&pivot=CAMPAIGN&timeGranularity=DAILY&dateRange=(start:(year:2026,month:11,day:1))&accounts=List(urn%3Ali%3AsponsoredAccount%3A521119150)&fields=dateRange,pivotValues,impressions,clicks,costInLocalCurrency,oneClickLeads" "${H[@]}"{
"elements": [
{
"dateRange": { "start": { "year": 2026, "month": 11, "day": 6 }, "end": { "year": 2026, "month": 11, "day": 6 } },
"pivotValues": ["urn:li:sponsoredCampaign:347365458"],
"impressions": 1951, "clicks": 19, "costInLocalCurrency": "167.14093", "oneClickLeads": 1
}
],
"paging": { "start": 0, "count": 10, "links": [] }
}The numbers vary: they add up the delivery model, the manual hour of traffic.deliver (by default 1,000 impressions, 10 clicks and 50.00 of spend) and the lead of step 7. See adAnalytics.
Next steps
- Testing in the sandbox for the rejection and failure triggers and the homologation toggles.
- Conversions API to send the CRM sale back with the click's
li_fat_id. - Sandbox control for every action, waiting and the clock.