Skip to main content

Create Posts using Custom Headlines / Subheadings

In this example we will look at how to create posts using your own content. You can provide content for heading, subheading for each page of the creative. You can also send content for bullet points if you are generating a listicle post.

If you pass the headlines parameter, the AI will not generate content for headlines/subheadings etc and will use the provided headlines as it is. The maximum number of allowed characters for heading and subheading is 200 characters

import requests

url = "https://brain.predis.ai/predis_api/v1/create_content/"

payload = {
"brand_id": "YOUR_BRAND_ID",
"text": "3 tips for a healthy morning breakfast",
"media_type": "single_image",
'headlines': """[{"h1": "Heading for first page", "h2": "Subheading for first page", "cta": "Call to action for first page"}, {"h1": "Heading for second page/first listicle bullet point", "h2": "subheading for second page"}, {"h1": "Heading for third page/second listicle bullet point", "h2": "subheading for third page"}]"""
}

headers = {"Authorization": "YOUR_API_KEY"}

response = requests.request("POST", url, data=payload, headers=headers)

if response.status_code == 200:
json_response = response.json()
post_id = response.get("post_id")
post_status = response.get("status")

else:
print("Error occurred - {}".format(response.text))

If you get a inProgress status in response, your request is successful and the posts are getting generated. Once the posts get generated successfully (or fail), you will get a request on your configured webhook URL with more details about the posts. In the case of multiple posts, you will receive the webhook event for each post separately.