API reference
Messages
Each campaign contains a set of Message objects which are eventually sent as a Twitter DM.
ENDPOINTS
Create Message
To send a DM to a Twitter user, you create a Message object for the desired campaign.
Make sure your campaign is API accessible !
You'll only be able to use this endpoint with campaigns that allow API access. Go to my campaigns .
Parameters
- to stringRequiredTwitter User ID or Username
- is_username booleanOptionalMust be true if a username is used for the parameter 'to'. Default is false.
Returns
Returns the newly created Message object.
- id stringUnique identifier of the message
- campaign stringUnique identifier of the campaign
- to stringRecipient Twitter User ID
- text stringMessage text that was sent to the recipient
- createdAt numberUnix timestamp of the moment the message was created
Example
cURL
curl https://api.colddm.me/v1/campaigns/some-campaign-id/messages/
-H "Content-type: application/json"
-H "Authorization: Bearer your-secret-api-key"
-d '{
"to": "jack",
"is_username": true
}'
Javascript
const campaignId = 'some-campaign-id'
const response = await fetch(
`https://api.colddm.me/v1/campaigns/${campaignId}/messages/`,
{
method: 'POST',
headers: {
'Content-type': 'application/json',
Authorization: 'Bearer your-secret-api-key',
},
body: JSON.stringify({
to: 'jack',
is_username: true,
}),
}
)
if (response.ok) {
//Success
const { data: message } = await response.json()
console.log(`Message id: ${message.id}`)
} else {
//Handle error
const { code, message } = await response.json()
console.log(`Error Code : ${code}
Error Message : ${message}`)
}