JavaScript
import Courier from '@trycourier/courier';
const client = new Courier({
apiKey: process.env['COURIER_API_KEY'], // This is the default and can be omitted
});
const automationInvokeResponse = await client.automations.invoke.invokeAdHoc({
automation: {
cancelation_token: 'delay-send--user-yes--abc-123',
steps: [
{ action: 'delay', until: '20240408T080910.123' },
{ action: 'send', template: '64TP5HKPFTM8VTK1Y75SJDQX9JK0' },
],
},
data: { name: 'Foo' },
profile: { tenant_id: 'abc-123' },
recipient: 'user-yes',
});
console.log(automationInvokeResponse.runId);import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
automation_invoke_response = client.automations.invoke.invoke_ad_hoc(
automation={
"cancelation_token": "delay-send--user-yes--abc-123",
"steps": [{
"action": "delay",
"until": "20240408T080910.123",
}, {
"action": "send",
"template": "64TP5HKPFTM8VTK1Y75SJDQX9JK0",
}],
},
data={
"name": "Foo"
},
profile={
"tenant_id": "abc-123"
},
recipient="user-yes",
)
print(automation_invoke_response.run_id)package main
import (
"context"
"fmt"
"github.com/trycourier/courier-go"
"github.com/trycourier/courier-go/option"
)
func main() {
client := courier.NewClient(
option.WithAPIKey("My API Key"),
)
automationInvokeResponse, err := client.Automations.Invoke.InvokeAdHoc(context.TODO(), courier.AutomationInvokeInvokeAdHocParams{
Automation: courier.AutomationInvokeInvokeAdHocParamsAutomation{
CancelationToken: courier.String("delay-send--user-yes--abc-123"),
Steps: []courier.AutomationInvokeInvokeAdHocParamsAutomationStepUnion{{
OfAutomationDelayStep: &courier.AutomationInvokeInvokeAdHocParamsAutomationStepAutomationDelayStep{
Action: "delay",
Until: courier.String("20240408T080910.123"),
},
}, {
OfAutomationSendStep: &courier.AutomationInvokeInvokeAdHocParamsAutomationStepAutomationSendStep{
Action: "send",
Template: courier.String("64TP5HKPFTM8VTK1Y75SJDQX9JK0"),
},
}},
},
Data: map[string]any{
"name": "Foo",
},
Profile: map[string]any{
"tenant_id": "abc-123",
},
Recipient: courier.String("user-yes"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", automationInvokeResponse.RunID)
}
package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.automations.AutomationInvokeResponse;
import com.courier.models.automations.invoke.InvokeInvokeAdHocParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
InvokeInvokeAdHocParams params = InvokeInvokeAdHocParams.builder()
.automation(InvokeInvokeAdHocParams.Automation.builder()
.addStep(InvokeInvokeAdHocParams.Automation.Step.AutomationDelayStep.builder()
.action(InvokeInvokeAdHocParams.Automation.Step.AutomationDelayStep.Action.DELAY)
.build())
.addStep(InvokeInvokeAdHocParams.Automation.Step.AutomationSendStep.builder()
.action(InvokeInvokeAdHocParams.Automation.Step.AutomationSendStep.Action.SEND)
.build())
.build())
.build();
AutomationInvokeResponse automationInvokeResponse = client.automations().invoke().invokeAdHoc(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
automation_invoke_response = courier.automations.invoke.invoke_ad_hoc(automation: {steps: [{action: :delay}, {action: :send}]})
puts(automation_invoke_response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Courier\Client;
use Courier\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('COURIER_API_KEY') ?: 'My API Key');
try {
$automationInvokeResponse = $client->automations->invoke->invokeAdHoc(
automation: [
'steps' => [
[
'action' => 'delay',
'duration' => 'duration',
'until' => '20240408T080910.123',
],
[
'action' => 'send',
'brand' => 'brand',
'data' => ['foo' => 'bar'],
'profile' => ['foo' => 'bar'],
'recipient' => 'recipient',
'template' => '64TP5HKPFTM8VTK1Y75SJDQX9JK0',
],
],
'cancelationToken' => 'delay-send--user-yes--abc-123',
],
brand: 'brand',
data: ['name' => 'bar'],
profile: ['tenant_id' => 'bar'],
recipient: 'user-yes',
template: 'template',
);
var_dump($automationInvokeResponse);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using System.Collections.Generic;
using System.Text.Json;
using TryCourier;
using Invoke = TryCourier.Models.Automations.Invoke;
CourierClient client = new();
Invoke::InvokeInvokeAdHocParams parameters = new()
{
Automation = new()
{
Steps =
[
new Invoke::AutomationDelayStep()
{
Action = Invoke::Action.Delay,
Duration = "duration",
Until = "20240408T080910.123",
},
new Invoke::AutomationSendStep()
{
Action = Invoke::AutomationSendStepAction.Send,
Brand = "brand",
Data = new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
},
Profile = new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
},
Recipient = "recipient",
Template = "64TP5HKPFTM8VTK1Y75SJDQX9JK0",
},
],
CancelationToken = "delay-send--user-yes--abc-123",
},
};
var automationInvokeResponse = await client.Automations.Invoke.InvokeAdHoc(parameters);
Console.WriteLine(automationInvokeResponse);courier automations:invoke invoke-ad-hoc \
--api-key 'My API Key' \
--automation '{steps: [{action: delay}, {action: send}]}'curl --request POST \
--url https://api.courier.com/automations/invoke \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"name": "Foo"
},
"profile": {
"tenant_id": "abc-123"
},
"recipient": "user-yes",
"automation": {
"cancelation_token": "delay-send--user-yes--abc-123",
"steps": [
{
"action": "delay",
"until": "20240408T080910.123"
},
{
"action": "send",
"template": "64TP5HKPFTM8VTK1Y75SJDQX9JK0"
}
]
}
}
'{
"runId": "1-65f240a0-47a6a120c8374de9bcf9f22c"
}Automations
Invoke an Ad Hoc Automation
Invoke an ad hoc automation run. This endpoint accepts a JSON payload with a series of automation steps. For information about what steps are available, checkout the ad hoc automation guide here.
POST
/
automations
/
invoke
JavaScript
import Courier from '@trycourier/courier';
const client = new Courier({
apiKey: process.env['COURIER_API_KEY'], // This is the default and can be omitted
});
const automationInvokeResponse = await client.automations.invoke.invokeAdHoc({
automation: {
cancelation_token: 'delay-send--user-yes--abc-123',
steps: [
{ action: 'delay', until: '20240408T080910.123' },
{ action: 'send', template: '64TP5HKPFTM8VTK1Y75SJDQX9JK0' },
],
},
data: { name: 'Foo' },
profile: { tenant_id: 'abc-123' },
recipient: 'user-yes',
});
console.log(automationInvokeResponse.runId);import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
automation_invoke_response = client.automations.invoke.invoke_ad_hoc(
automation={
"cancelation_token": "delay-send--user-yes--abc-123",
"steps": [{
"action": "delay",
"until": "20240408T080910.123",
}, {
"action": "send",
"template": "64TP5HKPFTM8VTK1Y75SJDQX9JK0",
}],
},
data={
"name": "Foo"
},
profile={
"tenant_id": "abc-123"
},
recipient="user-yes",
)
print(automation_invoke_response.run_id)package main
import (
"context"
"fmt"
"github.com/trycourier/courier-go"
"github.com/trycourier/courier-go/option"
)
func main() {
client := courier.NewClient(
option.WithAPIKey("My API Key"),
)
automationInvokeResponse, err := client.Automations.Invoke.InvokeAdHoc(context.TODO(), courier.AutomationInvokeInvokeAdHocParams{
Automation: courier.AutomationInvokeInvokeAdHocParamsAutomation{
CancelationToken: courier.String("delay-send--user-yes--abc-123"),
Steps: []courier.AutomationInvokeInvokeAdHocParamsAutomationStepUnion{{
OfAutomationDelayStep: &courier.AutomationInvokeInvokeAdHocParamsAutomationStepAutomationDelayStep{
Action: "delay",
Until: courier.String("20240408T080910.123"),
},
}, {
OfAutomationSendStep: &courier.AutomationInvokeInvokeAdHocParamsAutomationStepAutomationSendStep{
Action: "send",
Template: courier.String("64TP5HKPFTM8VTK1Y75SJDQX9JK0"),
},
}},
},
Data: map[string]any{
"name": "Foo",
},
Profile: map[string]any{
"tenant_id": "abc-123",
},
Recipient: courier.String("user-yes"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", automationInvokeResponse.RunID)
}
package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.automations.AutomationInvokeResponse;
import com.courier.models.automations.invoke.InvokeInvokeAdHocParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
InvokeInvokeAdHocParams params = InvokeInvokeAdHocParams.builder()
.automation(InvokeInvokeAdHocParams.Automation.builder()
.addStep(InvokeInvokeAdHocParams.Automation.Step.AutomationDelayStep.builder()
.action(InvokeInvokeAdHocParams.Automation.Step.AutomationDelayStep.Action.DELAY)
.build())
.addStep(InvokeInvokeAdHocParams.Automation.Step.AutomationSendStep.builder()
.action(InvokeInvokeAdHocParams.Automation.Step.AutomationSendStep.Action.SEND)
.build())
.build())
.build();
AutomationInvokeResponse automationInvokeResponse = client.automations().invoke().invokeAdHoc(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
automation_invoke_response = courier.automations.invoke.invoke_ad_hoc(automation: {steps: [{action: :delay}, {action: :send}]})
puts(automation_invoke_response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Courier\Client;
use Courier\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('COURIER_API_KEY') ?: 'My API Key');
try {
$automationInvokeResponse = $client->automations->invoke->invokeAdHoc(
automation: [
'steps' => [
[
'action' => 'delay',
'duration' => 'duration',
'until' => '20240408T080910.123',
],
[
'action' => 'send',
'brand' => 'brand',
'data' => ['foo' => 'bar'],
'profile' => ['foo' => 'bar'],
'recipient' => 'recipient',
'template' => '64TP5HKPFTM8VTK1Y75SJDQX9JK0',
],
],
'cancelationToken' => 'delay-send--user-yes--abc-123',
],
brand: 'brand',
data: ['name' => 'bar'],
profile: ['tenant_id' => 'bar'],
recipient: 'user-yes',
template: 'template',
);
var_dump($automationInvokeResponse);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using System.Collections.Generic;
using System.Text.Json;
using TryCourier;
using Invoke = TryCourier.Models.Automations.Invoke;
CourierClient client = new();
Invoke::InvokeInvokeAdHocParams parameters = new()
{
Automation = new()
{
Steps =
[
new Invoke::AutomationDelayStep()
{
Action = Invoke::Action.Delay,
Duration = "duration",
Until = "20240408T080910.123",
},
new Invoke::AutomationSendStep()
{
Action = Invoke::AutomationSendStepAction.Send,
Brand = "brand",
Data = new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
},
Profile = new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
},
Recipient = "recipient",
Template = "64TP5HKPFTM8VTK1Y75SJDQX9JK0",
},
],
CancelationToken = "delay-send--user-yes--abc-123",
},
};
var automationInvokeResponse = await client.Automations.Invoke.InvokeAdHoc(parameters);
Console.WriteLine(automationInvokeResponse);courier automations:invoke invoke-ad-hoc \
--api-key 'My API Key' \
--automation '{steps: [{action: delay}, {action: send}]}'curl --request POST \
--url https://api.courier.com/automations/invoke \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"name": "Foo"
},
"profile": {
"tenant_id": "abc-123"
},
"recipient": "user-yes",
"automation": {
"cancelation_token": "delay-send--user-yes--abc-123",
"steps": [
{
"action": "delay",
"until": "20240408T080910.123"
},
{
"action": "send",
"template": "64TP5HKPFTM8VTK1Y75SJDQX9JK0"
}
]
}
}
'{
"runId": "1-65f240a0-47a6a120c8374de9bcf9f22c"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Response
200 - application/json
⌘I