> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developer.americanexpress.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developer.americanexpress.ferndocs.com/_mcp/server.

# Unenroll an account from agent-executed commerce

POST https://apisandboxm.americanexpress.com/payments/digital/v1/agentic-commerce/unenrollments
Content-Type: application/json

Unenrolls an account from Agentic Commerce

Reference: https://developer.americanexpress.ferndocs.com/payment-services/agentic-commerce/api-reference/unenrollments/unenroll

## Authentication

- `Authorization` header (bearer token, required) — OAuth 2.0 client credentials. Exchange your API key and secret for a bearer token, then send it as `Authorization: Bearer <token>`.

## Servers

- `https://apisandboxm.americanexpress.com` (sandbox, default)
- `https://apigwm.americanexpress.com` (production)

## Request

### Headers

- `Authorization` (string, required) — The OAuth authorization header generated as prescribed in the Oauth 2.0 guide
- `trackingId` (string, required) — A unique identifier for request tracking.
- `agentId` (string, required) — Agent's unique identifier.

### Body (application/json)

This endpoint expects an UnenrollmentsRequest.

- `enrollmentId` (string, required) — A unique identifier for the enrolled account.
- `initiator` (enum, required) — Indicates the source that triggered the unenrollment action, distinguishing between user-initiated and agent-initiated requests.
  - Allowed values: `AGENT`, `USER`
- `reasonCode` (enum, required) — A predefined code representing the reason for unenrollment, used to support auditability, compliance, and operational decisioning.
  - Allowed values: `USER_REQUESTED`, `PRIVACY_CONCERNS`, `SWITCHED_ACCOUNT`, `DATA_SHARING_DECLINED`, `FAILED_AUTHENTICATION`, `ACCOUNT_COMPROMISED`, `SUSPICIOUS_ACTIVITY`, `RISK_POLICY_VIOLATION`, `TERMS_VIOLATION`

## Response

### 200

Successful response

## Errors

### 400 Bad Request Error

Bad request

- `error` (ErrorInvalidFieldsResponseError, required)

### 401 Unauthorized Error

Unauthorized

- `any`

### 404 Not Found Error

Resource not found

- `any`

### 422 Unprocessable Entity Error

Unprocessable entity

- `error` (ErrorBusinessExceptionResponseError, required)

### 500 Internal Server Error

Service error

- `error` (ErrorSystemDownResponseError, required)

## Types

### ErrorInvalidFieldsResponseError

- `code` (string, required) — An error code that is returned when request validation fails.
- `description` (string, required) — An error description that is returned when request validation fails.
- `type` (enum, required)
  - Allowed values: `USER_EXCEPTION`
- `param` (string, optional) — The parameter that caused the error, if applicable

### ErrorBusinessExceptionResponseError

- `code` (string, required) — An error code returned when a business rule validation fails.
- `description` (string, required) — An error description returned when a business rule validation fails.
- `type` (enum, required)
  - Allowed values: `BUSINESS_EXCEPTION`

### ErrorSystemDownResponseError

- `code` (enum, required)
  - Allowed values: `20001`
- `description` (enum, required)
  - Allowed values: `Internal server error`
- `type` (enum, required)
  - Allowed values: `SYSTEM_EXCEPTION`

## Examples

**Request**

```json
{
  "enrollmentId": "string",
  "initiator": "AGENT",
  "reasonCode": "USER_REQUESTED"
}
```

**Response**

```json
{}
```

**SDK Code**

```python
import requests

url = "https://apisandboxm.americanexpress.com/payments/digital/v1/agentic-commerce/unenrollments"

payload = {
    "enrollmentId": "string",
    "initiator": "AGENT",
    "reasonCode": "USER_REQUESTED"
}
headers = {
    "Authorization": "Bearer <token>",
    "agentId": "agentId",
    "trackingId": "trackingId",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://apisandboxm.americanexpress.com/payments/digital/v1/agentic-commerce/unenrollments';
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <token>',
    agentId: 'agentId',
    trackingId: 'trackingId',
    'Content-Type': 'application/json'
  },
  body: '{"enrollmentId":"string","initiator":"AGENT","reasonCode":"USER_REQUESTED"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://apisandboxm.americanexpress.com/payments/digital/v1/agentic-commerce/unenrollments"

	payload := strings.NewReader("{\n  \"enrollmentId\": \"string\",\n  \"initiator\": \"AGENT\",\n  \"reasonCode\": \"USER_REQUESTED\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("agentId", "agentId")
	req.Header.Add("trackingId", "trackingId")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://apisandboxm.americanexpress.com/payments/digital/v1/agentic-commerce/unenrollments")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["agentId"] = 'agentId'
request["trackingId"] = 'trackingId'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"enrollmentId\": \"string\",\n  \"initiator\": \"AGENT\",\n  \"reasonCode\": \"USER_REQUESTED\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://apisandboxm.americanexpress.com/payments/digital/v1/agentic-commerce/unenrollments")
  .header("Authorization", "Bearer <token>")
  .header("agentId", "agentId")
  .header("trackingId", "trackingId")
  .header("Content-Type", "application/json")
  .body("{\n  \"enrollmentId\": \"string\",\n  \"initiator\": \"AGENT\",\n  \"reasonCode\": \"USER_REQUESTED\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://apisandboxm.americanexpress.com/payments/digital/v1/agentic-commerce/unenrollments', [
  'body' => '{
  "enrollmentId": "string",
  "initiator": "AGENT",
  "reasonCode": "USER_REQUESTED"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
    'agentId' => 'agentId',
    'trackingId' => 'trackingId',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://apisandboxm.americanexpress.com/payments/digital/v1/agentic-commerce/unenrollments");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("agentId", "agentId");
request.AddHeader("trackingId", "trackingId");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"enrollmentId\": \"string\",\n  \"initiator\": \"AGENT\",\n  \"reasonCode\": \"USER_REQUESTED\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "agentId": "agentId",
  "trackingId": "trackingId",
  "Content-Type": "application/json"
]
let parameters = [
  "enrollmentId": "string",
  "initiator": "AGENT",
  "reasonCode": "USER_REQUESTED"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://apisandboxm.americanexpress.com/payments/digital/v1/agentic-commerce/unenrollments")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```