How to send a custom email using API v3

I am trying to use the endpoint “messages” to send an email for a list of contacts
However looking at the documentation I didn’t get how to do.
I am using python and I’ve tried the following:

headers = {'Api-Token': ac_key,
"accept": "application/json",
"content-type": "application/json"}

url = f'{ac_url}/api/3/messages'

payload = {
"message": {
"fromname": "Clube da Aposta",
"fromemail": "[relacionamento@clubedaposta.com](mailto:relacionamento@clubedaposta.com)",
"reply2": "[relacionamento@clubedaposta.com](mailto:relacionamento@clubedaposta.com)",
"subject": "You are subscribing to %LISTNAME%",
"preheader_text": "Pre-header Text",
"text": "hello",
"html": "<div>hello</div>"
}
}

response = requests.post(url, headers=headers, json=payload)

As response I got this:

{‘message’: {‘fromname’: ‘Clube da Aposta’, ‘fromemail’: ‘relacionamento@clubedaposta.commailto:[relacionamento@clubedaposta.com](mailto:relacionamento@clubedaposta.com)’, ‘reply2’: ‘relacionamento@clubedaposta.commailto:[relacionamento@clubedaposta.com](mailto:relacionamento@clubedaposta.com)’, ‘subject’: ‘You are subscribing to %LISTNAME%’, ‘preheader_text’: ‘Pre-header Text’, ‘text’: ‘hello’, ‘html’: ‘

hello
’, ‘links’: {‘user’: ‘https://clubedaaposta.api-us1.com/api/3/messages/4901/user’, ‘hyperlinks’: ‘https://clubedaaposta.api-us1.com/api/3/messages/4901/hyperlinks’}, ‘id’: ‘4901’}}

However looks like that no email was sent.
Do I have to set a parameter to indicate the users ids or lists to send the email?
I didn’t get how to do this. Can anyone help me?

1 Like

Hello there! Please check if the following call would be useful Send a campaign via API V1

Please keep in mind that we are here to help, if you have any other questions on this topic or any other you can contact us anytime at Contact ActiveCampaign - Support and Sales

ActiveCampaign Customer Experience Team.