The issue with sending is caused by the draft being sent before it's saved on the provider. Previously we were not always exposing the failure, as a result, our backend was continuously retrying hiding the underlying issue.
There are two potential fixes here:
- Quickest: Remove the draft.save() step and send message directly
- If saving the draft then confirm draft is created via job-status endpoint or webhook.
Method 1: Don't create a draft and send it directly via POST /send.
An example of how to do this via the Python SDK, remove the draft.save step.
Method 2: Confirm the Draft has been created before sending, by checking the job-status
Workflow:
- Create draft - POST /drafts
- Capture POST /drafts response which contains job_status_id
- Wait for webhook
job.successful
draft has been created on provider - OR you can GET /job-statuses/<JOB_STATUS_ID> , pass the job_status_id as returned in the POST /draft response
- Send draft - POST /send
Or a quicker, temporary method with minimal code to get everything working, wait ten seconds between draft and send, this can happen in the backend without affecting the user experience. This is not a long-term solution, best practice if using drafts is to check the job_status_id has completed.
Updated
Comments
0 comments
Please sign in to leave a comment.