Guides
API principles

Rest.li 2.0

Headers, the list and record syntax, URN encoding, finders, batches, partial updates, projections and query tunneling of the Marketing API.

The Marketing API is built on Rest.li, LinkedIn's REST framework, with protocol 2.0. The protocol changes the shape of URLs (lists and records in the query), the methods (a POST can be a create, a partial update or an action) and the responses (the id of a create comes in a header).

Headers of every /rest call

HeaderValue
AuthorizationBearer <token>
LinkedIn-Version202610 (see Versions)
X-Restli-Protocol-Version2.0.0
Content-Typeapplication/json on bodies
X-RestLi-MethodOn partial updates and batches (below)

A call with 2.0 syntax (List(…), (key:value) or an encoded URN in the path) without X-Restli-Protocol-Version: 2.0.0 answers:

json
{ "status": 400, "serviceErrorCode": 100, "message": "Invalid query parameters passed to request" }

Lists, records and encoding

SyntaxExample
Listids=List(347365458,347373377)
Recordsearch=(status:(values:List(ACTIVE,DRAFT)),test:false)
DatedateRange=(start:(year:2026,month:11,day:1),end:(year:2026,month:11,day:30))
URN inside a parameteraccounts=List(urn%3Ali%3AsponsoredAccount%3A521119150)
URN as a key in the path/rest/adAccounts/521119150/creatives/urn%3Ali%3AsponsoredCreative%3A166531097
Compound key/rest/adAccountUsers/(account:urn%3Ali%3AsponsoredAccount%3A521119150,user:urn%3Ali%3Aperson%3AyLp4Ms3J8-)

LinkedIn's rule: values inside parameters are encoded (: → %3A, ( → %28, ) → %29, , → %2C), but the (, ), , and : that structure the list or record are not. A URN used as a key in the path is fully encoded.

Mimicr accepts the query both in the form LinkedIn asks for and fully encoded, because the server re-encodes the query before reading it. So the check for unencoded URNs inside the query only catches what arrives raw; in the path it always applies. Encode URNs as LinkedIn documents: that's what works on the real LinkedIn.

The dotted form of protocol 1.0, which shows up in parts of the docs, is accepted too: search.status.values[0]=ACTIVE, search.test=true, pivot.value=CAMPAIGN, timeGranularity.value=DAILY.

Methods

Rest.li methodHTTPMarkerResponse
GETGET /{resource}/{key}200 with the entity
BATCH_GETGET /{resource}?ids=List(…){"results", "errors", "statuses"}
FINDERGET /{resource}?q={finder}&…{"elements", "paging" or "metadata"}
CREATEPOST /{resource}201, id in x-restli-id
BATCH_CREATEPOST /{resource} with {"elements": […]}X-RestLi-Method: BATCH_CREATE{"elements": [{status, id}]}
PARTIAL_UPDATEPOST /{resource}/{key} with {"patch": …}X-RestLi-Method: PARTIAL_UPDATE204
BATCH_PARTIAL_UPDATEPOST /{resource}?ids=List(…) with {"entities": …}X-RestLi-Method: BATCH_PARTIAL_UPDATE{"results", "errors"}
UPDATEPUT /{resource}/{key}204 (only adAccountUsers and campaignConversions)
BATCH_UPDATEPUT /{resource}?ids=List(…)X-RestLi-Method: BATCH_UPDATE{"results", "errors"}
DELETE, BATCH_DELETEDELETE /{resource}/{key} or ?ids=List(…)204 or {"results", "errors"}
ACTIONPOST /{resource}?action={name}200 or 201

LinkedIn uses POST with X-RestLi-Method: PARTIAL_UPDATE to update; Mimicr also accepts HTTP PATCH with the same body. Without the header, a POST to a key answers 400 "Invalid request: missing X-RestLi-Method header for partial update".

Create

bash
curl -si https://linkedin-ads.mimicr.dev/rest/adAccounts/521119150/adCampaignGroups \
  --header 'Authorization: Bearer <token>' \
  --header 'LinkedIn-Version: 202610' \
  --header 'X-Restli-Protocol-Version: 2.0.0' \
  --header 'Content-Type: application/json' \
  --data '{ "account": "urn:li:sponsoredAccount:521119150", "name": "Leads Q4", "runSchedule": { "start": 1793949746951 }, "status": "ACTIVE" }'
text
HTTP/1.1 201 Created
x-restli-id: 690078541
location: /adAccounts/521119150/adCampaignGroups/690078541
x-restli-protocol-version: 2.0.0
x-li-version: 202610

The body is empty, except for POST /rest/conversions (returns the rule) and ?action=createInline (returns the creative). The id is numeric for accounts, groups, campaigns, forms, rules and subscriptions, and a URN for creatives and posts. Creates aren't idempotent: two identical POSTs create two entities, so search before retrying a create that timed out.

Partial update

bash
curl -si https://linkedin-ads.mimicr.dev/rest/adAccounts/521119150/adCampaigns/347365458 \
  --header 'Authorization: Bearer <token>' \
  --header 'LinkedIn-Version: 202610' \
  --header 'X-Restli-Protocol-Version: 2.0.0' \
  --header 'X-RestLi-Method: PARTIAL_UPDATE' \
  --header 'Content-Type: application/json' \
  --data '{ "patch": { "$set": { "dailyBudget": { "amount": "200.00", "currencyCode": "BRL" } }, "$delete": ["totalBudget"] } }'

$set replaces fields and $delete removes optional fields. A nested patch ({"patch": {"runSchedule": {"$set": {"end": 1799133746951}}}}) changes only the sub-record. The answer is 204 and the entity's version.versionTag goes up by one. Documented exception: the PARTIAL_UPDATE of adAccountUsers answers 200.

Batches

bash
curl -s 'https://linkedin-ads.mimicr.dev/rest/adAccounts/521119150/adCampaigns?ids=List(347365458,347373377)' \
  --request POST \
  --header 'Authorization: Bearer <token>' \
  --header 'LinkedIn-Version: 202610' \
  --header 'X-Restli-Protocol-Version: 2.0.0' \
  --header 'X-RestLi-Method: BATCH_PARTIAL_UPDATE' \
  --header 'Content-Type: application/json' \
  --data '{ "entities": { "347365458": { "patch": { "$set": { "status": "PAUSED" } } }, "347373377": { "patch": { "$set": { "status": "PAUSED" } } } } }'
json
{ "results": { "347365458": { "status": 204 } }, "errors": { "347373377": { "status": 400, "code": "STATUS_CHANGE_NOT_ALLOWED", "message": "…" } } }

A failing key doesn't fail the others; the HTTP status is 200. Every entity of a batch must belong to the same account (MULTIPLE_ACCOUNTS_UNSUPPORTED). In BATCH_CREATE, each element comes back with status 201 and the id, or with the error. The exception is the Conversions API: an event batch is all-or-nothing.

Projections

fields limits the response and is the only way to get the Additional Info Fields (referenceInfo, accountInfo, campaignGroupInfo, associatedEntityInfo, ownerInfo, leadMetadataInfo, form):

bash
curl -s 'https://linkedin-ads.mimicr.dev/rest/adAccounts/521119150?fields=id,name,currency,reference,referenceInfo,servingStatuses' \
  --header 'Authorization: Bearer <token>' --header 'LinkedIn-Version: 202610' --header 'X-Restli-Protocol-Version: 2.0.0'
json
{ "id": 521119150, "name": "Conta Principal", "currency": "BRL", "reference": "urn:li:organization:48720492", "servingStatuses": ["RUNNABLE"], "referenceInfo": { "organization": { "id": 48720492, "vanityName": "mimicr-demo", "localizedName": "Mimicr Demo Ltda" } } }

Legacy decoration (projection=(owner~(…))) answers 400 "Decoration is not supported".

Query tunneling

URLs over the limits (URL 8 KB, query 4 KB, path segment 4 KB) answer 414. To stay under them, send the query in the body:

  • GET: POST with X-HTTP-Method-Override: GET, Content-Type: application/x-www-form-urlencoded and the query in the body.
  • Writes: multipart/mixed, with the query in the first part and the JSON in the second.
bash
curl -s https://linkedin-ads.mimicr.dev/rest/adAccounts/521119150/adCampaigns \
  --request POST \
  --header 'X-HTTP-Method-Override: GET' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --header 'Authorization: Bearer <token>' --header 'LinkedIn-Version: 202610' --header 'X-Restli-Protocol-Version: 2.0.0' \
  --data 'q=search&search=(status:(values:List(ACTIVE)))'

Response headers

Every response carries x-restli-protocol-version: 2.0.0, x-li-version (the version used), x-li-uuid and x-li-fabric. Creates add x-restli-id and location. With the lenientRestli toggle on, Mimicr tolerates missing version, protocol and method headers and unencoded URNs (see Testing in the sandbox).