SCALIX help

← All tools

lads_remove_segment_users

LinkedIn Ads write high risk

Part of the LinkedIn Audience Agent.

What it does

Remove hashed user identifiers from a USER-type DMP segment. Removal uses the SAME streaming endpoint as add: POST /rest/dmpSegments/{id}/users with the HEADER X-RestLi-Method: BATCH_CREATE and body {elements:[{action:'REMOVE', userIds:[{idType, idValue}]}]} — there is NO BATCH_DELETE / delete-by-ids variant for segment users; only the action flag differs from add. Up to 5000 per batch. Preview->approve->execute->log: show which identifiers/count will be removed and why (e.g. opt-out, suppression), get approval, then submit the REMOVE elements. Returns a per-element batch response with per-row status; surface partial failures. Use to honor opt-outs/erasure requests and keep the audience compliant. Subject to the same 600 req/member/minute limit on /users; identifiers MUST be hashed identically to upload (lowercase+trim then SHA-256/SHA-512 HEX) to match, and idType is restricted to SHA256_EMAIL, SHA512_EMAIL, or GOOGLE_AID. Batch cap: at most 5,000 rows per call (rejected pre-API above that). LinkedIn returns PER-ELEMENT statuses — a success envelope does not mean every row landed; failed rows are surfaced as warnings referencing their batchIndex. Without rw_dmp_segments, which Scalix requests only once LinkedIn approves its Audiences program (SCALIX_LINKEDIN_EXTRA_SCOPES), the call is refused at preview (access_gated), after the arguments are checked. Two-phase (parity with Google, ADR-028/029): the first call (no preview_id) reads the segment from LinkedIn (a missing segment, one in an ad account the user has not enabled, or a COMPANY segment is refused), builds the request locally and returns a preview_id — nothing is changed on LinkedIn; re-call with that preview_id and identical arguments to COMMIT (single-use, 30-min; a changed/forged/replayed token fails closed).

When to use it

Use to honor a member opt-out, suppression, or data-deletion request, or to prune a stale audience. Confirm the identifiers and reason, then remove via action:'REMOVE'. Do NOT remove members ad hoc without an audit reason.

Inputs

NameTypeRequiredDescription
segment_idstringyesNumeric USER-type DMP segment id, or its urn:li:dmpSegment URN (read as the id). At preview the segment is read: it must be a USER segment in an ad account the user has enabled.
usersarrayyesUsers to remove (max 5000 per batch), in the forms lads_add_segment_users takes (a hashed id of id_type, an {idType, idValue}, or {userIds, firstName?, lastName?, ...}); each becomes one element with action REMOVE. They must match the hashing used at upload (SHA-256/SHA-512 HEX of lowercased/trimmed email). idType restricted to SHA256_EMAIL | SHA512_EMAIL | GOOGLE_AID; the same checks as lads_add_segment_users run at preview.
reasonstringnoAudit reason (e.g. 'member opt-out', 'erasure request'). Logged, not sent to LinkedIn; an email address in it is logged as [email removed].
id_typestringnoDefault identifier type for users given as bare ids: SHA256_EMAIL (default) | SHA512_EMAIL | GOOGLE_AID; any other value is refused at preview.
preview_idstringnoOmit it to preview: nothing is applied, and the call returns a preview_id bound to this exact request. Pass it only after the user approves that preview in a later message, with the same arguments (leave out validate_only, and add any confirmation flag the preview names). Single-use, expires in 30 minutes; changed arguments need a fresh preview.

Safeguards

A change in two steps. The first call previews and changes nothing; Claude shows you the preview and applies it only after you approve, within 30 minutes and with the same arguments. Every applied change goes to the audit log. How changes are approved.

Policy

Honoring opt-out/erasure: removing a member on request is mandatory; identifiers must be hashed identically to upload (lowercase+trim then SHA-256/SHA-512 HEX) to match. Operate only on segments under the bearer's scoped account.

Reminder

Process opt-outs/deletions promptly; never log raw PII; the same hashing normalization must be used to match removals.

Errors

Error classMeansWhat to doRetry
PARTIAL_FAILURESome identifiers failed to remove (per-row status) — e.g. not present in the segment.Return per-row results; identifiers absent from the segment are effectively removed — treat them as success-equivalent.no
INVALID_ARGUMENTBad payload, hashing mismatch, missing action:'REMOVE', idType outside {SHA256_EMAIL, SHA512_EMAIL, GOOGLE_AID}, or >5000 ids (400) — surface message.Ensure each element has action:'REMOVE' and identifiers hashed exactly as on upload with an allowed idType, chunk to <=5000; fix and retry only failed rows.no
PERMISSION_DENIEDNo write access / missing rw_dmp_segments (403).Verify role/scope; re-auth if needed (needs_reauth).no
RESOURCE_EXHAUSTEDRate limit (429).Backoff 5/10/20s cap 60s; chunk + throttle.yes
TOKEN_REVOKEDToken expired/revoked (401).Refresh and retry once; else re-auth.yes
NOT_FOUNDSegment not found (404).Confirm numeric id.no

Edge cases

  • Removal uses BATCH_CREATE with action:'REMOVE', NOT BATCH_DELETE — no delete-by-ids variant exists for segment users.
  • Identifier not in segment -> per-row removal is a no-op; a 201 on an already-removed id is success (idempotent by design).
  • Hashing mismatch (e.g. uppercase or untrimmed email) won't match the stored member — normalize identically before removing.
  • idType outside {SHA256_EMAIL, SHA512_EMAIL, GOOGLE_AID} -> reject before sending.
  • Removing members may drop the audience below 300 -> warn it will stop serving.
  • Large removals (>5000) must be chunked under the 600/min limit.
  • Idempotent: re-running a removal is safe.