Skip to main content
DELETE
/
lists
/
{list_id}
/
subscriptions
/
{user_id}
JavaScript
import Courier from '@trycourier/courier';

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

await client.lists.subscriptions.unsubscribeUser('user_id', { list_id: 'list_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
)
client.lists.subscriptions.unsubscribe_user(
    user_id="user_id",
    list_id="list_id",
)
package main

import (
	"context"

	"github.com/trycourier/courier-go"
	"github.com/trycourier/courier-go/option"
)

func main() {
	client := courier.NewClient(
		option.WithAPIKey("My API Key"),
	)
	err := client.Lists.Subscriptions.UnsubscribeUser(
		context.TODO(),
		"user_id",
		courier.ListSubscriptionUnsubscribeUserParams{
			ListID: "list_id",
		},
	)
	if err != nil {
		panic(err.Error())
	}
}
package com.courier.example;

import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.lists.subscriptions.SubscriptionUnsubscribeUserParams;

public final class Main {
    private Main() {}

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

        SubscriptionUnsubscribeUserParams params = SubscriptionUnsubscribeUserParams.builder()
            .listId("list_id")
            .userId("user_id")
            .build();
        client.lists().subscriptions().unsubscribeUser(params);
    }
}
require "courier"

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

result = courier.lists.subscriptions.unsubscribe_user("user_id", list_id: "list_id")

puts(result)
<?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 {
  $result = $client->lists->subscriptions->unsubscribeUser(
    'user_id', listID: 'list_id'
  );

  var_dump($result);
} catch (APIException $e) {
  echo $e->getMessage();
}
using TryCourier;
using TryCourier.Models.Lists.Subscriptions;

CourierClient client = new();

SubscriptionUnsubscribeUserParams parameters = new()
{
    ListID = "list_id",
    UserID = "user_id",
};

await client.Lists.Subscriptions.UnsubscribeUser(parameters);
courier lists:subscriptions unsubscribe-user \
  --api-key 'My API Key' \
  --list-id list_id \
  --user-id user_id
curl --request DELETE \
  --url https://api.courier.com/lists/{list_id}/subscriptions/{user_id} \
  --header 'Authorization: Bearer <token>'
{
  "message": "Example message text",
  "type": "invalid_request_error"
}

Authorizations

Authorization
string
header
required

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

Path Parameters

list_id
string
required

A unique identifier representing the list you wish to retrieve.

user_id
string
required

A unique identifier representing the recipient associated with the list

Response