Skip to main content
POST
/
program_messages
JavaScript
import Moonbase from '@moonbaseai/sdk';

const client = new Moonbase({
  apiKey: process.env['MOONBASE_API_KEY'], // This is the default and can be omitted
});

const programMessage = await client.programMessages.send({
  person: { email: '[email protected]' },
  program_template_id: '1CLJt2v271pTY4bHG7UQrc',
  custom_variables: { coupon_code: 'HOWDY' },
});

console.log(programMessage.id);
{
  "id": "1CLJt2v4LTd2iVzVWmBhub",
  "type": "program_message",
  "program_template": {
    "id": "1CLJt2v271pTY4bHG7UQrc",
    "type": "program_template",
    "subject": "Test Subject to {{ person.name }}",
    "body": {
      "markdown": "Your coupon code is [TEST]"
    },
    "created_at": "2025-02-17T16:00:00.000Z",
    "updated_at": "2025-02-17T16:00:00.000Z"
  },
  "created_at": "2025-02-17T16:00:00.000Z",
  "updated_at": "2025-02-17T16:00:00.000Z"
}

Authorizations

Authorization
string
header
required

Your Moonbase API key.

Body

application/json

The ProgramMessage to be sent.

Parameters for sending a ProgramMessage.

person
object
required

The person to send the message to.

program_template_id
string
required

The ID of the ProgramTemplate to use for sending the message.

custom_variables
object

Any custom Liquid variables to be interpolated into the message template.

Response

Message accepted.

Represents a single message sent as part of a Program.

type
string
required

String representing the object’s type. Always program_message for this object.

Allowed value: "program_message"
id
string
required

Unique identifier for the object.

program_template
ProgramTemplate · object
required

The ProgramTemplate used to generate this message.

created_at
string<date-time>
required

Time at which the message was created and enqueued for sending, as an ISO 8601 timestamp in UTC.

updated_at
string<date-time>
required

Time at which the object was last updated, as an ISO 8601 timestamp in UTC.