Notify API reference

POST /v1/send/email

This POST endpoint lets you send an email.

A typical request is as follows:

Request

POST /v1/send/email HTTP/1.1
Content-Type: application/json

{
  "to": "Example User <user@example.com>",
  "from": "admin@project.com",
  "fromName": "Project Admin",
  "sub": "This is the email subject line",
  "text": "This is the email content in plain text",
  "html": "<p>This is the <b>email content</b> in html format</p>"
}

Note

  • Make sure that the from field you will be using to send emails is from the sending domain you have configured with SparkPost or Mandrill. For example, if your sending domain is project.com, you can only send emails from <something>@project.com, like admin@project.com.
  • Either text or html key should be present. Both can also be provided.
  • fromName is optional.

Response

An example response looks like:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "id": "<provider-reference-id>",
  "detail": "<details>"
}

POST /v1/send/sms

This endpoint can be used to send SMS.

Request

An example request to send an SMS to +91-9876543210 would look like:

POST /v1/send/sms HTTP/1.1
Content-Type: application/json

{
  "to": 9876543210,
  "countryCode": 91,
  "message": "This is the body of SMS"
}

Response

A typical response will look like this:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "id": "<provider-reference-id>",
  "detail": "<details>"
}

Response structure

Status code Description Response structure
200 Success
Request specific
400 Bad request
{
    "code"  : String,
    "message" : String
}
401 Unauthorized
{
    "code" : String,
    "message" : String
}
500 Internal server error
{
    "code" : String,
    "message" : String
}

Error Codes

Status Code Code Message Description
400 invalid_payload Error in $: When parsing the record EmailPayload of type Hasura.Notify.Types.EmailPayload the key to was not present. When required keys are not met in request payload
400 invalid_provider sending templates is not available for <provider-name> when ‘send/email-template’ is not supported by email provider specified in project conf
401 unauthorized Only role: admin is allowed When notify is requested by user not having ‘admin’ role
500 default_not_found No default email/sms provider set when default provider for sms for email not set in notify project conf
500 config_not_found No <provider-name> config found when config is not given for provider specified in ‘default’ field
500 unexpected unexpected response from mandrill when api response from mandrill is not expected
500 unexpected fallback 500 error handler  
500 response_changed <response from provider> when api response from sms and email provider is unexpected