Skip to main content
POST
/
messages
/
{message_id}
/
cancel
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 messageDetails = await client.messages.cancel('message_id');

console.log(messageDetails.id);
import os
from courier import Courier

client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
message_details = client.messages.cancel(
"message_id",
)
print(message_details.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"),
)
messageDetails, err := client.Messages.Cancel(context.TODO(), "message_id")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", messageDetails.ID)
}
package com.courier.example;

import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.messages.MessageCancelParams;
import com.courier.models.messages.MessageDetails;

public final class Main {
private Main() {}

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

MessageDetails messageDetails = client.messages().cancel("message_id");
}
}
require "courier"

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

message_details = courier.messages.cancel("message_id")

puts(message_details)
<?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 {
$messageDetails = $client->messages->cancel('message_id');

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

CourierClient client = new();

MessageCancelParams parameters = new() { MessageID = "message_id" };

var messageDetails = await client.Messages.Cancel(parameters);

Console.WriteLine(messageDetails);
courier messages cancel \
--api-key 'My API Key' \
--message-id message_id
curl --request POST \
--url https://api.courier.com/messages/{message_id}/cancel \
--header 'Authorization: Bearer <token>'
{
  "id": "1-5e2b2615-05efbb3acab9172f88dd3f6f",
  "status": "CANCELED",
  "enqueued": 1,
  "sent": 1,
  "delivered": 1,
  "opened": 1,
  "clicked": 1,
  "recipient": "string",
  "event": "string",
  "notification": "string",
  "error": "string",
  "reason": "BOUNCED"
}

Authorizations

Authorization
string
header
required

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

Path Parameters

message_id
string
required

A unique identifier representing the message ID

Response

200 - application/json
id
string
required

A unique identifier associated with the message you wish to retrieve (results from a send).

status
enum<string>
required

The current status of the message.

Available options:
CANCELED,
CLICKED,
DELAYED,
DELIVERED,
DIGESTED,
ENQUEUED,
FILTERED,
OPENED,
ROUTED,
SENT,
SIMULATED,
THROTTLED,
UNDELIVERABLE,
UNMAPPED,
UNROUTABLE
enqueued
integer<int64>
required

A UTC timestamp at which Courier received the message request. Stored as a millisecond representation of the Unix epoch.

recipient
string
required

A unique identifier associated with the recipient of the delivered message.

event
string
required

A unique identifier associated with the event of the delivered message.

notification
string
required

A unique identifier associated with the notification of the delivered message.

sent
integer<int64>

A UTC timestamp at which Courier passed the message to the Integration provider. Stored as a millisecond representation of the Unix epoch.

delivered
integer<int64>

A UTC timestamp at which the Integration provider delivered the message. Stored as a millisecond representation of the Unix epoch.

opened
integer<int64>

A UTC timestamp at which the recipient opened a message for the first time. Stored as a millisecond representation of the Unix epoch.

clicked
integer<int64>

A UTC timestamp at which the recipient clicked on a tracked link for the first time. Stored as a millisecond representation of the Unix epoch.

error
string | null

A message describing the error that occurred.

reason
enum<string> | null

The reason for the current status of the message.

Available options:
BOUNCED,
FAILED,
FILTERED,
NO_CHANNELS,
NO_PROVIDERS,
OPT_IN_REQUIRED,
PROVIDER_ERROR,
UNPUBLISHED,
UNSUBSCRIBED