Create/Update multiple tokens?

Anonymous
Not applicable

Create/Update multiple tokens?

Is there a way to create/update multiple tokens with the REST API using just 1 API call?

At the moment it seems like I have to make 1 API call for every token I want to update.

Thanks.

Tags (3)
13 REPLIES 13
SanfordWhiteman
Level 10 - Community Moderator

Re: Create/Update multiple tokens?

That endpoint only supports one token at a time. You might think about consolidating tokens into a single JSON object, depending on your output needs.

Anonymous
Not applicable

Re: Create/Update multiple tokens?

Hi Sanford, can you please elaborate on "consolidating tokens into a single JSON object, depending on your output needs."

I'm creating a client in an external application which clones a template program in Marketo. I want to update the tokens in the program with the details of the client e.g. client name, client address, client phone number etc...

That's just a very simple take on the use case, I actually have about 30 tokens I need to update... If I can send all of the tokens I need to create in 1 API call that'd save me a lot of system resources and time.

Thanks.

SanfordWhiteman
Level 10 - Community Moderator

Re: Create/Update multiple tokens?

JSON, by definition, can store multiple keys and values in a single string. For example, a token like

{

"fullName" : "e stately",

"streetAddress" : "212 JSON Lane",

"phoneNumber" : "646-555-1212"

}

can be parsed into its constituent parts using JavaScript (on landing pages) or Velocity (in emails). So as long as you pass your tokens through one of those before outputting, you can use a single token to represent a set of related (or even unrelated) values.

From a {{my.token}} standpoint, since you can't search those values anyway, there's no loss of matching fidelity by using JSON..  About the only drawback would be if you want to use a single value from the {{my.token}} in a Flow step, where you don't have JS/VTL to draw on directly (though you could shred the JSON onto lead fields first, if you wanted to really badly).

I've written about this approach at http://blog.teknkl.com/marketo-json-fields-in-velocity/ and in numerous other places on my blog and here in the Community.

Anonymous
Not applicable

Re: Create/Update multiple tokens?

Clever use of custom fields and I do understand your idea now, but unfortunately it's not applicable for my situation.

SanfordWhiteman
Level 10 - Community Moderator

Re: Create/Update multiple tokens?

Because?

Anonymous
Not applicable

Re: Create/Update multiple tokens?

I need a solution that works like a lookup so that if details about a client changes, it'll be painless. Currently cascading folders and using tokens seems to be the only way to do it. Custom objects currently are limited to 1 intermediary object + 1 custom object and filters don't work yet. My situation resembles:

1. Client Level

     2. Product Level - looks up clientId

           3. Line item Level - looks up productId

Applying your idea, if I use write company tokens to a lead, and the company's phone number/contact person changes, it'll be painful having to change the custom field of every lead where the company exists.

SanfordWhiteman
Level 10 - Community Moderator

Re: Create/Update multiple tokens?

I don't understand why such values need to be copied to lead records.

Presumably, as you're intending to use the program tokens endpoint, these are not lead-specific values, but values that are shared across all leads that make use of assets in those programs and/or are members of those programs.

Erik_Heldebro2
Level 8

Re: Create/Update multiple tokens?

Hey Sanford Whiteman,

Bringing back one of these old threads again

I was looking at the endpoint reference for Creating/Updating Tokens (https://developers.marketo.com/rest-api/assets/tokens/#create_and_update) and it is referring to data being passed as POST x-www-form-urlencoded, not as JSON.

Do you think it would be possible to pass data as a JSON object to update say 10-15 My Tokens in one API call? Just wondering if you have any good insights into this considering your comments above.

Best,

Erik

SanfordWhiteman
Level 10 - Community Moderator

Re: Create/Update multiple tokens?

Yeah, no, the individual {{my.tokens}} (as Marketo sees them) have to be updated in one call at a time AFAIK. But if you embed JSON data with a single {{my.token}} you can output all the parts of it separately using Velocity. It's awesome for particular cases, but def'ly not all.