How to style content with the elements API?

I was wondering if it’s possible to replicate some of the functionality from the Template-Designer with the Elements API: Elements | Courier Docs

I’ve tried to create an element that should be formatted as a title/headline, but it’ll always get rendered as normal text.

I’ve tried:

elements: [
	{
		type: "text",
		text_style:"h2", // Does not seem to work?
		content: "This is the title"
	}
]

and:

elements: [
	{
		type: "text",
		content: "## This is the title"
	}
]

But neither creates a title.
What am I missing? Does somebody have an example for text-formatting via Elements? Or is there an undocumented markdown type or something?

Hi @Roman,

Thanks for reaching out!

If you’re looking for a “title” property, you can nest it inside a “content” object like in this example.

Let me know how that works!

1 Like

Hi @rodrigo. Thanks for your reply.
That doesn’t seem to answer my question though. The “title” property is the email Subject.
I was wondering how to format a Text-Element as title.

Here’s an example of what I mean. In the Template designer, you can format Text like this:

I want to do the same by using the API (without having to create templates in the Designer first)

Hmm, that’s certainly strange that "text_style": "h2" wouldn’t work for text blocks but available for quote blocks. Let me check with my engineering team and see if there’s a workaround for this or if there’s a gap in our docs not fully explaining how to format text styles. I’ll circle back with a more detailed answer @Roman !

Wanted to circle back and give you an update @Roman . Currently, Elemental does not have "text_style": support for the Text block. Only the quote block. I brought this up to my engineering team and they will work on adding support - which should not be too hard to do. I’ll get back to you once this update has been shipped and is live!

1 Like