How to trigger SendGrid single send from API - sendgrid

I'm able to create single send for a segment from API, but it is not being sent and its status is shown as "draft"
as "send_at" (says that it must be a datetime in the future) is optional and also in the single send intro says that single send can be sent immediately or scheduled for a time in the future I assumed that I shouldn't set any value to this property to send the emails immediately. these are the single sends I have created using API:

The single send will be in draft mode until it is scheduled.
Specifically this endpoint needs to be hit using that Single Send id: /v3/marketing/singlesends/{sendgrid_single_send_id}/schedule
With the send_at specified as a date in the future

Related

Can I stop a SendGrid mail if it received a certain parameter?

I'm using a certain SendGrid template for several different projects and am trying to find a way to stop emails from going out in some conditions, through SendGrid.
For example, lets say I'm passing SendGrid some parameters like:
{id, name, amount, date}
I want to stop that email from going out when i'm passing a certain id.
I know that I can change the email template i'm sending with conditionals using handlebars:
From here
But Can I actually stop the mail if some condition happens?
In my case, every time I send the id = 5
You can control the body of the email using Handlebar templating, but by that point, you have already told SendGrid to send email with the data you provided. You cannot stop the email from being sent from within Handlebars.
If you're using code to tell SendGrid to send these emails, you could check in your code if the id equals 5, and if so, do not send an email.
If you're using Single Sends to send an email to SendGrid Contacts, you could to store this id field as a custom field, and create a segment or update your existing segment to filter out the contact with that id.

SendGrid send mail - how to keep track of emails?

I am sending emails from sendgrid from my backend. When I send the email, the response is 202 and the response body is empty. Since the response body is empty, i do not have any information like an ID to track the email events in my system.
When I go to fetch the events, i see they have an ID, but since I don't have that ID from their creation, I cant map emails I sent to events I received.
Can you give an email an ID or label it somehow when you send it? So that you can map al the events from it?
What we are trying to do is to have a list of "transactions" where each "Transaction" is affiliated with an email. We want to provide email event data in our app, but can't figure out how to map
The response body of a successful Mail Send API call is empty, but the response contains a x-message-id header which you can use to retrieve details about the messages being sent.
Since one API call to the Mail Send API can result in multiple emails being sent, this ID identifies the group of messages, and they'll all be prefixed with the x-message-id. For example, if x-message-id returns W86EgYT6SQKk0lRflfLRsA, the IDs of your messages will start with that and then be suffixed with something like .filterdrecv-5645d9c87f-78xgx-1-62841247-82.1.
Together it'd look like W86EgYT6SQKk0lRflfLRsA.filterdrecv-5645d9c87f-78xgx-1-62841247-82.1.
If you want to track the messages, you can use the event webhook or pull the information via the Email Activity Feed API.
This Stack Overflow Q&A about tracking bulk email statuses may also be useful to look at.

How to specify SMS URL for specific text message

Is there a way when using the REST API to send an outgoing message that I can specify the SMS Url to use for any responses to that message? I saw mention of it in the docs where it says you can specify it for the phone number in the console or via the API. If I post a variable named SmsUrl when sending the text it still uses the url connected to the number or the twilio app.
We need responses to submit back to a url on our server that includes a parameter that lets us connect the response to a specific inspection request. In other words we need to be able to connect the response not to the from number but to the record on our end for which the outgoing message was triggered.
Thanks
If you are sending from a single number this is totally impossible, SMS simply doesn't work like that. If you send me 5 SMS and then I reply to one of them my reply contains no data which links it to the SMS I am responding to.
The only ways I can see you achieving this are:
Assign a different outgoing number to each trigger. This is foolproof
but may not be viable depending on your usecase and nuber of
triggers. It may also confuse your users if they get texts from many
different numbers, although if you buy consecutive ones you could
mitigate this.
Include instructions in your SMS like "Reply 1 to request a call, 2
to request a password reset..." or "Start your reply with XXXX" where
XXXX is a unique code you generate server side and assign to the
user, or have a code for each trigger or whatever. This would work
with only one outgoing number, but in my experience the end users
will screw it up a lot of the time and not respect your instructions.

How to track status of email in sendgrid without using SMTP.

I want to send emails which contain different contents to same user and I need to track their status. Are there any way to do that without using SMTP.
Sounds like you want Unique Args. These are called custom_args in the v3 API mail send argument, but it's the same concept.
Once you activate the Event Webhook, all events will include the appropriate unique_args, so you can relate each specific message to each.
Also, whenever you send a message to SendGrid, the acceptange response includes a message_id, which will be in all those events.

sendgrid email via X-SMTP

I am trying to figure out how can I make it possible to send an email from my
application to Sendgrid and have it come back.
I want to use coldfusion to send an email using X-SMTP API. I found a documentation
online here but still wondering if there's any documentation available other
than the web API one?
http://thehatrack.net/blog/integrating-sendgrid-with-your-coldfusion-application/
SendGrid's Event Webhook is the only way to get email reads on an individual basis. This will POST an event to your server every time an email is read (among several other events).
The only "pull" based solution to get individual email events from SendGrid is the bounces endpoint, which will tell you when an email bounces (and is certainly not read), but nothing else.
If you want to retrieve individual read events from SendGrid, you'll need to connect the Event Webhook to an external service like Keen.io, and then leveraging their API to get individual events.