Schedules one or more send_message API calls to be made at one or more points in time in the future. This is effectively an alternative to calling create_scheduled_events multiple times.

This method is useful for situations where an application can only deliver a singular API payload during a particular course of action.

Request Fields

These are passed in at the top level of the request.

Key Type Description
events array One or more nested create_scheduled_event definitions.

Request Example

{
  "api_key" : "__PROJECT_API__KEY__",
  "events": [
    {
      "uid": "__UID_1__",
      "schedule": "every 5 mins",
      "metadata": {
        "arguments": {
          "recipients": "test@example.com",
          "headers": {
            "from": "test@example.com",
            "subject": "Example Scheduled Email"
          },
          "content": {
            "text/plain": "This email was sent automatically."
          },
          "attachments": {
            "test.pdf": {
              "content_type": "application/octet-stream",
              "content": {
                "$ref": "http://example.com/resources/example.pdf", 
                "$type": "application/octet-stream",
                "$encode": "base64"
              }
            }
          }
        }
      }
    },
    {
      "uid": "__UID_2__",
      "schedule": "every 30 mins",
      "metadata": {
        "arguments": {
          "recipients": "test@example.com",
          "headers": {
            "from": "test@example.com",
            "subject": "Example Secondary Scheduled Email"
          },
          "content": {
            "text/plain": "This email was sent automatically."
          },
          "attachments": {
            "test.pdf": {
              "content_type": "application/octet-stream",
              "content": {
                "$ref": "http://example.com/resources/example.pdf", 
                "$type": "application/octet-stream",
                "$encode": "base64"
              }
            }
          }
        }
      }
    }
  ]
}

Response 200 OK

Upon successful creation a response of the following form is sent:

{
  "response": {
    "status": "ok",
    "message": [
      {
        "uid": "__UID_1__",
        "status": "activated",
        "schedule": "every 1 mins",
        "event_type": "repeatable",
        "scheduled_at": "2019-01-04T20:51:00+00:00"
      },
      {
        "uid": "__UID_2__",
        "status": "activated",
        "schedule": "every 5 mins",
        "event_type": "repeatable",
        "scheduled_at": "2019-01-04T20:55:00+00:00"
      }
    ]
  }
}

The scheduled_at field shows the execution time (UTC) of the event.

Response 400 Bad Request

If the UID is taken an error of the following form will be returned:

{
  "response": {
    "status": "bad_request",
    "uid": "__UID__",
    "message": "Could not create scheduled event."
  },
  "data": {
    "errors": [
      "[:uid, :project id] is already taken"
    ]
  }
}

Each UID value must be unique per-project. Existing events can be updated on an individual basis with the update_scheduled_event endpoint.