Skip to main content
POST
/
journeys
/
{templateId}
/
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 journeysInvokeResponse = await client.journeys.invoke('templateId', {
  data: { order_id: 'order-456', amount: 99.99 },
  user_id: 'user-123',
});

console.log(journeysInvokeResponse.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
)
journeys_invoke_response = client.journeys.invoke(
template_id="templateId",
data={
"order_id": "order-456",
"amount": 99.99,
},
user_id="user-123",
)
print(journeys_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"),
)
journeysInvokeResponse, err := client.Journeys.Invoke(
context.TODO(),
"templateId",
courier.JourneyInvokeParams{
JourneysInvokeRequest: courier.JourneysInvokeRequestParam{},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", journeysInvokeResponse.RunID)
}
package com.courier.example;

import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.journeys.JourneyInvokeParams;
import com.courier.models.journeys.JourneysInvokeRequest;
import com.courier.models.journeys.JourneysInvokeResponse;

public final class Main {
private Main() {}

public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();

JourneyInvokeParams params = JourneyInvokeParams.builder()
.templateId("templateId")
.journeysInvokeRequest(JourneysInvokeRequest.builder().build())
.build();
JourneysInvokeResponse journeysInvokeResponse = client.journeys().invoke(params);
}
}
require "courier"

courier = Courier::Client.new(api_key: "My API Key")

journeys_invoke_response = courier.journeys.invoke("templateId")

puts(journeys_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 {
$journeysInvokeResponse = $client->journeys->invoke(
'templateId',
data: ['order_id' => 'bar', 'amount' => 'bar'],
profile: ['foo' => 'bar'],
userID: 'user-123',
);

var_dump($journeysInvokeResponse);
} catch (APIException $e) {
echo $e->getMessage();
}
using System;
using TryCourier;
using TryCourier.Models.Journeys;

CourierClient client = new();

JourneyInvokeParams parameters = new() { TemplateID = "templateId" };

var journeysInvokeResponse = await client.Journeys.Invoke(parameters);

Console.WriteLine(journeysInvokeResponse);
courier journeys invoke \
--api-key 'My API Key' \
--template-id templateId
curl --request POST \
--url https://api.courier.com/journeys/{templateId}/invoke \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"user_id": "user-123",
"data": {
"order_id": "order-456",
"amount": 99.99
}
}
'
{
  "runId": "1-65f240a0-47a6a120c8374de9bcf9f22c"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

templateId
string
required

A unique identifier representing the journey to be invoked. Accepts a Journey ID or Journey Alias.

Body

application/json

Request body for invoking a journey. Requires either a user identifier or a profile with contact information. User identifiers can be provided via user_id field, or resolved from profile/data objects (user_id, userId, or anonymousId fields).

user_id
string

A unique identifier for the user. If not provided, the system will attempt to resolve the user identifier from profile or data objects.

profile
object

Profile data for the user. Can contain contact information (email, phone_number), user identifiers (user_id, userId, anonymousId), or any custom profile fields. Profile fields are merged with any existing stored profile for the user. Include context.tenant_id to load a tenant-scoped profile for multi-tenant scenarios.

data
object

Data payload passed to the journey. The expected shape can be predefined using the schema builder in the journey editor. This data is available in journey steps for condition evaluation and template variable interpolation. Can also contain user identifiers (user_id, userId, anonymousId) if not provided elsewhere.

Response

Journey invocation accepted

runId
string
required

A unique identifier for the journey run that was created.