Marketo
Sync leads, trigger smart campaigns, and pull activities via the Marketo (Adobe Marketo Engage) REST API.
Grounded in the official Marketo REST API reference
(https://developers.marketo.com/rest-api/, now hosted on Adobe Experience
League). Standard-library Python only (urllib, json, base64) — no
third-party packages.
What it does
The tool authenticates with Marketo using OAuth 2.0 client_credentials,
fetches a short-lived bearer token, and then calls the REST API on your
instance host (https://<munchkin-id>.mktorest.com). It returns the raw
Marketo JSON response as result and the HTTP status as status.
Operations
| operation | Method / endpoint | Purpose |
|---|---|---|
get_leads |
GET /rest/v1/leads.json |
Read leads by filter |
sync_leads |
POST /rest/v1/leads.json |
Create/update (upsert) up to 300 leads |
trigger_campaign |
POST /rest/v1/campaigns/{id}/trigger.json |
Run up to 100 leads through a smart campaign |
get_activities |
GET /rest/v1/activities.json |
Pull lead activities (paged) |
Inputs by operation
- get_leads —
filterType(e.g.email,id),filterValues(up to 300 comma-separated values). Optional:fields,batchSize. - sync_leads —
leads(JSON array of lead objects, up to 300). Optional:action(createOrUpdatedefault /createOnly/updateOnly/createDuplicate),lookupField(defaults toemail). - trigger_campaign —
campaignId,leads(JSON array of{"id": …}refs, up to 100). Optional:tokens(My Token overrides). The campaign must have a "Campaign is Requested" trigger with Web Service API as the source. - get_activities —
activityTypeIds(up to 10 comma-separated ids) plus anextPageToken. If you don't have a token yet, passsinceDatetime(ISO-8601) and the tool first callsGET /rest/v1/activities/paging/token.json?sinceDatetime=…to bootstrap one. Optional:leadIds(up to 30),listId.
apiKey setup
Marketo uses OAuth, not a single static key, so the apiKey packs the three
OAuth parts pipe-separated:
<Identity URL>|<Client Id>|<Client Secret>
Example:
https://123-ABC-456.mktorest.com/identity|abcd1234-client-id|s3cr3t-client-secret
Where to find each part in the Marketo Admin console:
- Identity URL — Admin > Integration > Web Services (the "Identity" REST
URL, usually
https://<munchkin-id>.mktorest.com/identity). - Client Id / Client Secret — Admin > Integration > LaunchPoint → create (or open) a Custom Service, then View Details.
The tool performs the token exchange for you:
GET <Identity URL>/oauth/token?grant_type=client_credentials&client_id=…&client_secret=…
and sends the returned token as Authorization: Bearer <access_token> on each
call (query-param tokens are being removed 2026-07-31, so the header form is used).
Alternative: if you already have a valid bearer token, pass it directly as
apiKey(no|) and setinstanceUrlto your REST host (https://<munchkin-id>.mktorest.com).
Examples
Look up leads by email
operation: get_leads
apiKey: https://123-ABC-456.mktorest.com/identity|<clientId>|<clientSecret>
filterType: email
filterValues: [email protected],[email protected]
fields: email,firstName,lastName
Upsert leads
operation: sync_leads
apiKey: https://123-ABC-456.mktorest.com/identity|<clientId>|<clientSecret>
leads: [{"email":"[email protected]","firstName":"Ann","lastName":"Lee"}]
action: createOrUpdate
Trigger a smart campaign for two leads
operation: trigger_campaign
apiKey: https://123-ABC-456.mktorest.com/identity|<clientId>|<clientSecret>
campaignId: 1234
leads: [{"id":318581},{"id":318582}]
tokens: [{"name":"{{my.message}}","value":"Welcome aboard"}]
Pull lead activities since a date
operation: get_activities
apiKey: https://123-ABC-456.mktorest.com/identity|<clientId>|<clientSecret>
sinceDatetime: 2024-01-01T00:00:00Z
activityTypeIds: 1,12,13
Output
{ "result": "<raw Marketo JSON response>", "status": "200" }
A non-2xx HTTP response is returned as-is (with its status) so you can inspect
Marketo error codes (e.g. 601/602 token errors). A transport-level failure
returns {"error": "<message>"} and fails the step.